Linux Help

LAMP: Linux, Apache, MySQL and PHP

Posted on Apr 30, 2016 in Linux Help | 0 comments

There’s many a time we need a CentOS node setup with Apache, PHP, and MySQL.  See how we provision our server(s). Overview LAMP is a collection of open source software to run web servers. LAMP is an acronym for (Linux, Apache, MySQL and PHP). This tutorial is going to assume that you already have CentOS 6 installed. You should also have some basic knowledge of how to operate the console and some basic knowledge of shell as well. You need to make sure you have root privileges and that you know how to access root shell before you begin. Choose An Editor Before we begin the installation process, we need to choose a text editor. For this guide, Nano will be the recommended text editor of choice. You can use Vim, but it’s slightly more complicated than Nano. Updating Your System You need to run some updates after a fresh CentOS6 install. To do this, type: yum update Make sure you have all of the possible updates selected and let them complete. After that’s finished, you’ll run the following: cat /etc/*release* When you type that in, you should the CentOS version you’re currently running. At the time of this tutorial (5/24/2015), the correct version should be: 6.6 SELinux Setup Next, we need to either disable or setup SELinux. It’s recommended that you disable SELinux because it’s not uncommon to receive errors when you’re running the LAMP stack. To disable SELinux (recommended), do the following: nano /etc/selinux/config You’ll notice a SELINUX line. To disable it, simply change the line to disabled by doing: SELINUX=disabled After this is done, you need to reboot the machine by typing: shutdown -r 0 Setting Up The EPEL Repository Since EPEL isn’t included in your base repository and EPEL comes with some extra helpful software, we’re going to need to set that up. Simply run: yum install epel-release -y yum update The EPEL repository should now be installed and updated The Installation Of Apache, MySQL and PHP Install Software First, start off with the following command: yum install mysql mysql-server mysql-devel httpd php-common php-gd \ php-pear php-pecl-memcache php-mysql php-xml php \ php-mcryptphp-mbstring php-devel gcc pcre-devel -y Enable Software Next, we’ll need to enable MySQL and Apache on startup. To do so, simply issue the following command: chkconfig httpd on chkconfig mysqld on The following command will ensure that Apache and MySQL start service httpd start service mysqld start If everything was done right up to this point, you should then see a dialogue from MySQL notifying you to change your password. Run the command: /usr/bin/mysql_secure_installation You will be taken through a series of prompts. All the defaults should be fine so simply hit enter on them all except for the one asking you to set the MySQL root password. Make sure to choose a strong password. This root password is different from the root password of your server. Confirmation If everything has been setup correctly, you should be able to reach your web server using the IP in a web browser. Congratulations, you have installed your first LAMP Stack on CentOS. Further Configuration Sometimes the default configuration values are not enough and need modified. This section will briefly go over some of the settings that you can change. Apache Configuration nano /etc/httpd/conf/httpd.conf Next, you need to allow for .htaccess overrides. To do this, search for the allowoverride function. Once you see it, just simply change: AllowOverRide None to AllowOverRide All If there’s a hashtag in front of AllowOverRide All, you need to remove it. Configuring PHP First thing’s first, we need to edit the PHP...

Read More