Apache and php Install on Linux CentOS

Written by:

The installation of Apache on Linux distributions is straightforward. This article specifically utilizes CentOS 6.9.

Note: An active internet connection is required on the Linux machine for installation.

1 – Installation of the httpd package

Execute the following commands to install Apache:

yum -y install httpd

2 – Installation of the PHP module

yum -y install php

3 – Enabling Apache on system boot

chkconfig httpd on

4 – Starting the httpd service

service httpd start

To verify Apache’s functionality, open a browser and enter the Linux machine’s IP address or hostname. The default Apache page should appear.

01_2015-10-sharingit.com.br-WilliandeSouzaOliveira-instalacao_apache_php

For PHP testing:

1. In the /var/www/html directory, create a PHP test file:

cd /var/www/html/
vi teste.php

2. In the vi editor, press “i” to enter insert mode and input the following PHP script:

<?php
phinfo();
?>

3. Press :x to save and exit the editor.

By navigating to http://<linux_machine_ip>/teste.php, a page displaying PHP version and details should be displayed.

02_2015-10-sharingit.com.br-WilliandeSouzaOliveira-instalacao_apache_php

Note: The vi editor was utilized here. If it’s not installed, it can be installed using:

yum -y install vim

Leave a Reply

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