Installing Apache and PHP on CentOS

1. Install Apache server
sudo yum install httpd mod_ssl
Configuration file is by default located in /etc/httpd/conf/httpd.conf, where root directory, port, etc. can be changed.

The follow command can setup httpd service as auto startup:
chkconfig httpd on

2. Install PHP
yum install php

3. Start the Apache server
service httpd start

4. Create a sample php file in the root directory. The default root directory configured in /etc/httpd/conf/httpd.conf is /var/www/html/. Creating a file with the following content, and name it as info.php.

<?php
   phpinfo();
?>

5. Try accessing the file in browser.

Leave a Reply

Your email address will not be published. Required fields are marked *