Install Apache, PHP And MySQL On CentOS 7

1. Installing Maria DB Server:
# yum -y install mariadb-server mariadb

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:

# systemctl start mariadb.service
# systemctl enable mariadb.service

to open 3306 port in cent osm use the following command:
# iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT

2. Set passwords for the MySQL root account:
# mysql_secure_installation
Follow the on screen procedure

3. Installing Apache2:
# yum -y install httpd

Now configure your system to start Apache at boot time...
# systemctl start httpd.service
# systemctl enable httpd.service

In CentOS 7.0 uses Firewall-cmd, so we have to customize it to allow external access to port 80 (http) and 443 (https).
# firewall-cmd --permanent --zone=public --add-service=http 
# firewall-cmd --permanent --zone=public --add-service=https
# firewall-cmd --reload

Now open localhost in your browser.

4. Installing PHP5:
We can install PHP5 and the Apache PHP5 module as follows:
# yum -y install php

We must restart Apache afterwards:
# systemctl restart httpd.service

To test whether php is working or not, create a demo page under var/www/html/
Ex: var/www/html/info.php and the file contains the following code


About the author

Janaki( - A Software developer with 9+ years of experience in multiple technology projects across web, mobile, and cloud applications with expertise in PHP, C#, MySQL, Web services and open source platforms.

Similar Posts

Sample nginx vhsot config file
Uninstall MySql on a Mac OS X
VMWare shared folder as apache vhost

Leave a reply


Eye Test: * Time limit is exhausted. Please reload CAPTCHA.