AMP AMP

How to install lamp on centos 7.5

Installation of lamp setup in centos 7.5

Check the centos version by using this command

[root@linuxhelp ~]# rpm -q centos-release
centos-release-7-5.1804.el7.centos.x86_64

Install the apache server by using the following command

 [root@linuxhelp ~]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.xeonbd.com
 * epel: mirrors.nipa.cloud
 * extras: mirror.xeonbd.com
 * remi-php70: remirepo.reloumirrors.net
 * remi-safe: remirepo.reloumirrors.net
 * updates: mirrors.nhanhoa.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-88.el7.centos will be installed
--> Finished Dependency Resolution
Installed size: 10 M
Is this ok [y/d/N]: y
.
.
.
Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1                           apr-util.x86_64 0:1.5.2-6.el7              
  httpd-tools.x86_64 0:2.4.6-88.el7.centos               mailcap.noarch 0:2.1.41-2.el7              
Complete!

Once the above step is completed start the apache service by using the following command

[root@linuxhelp ~]# systemctl start httpd

Once the apache service is started check the status of apache service

[root@linuxhelp ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-04-10 12:42:26 IST; 14s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 6264 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
    Tasks: 6
 .
.
Apr 10 12:42:26 linuxhelp systemd[1]: Starting The Apache HTTP Server...
Apr 10 12:42:26 linuxhelp httpd[6264]: AH00558: httpd: Could not reliably determine the serve...sage
Apr 10 12:42:26 linuxhelp systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

After completing the above step enable the apache by using the following commad

[root@linuxhelp ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

Install the mariadb server by using the following command

[root@linuxhelp ~]# yum install mariadb mariadb-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.xeonbd.com
 * epel: mirrors.nipa.cloud
 * extras: mirror.xeonbd.com
 * remi-php70: remirepo.reloumirrors.net
 * remi-safe: remirepo.reloumirrors.net
 * updates: mirrors.nhanhoa.com
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.60-1.el7_5 will be installed
.
.
.
Installed:
  mariadb.x86_64 1:5.5.60-1.el7_5               mariadb-server.x86_64 1:5.5.60-1.el7_5              
Dependency Installed:
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7      perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7     
  perl-DBD-MySQL.x86_64 0:4.023-6.el7               perl-DBI.x86_64 0:1.627-4.el7                   
  perl-Data-Dumper.x86_64 0:2.145-3.el7             perl-IO-Compress.noarch 0:2.061-2.el7           
  perl-Net-Daemon.noarch 0:0.48-5.el7               perl-PlRPC.noarch 0:0.2020-14.el7               
Dependency Updated:
  mariadb-libs.x86_64 1:5.5.60-1.el7_5                                                              
Complete!

Once the above step is completed start the mariadb service by using the following command

[root@linuxhelp ~]# systemctl start mariadb
Once the apache service is started check the status of mariadb service
 [root@linuxhelp ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-04-10 12:44:40 IST; 11s ago
  Process: 6747 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 6668 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 6746 (mysqld_safe)
    Tasks: 20
   CGroup: /system.slice/mariadb.service
           ├─6746 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─6908 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/l...
.
.
Hint: Some lines were ellipsized, use -l to show in full.

After completing the above step enable the mariadb by using the following commad

[root@linuxhelp ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

After enabling the service we need to secure the root password for mysql database

 [root@linuxhelp ~]# mysql_secure_installation
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): 
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] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!
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
production environment.
Remove anonymous users? [Y/n] y
 ... Success!
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] y
 ... Success!
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] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

Once it completed install php7.0 by using this command

[root@linuxhelp ~]# yum install php php-mbstring php-mcrypt php-gd php-mysql php-zip php-soap php-ldap php-curl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.xeonbd.com
 * epel: mirrors.nipa.cloud
 * extras: mirror.xeonbd.com
 * remi-php70: remirepo.reloumirrors.net
 * remi-safe: remirepo.reloumirrors.net
 * updates: mirrors.nhanhoa.com
Package php-mysql is obsoleted by php-mysqlnd, trying to install php-mysqlnd-7.0.33-7.el7.remi.x86_64 instead
Resolving Dependencies
--> Running transaction check
.
.
.
Installed:
  php.x86_64 0:7.0.33-7.el7.remi                 php-common.x86_64 0:7.0.33-7.el7.remi             
  php-gd.x86_64 0:7.0.33-7.el7.remi              php-ldap.x86_64 0:7.0.33-7.el7.remi               
  php-mbstring.x86_64 0:7.0.33-7.el7.remi        php-mcrypt.x86_64 0:7.0.33-7.el7.remi             
  php-mysqlnd.x86_64 0:7.0.33-7.el7.remi         php-pecl-zip.x86_64 0:1.15.4-1.el7.remi.7.0       
  php-soap.x86_64 0:7.0.33-7.el7.remi           
Dependency Installed:
  gd-last.x86_64 0:2.2.5-8.el7.remi                libmcrypt.x86_64 0:2.5.8-13.el7                  
  libwebp7.x86_64 0:1.0.2-1.el7.remi               libzip5.x86_64 0:1.5.2-1.el7.remi                
  php-cli.x86_64 0:7.0.33-7.el7.remi               php-json.x86_64 0:7.0.33-7.el7.remi              
  php-pdo.x86_64 0:7.0.33-7.el7.remi              
Complete!

Configure the info.php by using the following command

[root@linuxhelp ~]# vim /var/www/html/info.php

Once the all step is completed restart the apache service

[root@linuxhelp ~]# systemctl restart httpd

Switch to your browser and enter your domain name

The apache test page The php and it information page

With this the Method to install lamp on centos 7.5 comes to end

Tag : LAMP CentOS
FAQ
Q
How to check the apache MariaDB and PHP version?
A
Check the version by using the following command

httpd -v , mysql -V ,php -v
Q
How to configure port-based virtual host?
A
Go to the location /etc/httpd/conf/httpd.conf





listen :
Q
What is the Purpose of using the LAMP setup?
A
LAMP is a server configuration for various web applications. It helps in running servers and dynamic web sites. It is a web development platform that uses Linux operating system, Apache web s
Q
How to configure the host entry
A
enter into



vim /etc/hosts



configure the ip address and domain name
Q
What are the alternatives to lamp stack?
A
These are the alternatives LEMP, XAMMP and much more.