Install the lamp server (APACHE,MARIADB, PHP) in Centos/rhel/linux

Source: Internet
Author: User
Tags install php phpmyadmin

Install LAMP Server (Apache, MariaDB, PHP) on centos/rhel/scientific Linux 7By skshare on Facebook tweets on Twitter

LAMP is a combination of operating system and Open-source software stack. The acronym of LAMP is derived from first letters of Linux, Apache HTTP Server, Mysql/mARIADB database, and php/perl/python.

In this tutorial, let us see how to Setup LAMP server on rhel/centos/scientific Linux 7.

My testbox hostname and IP address are server.unixmen.local and 192.168.1.101/24respectively.

Install Apache

Apache is an open-source multi-platform Web server. It provides a full range of Web server features including CGI, SSL and virtual domains.

The following commands should is run with root user privileges.

To install Apache, enter the following command in your terminal:

Yum Install Httpd-y

Start the Apache service and make it to start automatically on every reboot:

Systemctl start Httpdsystemctl Enable httpd

If you ' re behind firewall or router, allow Apache server through your firewall/router in case you want to access it from T He remote systems. To do, enter the following commands from your Terminal:

Firewall-cmd--permanent--add-service=httpsystemctl Restart Firewalld
Test Apache

Open your Web browser and navigate to http://localhost/ or http://server-ip-address/.

Install MariaDB

MariaDB is a drop in replacement for MySQL. It's a robust, scalable and reliable SQL server that comes rich set of enhancements.

Now, start installing MariaDB as shown below:

Yum Install Mariadb-server mariadb-y

Start MariaDB service and let it to start automatically on every reboot:

Systemctl start Mariadbsystemctl Enable MARIADB
Set MySQL root password

By default, the MySQL root password is empty. So, to prevent unauthorized access to MySQL, let us set root user password. Enter the following command to setup MySQL root user password:

Mysql_secure_installation
/usr/bin/mysql_secure_installation:line 379:find_mysql_client:command not foundnote:running all PARTS of this SCRIPT I  S 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 CurrentPassword for the root user. If you ' ve just installed MariaDB, Andyou Haven ' t set the root password yet, the password would be a blank,so you should just Press ENTER here. Enter current password to root (enter for none): OK, successfully used password, moving on ... Setting The root password ensures that nobody can log into the Mariadbroot user without the proper authorisation. Set root Password? [y/n] Y# # Enter Y and press EnterNew Password:# # Enter New PasswordRe-enter new password:# # Enter password againPassword Updated successfully! Reloading privilege tables. ... success!  By default, a MariaDB installation had an anonymous user, allowing Anyoneto log into MariaDB without had to had a user  Account created Forthem.  This was intended only for testing, and the Installationgo a bit smoother. You should remove them before moving into aproduction environment. Remove anonymous users? [y/n] Y# # Enter Y and press Enter... success!  Normally, Root should only is allowed to connect from ' localhost '. Thisensures that someone cannot guess at the root of password from the network. Disallow Root login remotely? [y/n] Y# # Enter Y and press Enter... success!  By default, the MariaDB comes with a database named ' Test ' anyone canaccess. This was also intended only for testing, and should was removedbefore moving into a production environment. Remove test database and access to it? [y/n] Y# # Enter Y and press Enter-Dropping test database ... success! -Removing privileges on test database ... success! Reloading the privilege tables would ensure that all changes made so farwill take effect immediately. Reload privilege tables now? [y/n] Y# # Enter Y and press Enter... success! Cleaning up ...  All done! If you've completed all of the above steps, your mariadbinstallation should now is secure. Thanks for using mariadb!
Install PHP

PHP (recursive acronym for PHP:HYPERTEXT Preprocessor) are a widely used Open-source general purpose scripting language that I s especially suited for web development and can is embedded into HTML.

Install PHP with following command:

Yum install php php-mysql php-gd php-pear-y
Test PHP:

Create a sample "testphp.php" file in Apache document root folder and append the lines as shown below:

vi/var/www/html/testphp.php

Add the following lines.

<?php phpinfo ();?>

Restart httpd Service:

Systemctl Restart httpd

Navigate to http://server-ip-address/testphp.php. It would display all of the details about PHP such as version, build date and commands etc.

If you want to install all PHP modules, enter the command yum install php*-y and restart the httpd service. To verify for the modules, open Web browser and navigate tohttp://server-ip-address/testphp.php. You'll then see all PHP modules.

Install phpMyAdmin (Optional)

phpMyAdmin is a free Open-source Web interface tool used to manage your MySQL databases. By default phpMyAdmin is not a found in centos/rhel/scientific Linux official repositories. So-let us-install it from EPEL Repository.

To add EPEL repository, just follow the link.

    • Install EPEL Repository on rhel/centos/scientific Linux 7

Now, install PhpMyAdmin:

Yum Install Phpmyadmin-y
Configure phpMyAdmin

By default, PhpMyAdmin can is accessed from the localhost itself. Accessible globally, do the following steps.

Edit the phpmyadmin.conf file:

Vi/etc/httpd/conf.d/phpmyadmin.conf

Find and comment The whole /<directory> section and add the lines as shown below:

[...] Alias/phpmyadmin/usr/share/phpmyadminalias/phpmyadmin/usr/share/phpmyadmin# # Comment The following section ##
    #<directory/usr/share/phpmyadmin/>#   <ifmodule mod_authz_core.c>#     # Apache 2.4#     < requireany>#       Require IP 127.0.0.1#       Require IP:: #     </requireany>#   </ifmodule>#   <ifmodule!mod_authz_core.c>#     # Apache 2.2#     Order deny,allow#     Deny from all#     127.0.0.1# allow from     :: #   </IfModule>#</Directory> ## Add the following lines:<Directory /usr/share/phpMyAdmin/>        Options none        AllowOverride Limit        Require all granted</Directory> [...]

Edit "config.inc.php" file and change from "cookies" to "http" to the change of the authentication in PhpMyAdmin:

Change ' Cookies ' to ' http '.

' http '; authentication method (config, HTTP or cookie based)? [...]

Restart The Apache service:

Systemctl Restart httpd

Now you can access the phpMyAdmin console by navigating to the URL of http://server-ip-address/phpmyadmin/ from your Browser.

Enter your MySQL username and password which you had given in previous steps. In my case it "root" and "CentOS".

You'll be redirected to PhpMyAdmin main web interface.

Now you'll able to manage your MariaDB databases from PhpMyAdmin Web interface.

That ' s it. Your LAMP server is up and ready to use.

cheers!

A very useful article, especially for the rookie like me ~ http://www.unixmen.com/ install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/reprinted with here.

Install the lamp server (APACHE,MARIADB, PHP) in Centos/rhel/linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.