[CentOS] Apache, MySQL, and PHP

Wed Apr 20 08:17:19 UTC 2005
Olaf Greve <o.greve at axis.nl>

Hi,

I have set up this combination on various platforms, including Windows, 
FreeBSD, RHEL and CentOS and I must say that by far the easiest was CentOS.

Down below follows the general procedure (based on CentOS 4), and if 
that doesn't help, feel free to ask some more specifics.

Firstly, much will depend upon which type of CentOS installation you 
performed: full, desktop or server. If you installed the system with all 
packages, there's very little to add lateron. If, OTOH, you chose one of 
the other options, you are likely to have to install some more packages.

Assuming you have performed a very basic installation, you'd typically 
need to perform the following calls (you can use yum or up2date for this):

up2date php mysql httpd
up2date mysql-server php-mysql

[Note: you can check the presence of these packages by performing: rpm 
-qa | grep <package name>, e.g. check the output when performing rpm -qa 
| grep mysql]

Once these packages are installed, you're almost done. You'll need to 
make sure the MySQL daemon gets started at boottime (or at least: that's 
what I always do as I don't want to have to start it manually), which 
can be achieved by the following:
/sbin/chkconfig mysqld on

Make sure to do the same for Apache:
/sbin/chkconfig httpd on

Now, Apache will not start using it's default httpd.conf file, so you'll 
have to edit that:
vi /etc/httpd/conf/httpd.conf

Now, search for the ServerName directive and set that to your machine's 
IP address, or fully qualified hostname (e.g. ServerName 
192.168.1.1:80). Scroll down a bit and set the UseCanonicalName 
directive to On (default = Off). Save your changes.

That's pretty much it. You can start Apache manually to make sure the 
config file is correct, by typing (as root): apachectl start

If all goes well, you should now see a set of httpd daemons when running 
top (or ps -ef | grep http).

Now, test your installation, by pointing a browser to the IP address (or 
fully qualified hostname, ot just the localhost) to test if Apache 
indeed is running.

Finally, I at this point in time I always reboot the machine one to make 
sure everything comes up properly at boot time.

Once this is done, you should be all set, and then you can start using 
PHP and MySQL as well. Please let me know if you need some help getting 
that running/tested as well...

Cheers!
Olafo