If you’re setting up your own Web server from scratch, you have to install a Web server, PHP, and MySQL – as well as maintain, administer, and update the system yourself. Here are the general steps that lead to your dynamic Web site:
1. Install The Web Server.
It’s much better to setup a new machine to be your Web server. Then you need to install Web server software (Apache).
# yum install -y httpd
2. Install MySQL
# yum install -y mysql-server
# service mysqld start
Change root’s password for MySQL management.
# mysqladmin -u root password <new-password>
Login to MySQL:
# mysql --user=root -p
On your Web site, create the following file with the name
mysql_test.php. Notice that you should change the value of
$host,
$user and
$password to the appropriate values. Now, type http://localhost/mysql_test.php on your browser. If no error or warning message is displayed, MySQL is working fine.
3. Install PHP
# yum install -y php php-mysql
In Linux, the directory in which your PHP programs need to be saved, might be /var/www/html. You can set the Web space to a different directory by configuring the Web server. Now, create the following file somewhere in your Web space with the name test.php.
To run this file on your own computer, you can type http://localhost/test.php into your browser address window. You should see the result the following in the Web browser.
Make sure that MySQL support is ON and you’re running PHP 5, not PHP 4. The general setting for PHP are stored in a file named /etc/php.ini. You can change the settings to change PHP’s behavior.
Have fun!