Deploy LAMP on CentOS7

Many open source p[projects require LAMP with database and database user ready to go. Here we will look at basic commands on CentOS7 to get it up and running quickly.

After CentOS7 installed update all packages

yum update -y

Install apache web server

yum install httpd

Start service and enable it to start on boot

systemctl start httpd.service
systemctl enable httpd.service

Install MariaDB database server

yum install mariadb-server mariadb

Start mysql services

systemctl start mariadb

Secure mysql installation

mysql_secure_installation

Enable MariaDB to start on boot

systemctl enable mariadb.service

Install PHP with mysql support

yum install php php-mysql

Restart apache web server

systemctl restart httpd.service

Open necessary firewall ports for example http

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload

And finally create database and user. See example below.

create database mydb;
grant usage on *.* to mydbuser@localhost identified by 'mypassword';
grant all privileges on mydb.* to user@localhost ;
FLUSH PRIVILEGES;