first need to install epel-release repo on centos 7
just run following command to install epel
yum install epel*
after that we can start install LAMP stack on CentOS7
LAMP stand for followings
L - Linux (CentOS)
A - Apache(httpd)
M - Mysql(mysqld)
P - PHP
now we can install httpd server using following
yum install httpd
this will install Apache server as httpd service
start the httpd service using following command
service httpd start
start httpd with system bootup use following command
chkconfig httpd on
add following firewall rules
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
now install mysql using following command
yum -y install mariadb-server mariadb
start mariadb service
service mariadb start
enable with system boot
chkconfig maradb on
set mysql root password
[root@server1 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): <--ENTER
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n]
New password: <--yourmariadbpassword
Re-enter new password: <--yourmariadbpassword
Password updated successfully!
Reloading privilege tables..
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
Remove anonymous users? [Y/n] <--ENTER
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <--ENTER
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] <--ENTER
- Dropping test database...
- Removing privileges on test database...
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <--ENTER
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
now test http://localhost or http://ip_of_server/ on browser it gives you a page like following
Testing 123..that page saying httpd is working fine
now we can install PHP on centos
yum -y install php
after installing php httpd requires restart
restart httpd using follwoing
service httpd restart
for test php
create a file including followings
and save it in /var/www/html folder as phpinfo.php
check with browser http://localhost/phpinfo.php or http://ip_of_server/phpinfo.php
now install php-mysql using following command to get mysql support in php
yum install php-mysql
then other modules also well
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
don't forget to restart apache again
service httpd restart
if you need to access mysql using webrowser install phpMyAdmin using following
yum install phpMyAdmin