Install LAMP (Apache with MariaDB and PHP) on CentOS/RHEL/Scientific Linux 6
LAMP is a combination of operating system and open-source software stack. The acronym LAMP is derived from first letters of Linux, Apache HTTP Server, MySQL database, and PHP, Perl or Python. We already have shown you how to install LAMP on many platforms.
In this tutorial, we have covered LAMP installation with MariaDB instead of MySQL on RHEL/CentOS/Scientific Linux 6.x. Here x stands for version such as 6.1, 6.2 etc.
My testbox hostname and IP address are server.unixmen.com and 192.168.1.200/24, respectively.
Apache is an open-source multi-platform web server. It provides a full range of web server features including CGI, SSL and virtual domains.
To install Apache, enter the following command from your terminal:
[root@server ~]# yum install httpd -y
Start the Apache service and let it to start automatically on every reboot:
[root@server ~]# /etc/init.d/httpd start [root@server ~]# chkconfig httpd on
Allow Apache server default port 80 through your firewall/router if you want to connect from remote systems:
[root@server ~]# vi /etc/sysconfig/iptables [...] -A INPUT -p udp -m state --state NEW --dport 80 -j ACCEPT -A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT [...]
[root@server ~]# /etc/init.d/iptables restart
Open your web browser and navigate to http://localhost/ or http://server-ip-address/.
MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.
First you have to remove existing MySQL packages if any:
[root@server ~]# yum remove mysql* mysql-server mysql-devel mysql-libs
Install REMI Repository to resolve MySQL Compatibility issue
You will probably get dependencies errors while installing MariaDB. So let us add REMI Repository to solve dependencies problems:
Thanks to AskMonty Knowledgebase to help me to solve the dependencies issues.
[root@server ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Install compat-mysql55 package now:
[root@server ~]# yum --enablerepo=remi-test --disablerepo=remi install compat-mysql55
Create a repository file for MariaDB and add the following lines:
For 32bit systems:
[root@server ~]# vi /etc/yum.repos.d/mariadb.repo # MariaDB 5.5 CentOS repository list - created 2013-06-06 07:42 UTC # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
For 64bit systems:
[root@server ~]# vi /etc/yum.repos.d/mariadb.repo
#MariaDB 5.5 CentOS repository list - created 2013-06-06 07:53 UTC
#http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Save and exit the file and run yum update command:
[root@server ~]# yum update
Now start installing MariaDB:
[root@server ~]# yum install MariaDB-devel MariaDB-client MariaDB-server -y
Start MariaDB service and let it to start automatically on every reboot:
[root@server ~]# /etc/init.d/mysql start Starting MySQL... SUCCESS! [root@server ~]# chkconfig mysql on
Set MySQL root password
By default MySWL root password is empty. So to prevent unauthorized access to MySQL, let us set root user password:
[root@server ~]# /usr/bin/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): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the 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] ... 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] ... 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] - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - 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] ... 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!
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.
Install PHP with following command:
[root@server ~]# yum install php -y
Create a sample “testphp.php” file in Apache document root folder and append the lines as shown below:
[root@server ~]# vi /var/www/html/testphp.php <?php phpinfo(); ?>
Restart httpd service:
[root@server ~]# /etc/init.d/httpd restart
Navigate to http://server-ip-address/testphp.php. It will display all 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 to http://server-ip-address/testphp.php. You will able to 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 will not be not found in CentOS/RHEL/Scientific Linux official repositories. So let us install it from EPEL repository.
To do so add EPEL repository first:
[root@server ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Now install phpMyAdmin:
[root@server ~]# yum install phpmyadmin -y
Open the phpmyadmin.conf file. Find and comment the whole /<Directory> section as shown below:
[root@server ~]# vi /etc/httpd/conf.d/phpMyAdmin.conf Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /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 ::1 # </RequireAny> # </IfModule> # <IfModule !mod_authz_core.c> # # Apache 2.2 # Order Deny,Allow # Deny from All # Allow from 127.0.0.1 # Allow from ::1 # </IfModule> #</Directory>
Open “config.inc.php” file and change from “cookie” to “http” to change the authentication in phpMyAdmin:
[root@server ~]# cp /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php [root@server ~]# vi /usr/share/phpMyAdmin/config.inc.php [...] /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'http'; [...]
Restart the Apache service:
[root@server ~]# /etc/init.d/httpd restart
Now you can access the phpmyadmin console by navigating to http://server-ip-address/phpmyadmin/ from your browser.
Enter your MySQL username and password which you have given in previous steps. In my case its “root” and “centos”.
That’s it. Your LAMP server is up and running now.
Like us on Facebook
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- Configure Your Browser To Use Tor On Ubuntu/Debian/Linux Mint : Tor, The Onion Router, is a network of Virtual Tunnels that allows users to communicate securely and...1 comment |
- Setup A Full Featured ITIL Management System Using Integria IMS On CentOS 6 : Integria IMS is a fully featured ITIL management system, featuring a ticketing system, inventory/C...4 comments |
- How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander : Ubuntu 13.10 Saucy will be released on October 17th. Hope it will come with lot of improvements and ...0 comments |
- OpenLDAP Installation and Configuration in Ubuntu 12.10/13.04/13.10 And Debian 6/7 : OpenLDAP is a free open source Light Weight Directory Access protocol developed by the OpenLDAP proj...0 comments |
- Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comments |
- OpenLDAP Installation and Configuration in Ubuntu 12.10/13.04/13.10 And Debian 6/7
- Configure Your Browser To Use Tor On Ubuntu/Debian/Linux Mint
- Setup A Full Featured ITIL Management System Using Integria IMS On CentOS 6
- Install LibreOffice 4.1.3 in Elementary OS ‘Luna’
- How To Install Simple Scan in Crunchbang ‘Waldorf’
- Selene Media Encoder: Convert Audio, Video Files To Most Popular Formats
- Linux Kernel 3.12.2 Is Available For Download! Install / Upgrade Instructions
- CentOS 6.5 Has Been Officially Released!
- Format Junkie: Convert Media Files To All Popular Formats
- Setup Squid Proxy Server On openSUSE 13.1
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .