Installing Apache/MySQL/PHP on CentOS 7
LAMP or Linux, Apache, MySQL, and PHP is the default software stack most PHP+MySQL based applications use, it's the easiest and quickest way to get your PHP+MySQL application online. A LAMP stack can be installed on your CentOS install using the following commands.
Install Apache
To install and start Apache, input the following commands:
yum -y install httpd
Once Apache is installed, you can start it by using the command:
systemctl start httpd.service
To enable Apache to start on boot, use the following command:
systemctl enable httpd.service
Configure firewalld to Allow Web Traffic
CentOS 7’s built-in firewall is set to block web traffic by default. Run the following commands to allow web traffic:
sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --add-service=https --permanent
sudo systemctl restart firewalld
Install PHP
To install PHP and PHP-MySQL components [default version PHP 5.4], use the command:
yum install php php-mysql
To install latest version,
Restart Apache web server to put all changes into effect:
systemctl restart httpd.service
Install MySQL
To install MySQL (in this case MariaDB), input the following commands:
yum install mariadb-server mariadb
Once it's completed, use the following command to start the MySQL:
systemctl start mariadb
use mysql_secure_installation script to secure database (set root password, disable remotely logon from root, remove test database and remove anonymous users):
mysql_secure_installation
Then the prompt will ask you if you want to set a root password. Go ahead and enter Y, and follow the instructions:
To enable MariaDB to start on boot, use the following command:
systemctl enable mariadb.service
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS