It’s been a little while since I posted part 3 of this tutorial so let’s get this thing going. At this point we have a Linux CentOS 5 server running. Now we need to install and configure all the major web services : Apache, PHP and MySQL.
For the most part of this article, I will be using the command line interface through SSH and not the default GUI (Gnome). You can download putty.exe, an SSH client, at http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Starting Apache Web Server
If you followed the previous parts of this tutorial, Apache 2.2 should be installed by default. You only have to make sure the service is started at boot time. To ensure that the httpd service is started automatically, type : chkconfig httpd on . This will add the httpd startup / shutdown scripts in the proper directories.
Now even though we configured the httpd service to start automatically, it is not started unless you rebooted the server. Simply type “service httpd start” to launch the Apache web server.
To make sure the web server is running, open a web browser on your host system (ie. not on your virtual machine) and try to access http://[your virtual machine’s ip]. If you don’t know your virtual server’s ip address, type “ifconfig” at the command prompt. If the web server is installed correctly and running, you should see a “Apache 2 Test Page”.
Installing MySQL Database Server
Great we now have a web server running so let’s install our database server. Again we’ll be using YUM to install MySQL so issue the following commands :
# yum update yum
# yum –y install mysql mysql-server
When the installation is completed, launch the MySQL server service by issuing : service mysqld start
We also want that service to be launched automatically so type the following command :
# service mysqld start
Now that we have our MySQL server running, let’s set the password for the root user :
# mysqladmin –u root password ‘new password’
# mysqladmin –u root –p –h your_hostname password ‘new password’
Installing PHP
At the command prompt, simply issue:
# yum –y install php
The PHP version available at the time of this writing is 5.1.6.
Now let’s restart the httpd service:
# service httpd restart
We’re now going to test our PHP installation. Create a new file named “index.php” into the folder /var/www/html. In that file, simply copy the following line :
<? phpinfo(); ?>
Now again, open a web browser at the address http://[your virtual machine’s ip] and you should see PHP’s information page :

Well that’s about it, you got yourself a virtual CentOS 5 web server. I will not go into details about how to configure Apache, MySQL, PHP or even hardening your Linux box but stay tuned for more tutorials on the subject.








Top Commentators