Dreaming of blogging on my own Web Server, studying for a while, I started to build my own Web Server. The linux distribution being utilized for this tutorial is Red Hat Enterprise Linux 3, however the steps should be very similar across most distribution. Be sured that you have the required development tools loaded for compiling programs from the source, these tools are beyond the scope of this doc and will not be covered here. In addition, it assumes you can use a text editor (e.g.: gedit, vi, emacs, etc) for basic editing tasks. Are you ready? — COOL! Here we go! 🙂

1. Grab 3 Sourcecode

2. Installation

Beginning now we will be working as root, sitting on a big sofa….with a cigar, ….change to the directory in which you saved your downloaded files and iyou can use su command f you want to become root, okay, then type the following comands:

# tar xzvf httpd-2.2.2.tar.gz (enter)
# tar xzvf mysql-4.0.27.tar.gz (enter)
# tar xzvf php-5.1.4.tar.gz

Having done these, now lets move on to compiling the source into usable programs. We will start with Apache.

3. Compiling Apache – follow these commands by typing:
#cd httpd-2.2.2 (enter)
#./configure –prefix=/usr/local/apache2–enable-mods-shared=most (enter)
(This telles Apache to install in the /usr/local/apache2 directory and to build most of the available loadable modules. Well, of course you have a bunch of options with Apache, but these should work for the most part. Once the configuration is done and the system returns the prompt to you, type the following command)

#make (it takes me several minutes, issue the following command once the prompt comes back again)
#make install
(Me voila Apache is installed! Bravo!)
We still need to make a few minor changes as follows:

# gedit /usr/local/apache2/conf/httpd.conf
or # emacs /usr/local/apache2/conf/httpd.conf
or # vi/usr/local/apache2/conf/httpd.conf

Then check the following line is present in the httpd.conf file at the bottom of the LoadModule list, add it if it is not there;

LoadModule php5_module modules/libphp5.soNote if you download php 4.x.x you should change as:
LoadModule php4_module modules/libphp4.so

Find the DirectoryIndex line and edit it like the following;

DirectoryIndex index.html index.html.var index.php

Find the AddType application section and add the following line;

AddType aplication/x-httpd-php .php

C’est tout! Save the file and we are done with Apache part. Let’s move on to MySQL!

4. Compiling MySQL
#cd mysql-4.0.27 (enter)
# ./configure –prefix=/usr/local/mysql –localstatedir=/usr/local/mysql/data –disable-maintainer-mode –with-mysqld-user=mysql –enbale-large-files-without-debug (enter)
#make install

Note that the above commands you may not need if you have downloaded mysql recently cause the current one is ready-to-run version.
Now let’s create a group for MySQL as follows:
#/usr/sbin/groupadd mysql (enter)
Now let’s creat a user called mysql which belongs to the mysql group;
#/usr/sbin/useradd -g mysql mysql (enter)
Then we install the db files as follows; (you might not need this step if you use the ready-to-run version)
#./scripts/mysql_install_db (enter)Okay, then we make some minor ownership changes;
#chown -R root:mysql /usr/local/mysql (enter)
#chown -R mysql:mysql /usr/local/mysql/data (enter)
still, using emacs/vi to add a line the ld.so.conf file as follows:
#gedit /etc/ld.so.conf
Adding the following line:
We are done! MySQL is installed! To run it, just issue the following command:
#/usr/local/mysql/bin/mysqld_safe –user=mysql &

the following command is optional, you can set a root password for MySQL as follows:
#/usr/local/mysql/bin/mysqladmin -u root password new_password
where new_password is the password you wanna use.

Okay, last monster-PHP!
5. Compiling PHP

(To be continued–Après la pause…)

Friday, July 28, 2006

Attention: yesterday I found that PHP 5.1.4 doesn’t fit for my current environment, it needs more high version of xm..stuff  😡 . So, I downloaded php 4.4.2 instead. C’est super! 🙂  Okay, follow me to compile php 4 by typing:

#cd /opt/php4.4.2 (enter)
#./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql (enter)
#make (enter)
#make install (inter)
Okay, grab a beer for a while till you have the prompt back, then type:
# cp php.ini-recommended /usr/local/php/lib/php.ini (enter)Then edit that file;#gedit /usr/local/php/lib/php.ini (enter)

And change the following: 
Find the doc_root section and enter the correct path for the directory which serves your web content such as:

doc_root= “/usr/local/apache2/htdocd/”

(this is default for apache2) Then find the file_uploads section and change it to reflect the following (for security reasons):


Wonderful! C’est fini! Let’s test!

6. Testing
Use ps command to check if your MySQL process is still running from earlier, if not, start it again! Then we need to start Apache by issuing the following command which starts the Apache web server:

#/usr/local/apache2/bin/apachetl start (enter)

now change into the following directory and using gedit create a file called test.php:

#cd /usr/local/apache2/hotdocs (enter)
#gedit test.php

and add the following line to the file:

<?php phpinfo(); ?>

Save the file, then open a browser (firefox) and point it to /localhost/test.php. You should see a listing of all kinds of cool info about PHP, Apache, etc. Now, I end up my first time fully functioning setup. However, during the whole setup process, I got some problems and I figured them out, so hopefully you don’t have so much troubles, if you do have, then GOOGLE or ask me, I will try my best to help you. :mrgreen:

Okay, let’s do something to celebrate, BBQ, having some champagne…Yeah we made it!

Well, now we have everything running now, the only minor problem is that we have to start Apache and MySQL manually, I’m a bit lazy and I do not want to have to remember to do everytime I reboot, so I wanna fix it. I found a way which is pretty good, but it seems that I need a while to get it done! Hopefully tomorrow I can work it out.

7. Starting Apache and MySQL automatically

July 30, 2006

Finally, I made it. Let’s start with MySQL. Logging in as root and with the mysql directory we set earlier.
#cd /usr/local/mysql/ <enter>

then copy the file mysql.server to the directory /etc/init.d as follows;
#cp support-files/mysql.server /etc/init.d/mysql

Now, let’s create some links in the startup folders fur run level 3 and 5;

#cd /etc/rc3.d <enter>
#ln -s ../init.d/mysql S85mysql <enter>
#ln -s ../init.d/mysql K85mysql <enter>
#cd /etc/rc5.d <enter>
#ln -s ../init.d/mysql S85mysql <enter>
#ln -s ../init.d/mysql K85mysql <enter>
#chmod 755 mysql <enter>
We’re done for MySQL, it should start automatically now when you reboot your machine (use ps -ef | grep to check if you want). Now let’s do the same steps for Apache, still, as root and with the apache2 directory configuration as we did before.

#cd /usr/local/apache2/bin <enter>
#cp apachectl /etc/init.d/httpd <enter>
#cd /etc/rc3.d <enter>
#ln -s ../init.d/httpd S85httpd <enter>
#ln -s ../init.d/httpd K85httpd <enter>
#cd /etc/rc5.d <enter>
#ln -s ../init.d/httpd S85httpd <enter>
#ln -s ../init.d/httpd K85httpd <enter>

Cool! The apache should start automatically along with MySQL the next time you boot your machine.

Well, having done this, I could setup a webserver and to build my WordPress in, and have a powerful blog site later! Yeah! I wrote the whole procedure down because I want to get it noted and hopefully it helps you guys. Ciao.