How to install Apache and PHP in CentOS

How to Linode VPSWe are configuring a new VPS box in Linode and we choose CentOS as the linux distribution. If you are in a similar situation, we show here a few steps that may help you with the installation. Doesn’t matter if you are not in Linode, Slicehost, GoDaddy or your own home based server. If you did not decide yet to get a VPS, it is a good solution if you want to scale your websites or web applications. Reseller hosting or shared hosting are fine but when you come to get traffic, you cannot depend on your neighbors to keep your site running or not. So, isolating your server under a VPS is a very good decision.

As reference (and inspiration), we got most of the steps from the following resources:

First of all, connect via SSH and log as root so you can install packages using yum installer.

Install Apache

sudo yum install httpd mod_ssl

Then, you can start your Apache server by running:

sudo /etc/init.d/httpd start

When navigating to http://, you will notice a new Welcome page.

centos_apache_welcome

Chkconfig

You can use chkconfig to configure httpd to run automatically each time the server is restarted.

sudo /sbin/chkconfig httpd on

How to Install PHP5 under CentOS

You can install it using yum installer. Specify all the modules availables or at least all modules that you require for your environment. In our case, we will specify the following:

sudo yum install php-common php-gd php-mcrypt php-pear php-pecl-memcache php-mhash php-mysql php-xml

Then, restart (or reload) Apache again:

sudo /etc/init.d/httpd reload

Configuration

Once the installation is ready, we need to configure Apache so we can host multiple sites in the same server. Also, we need to make sure Apache will run using fast-cgi (at least in our case).

Advertisement

Did you like it?

No comments yet.

Leave a Comment