Perfect Server on Centos 5.3
Install Apache (httpd), PHP, MySQL (server and client), and the component that allows php to talk to mysql.
yum -y install httpd php mysql mysql-server php-mysql php-gd
Configure the new services to start automatically
chkconfig httpd on
chkconfig mysqld on
service httpd start
service mysqld start
IMPORTANT! Set up the mysql database root password. Without a password, ANY user on the box can login to mysql as database root. The mysql root account is a separate password from the machine root account.
mysqladmin -u root password 'new-password' [quotes are required]
Make additional security-related changes to mysql.
mysql -u root -p
mysql> DROP DATABASE test; [removes the test database]
mysql> DELETE FROM mysql.user WHERE user = ''; [Removes anonymous access]
mysql> FLUSH PRIVILEGES;
mysql> exit;
Following the above steps, the document root for Apache is /var/www/html/
Create a test PHP script (such as phpinfo.php) and place it in the document root. A useful test script sample:
[php]
<?php
phpinfo();
?>
[/php]
PS: CentOS 5.3 ships with a default iptables ruleset installed that will reject all incoming traffic. Before you can use some services you must add rules to iptables so the services will work. Below is a list of common rules that users would use.
HTTP – Port 80
/sbin/iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 80 -j ACCEPT
HTTPS/SSL – Port 443
/sbin/iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 443 -j ACCEPT
SSH – Port 22
/sbin/iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 22 -j ACCEPT
FTP – Port 21
/sbin/iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 21 -j ACCEPT
MySQL – Port 3306
/sbin/iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 3306 -j ACCEPT
Save your ruleset
/etc/init.d/iptables save