Thursday, June 14, 2012

Install LAMP on most Linux Distros the easy way

For those of you who don't know what LAMP is, it stands for Linux, Apache, MySQL and PHP, which are a must have these days if you intend on running a Linux Server of any flavor. There are many ways to install the above Software, the most painful of them all is installing them one by one starting with Apache, then configure Apache to work with PHP by editing some options in the Apache Configuration File, followed by enabling PHP to connect to MySQL which is essentially the manual way of setting up your Web Server. The process itself however is anything but common sense and there are a lot of things one can do wrong while attempting the manual setup.

A much easier way to do the same is by using YUM (stands for Yellowdog Updater, Modified) is an open-source command-line package-management utility for RPM-compatible Linux operating systems released under the GNU General Public License. It's job is to basically make installing of Software on Linux easier for us, and it does a very good job of that. Please note that this will work on all RHEL Redhat based Linux Distros:

Follow the instructions below to install LAMP using YUM.

1. Connect to your Server either physically or using SSH, and bring up a Terminal Window.

2. Run the following command to update the YUM Database with the latest versions of Software:

yum update

Note that if you don't have YUM installed by default you will have to run this command to install YUM first:

sudo apt-get install yum

3. Once that's done, run the following command to install LAMP:

yum install httpd mysql mysql-server php php-devel php-mysql

4. Start MySQL by running the following command:

systemctl start mysqld.service /usr/bin/mysql_secure_installation

Press enter when you are asked for password, then set a root password for MySQL.

5. Run this command to make Apache start on system load:

systemctl start httpd.service
systemctl enable httpd.service

6. Run this command to make sure MySQL always runs on system load:

systemctl enable mysqld.service

7. Enter an exception into your Server Firewall by running this command:

/usr/bin/system-config-firewall

The firewall wizard is pretty straight forward, but you can find some screenshots on how to work the Firewall Wizard HERE. At the very least, you want to enable access for the following Services:

  • FTP
  • IMAP over SSL
  • Mail (SMTP
  • POP-3 over SSL
  • Secure WWW (HTTPS)
  • SSH
  • WWW (HTTP)

If you are on Ubuntu or LinuxMint or other Debian Distros it's even easier, but there is no YUM to use. Instead you will have to use "apt-get". The Advanced Packaging Tool, or APT, is a free user interface that works with core libraries to handle the installation and removal of software on the Debian GNU/Linux distribution and its variants. Take the following steps instead:

1. Install and run tasksel:

sudo apt-get install tasksel
sudo tasksel

2. You will be prompted with a software selection wizard. Select "LAMP Server" and hit Ok to install.

3. When prompted for MySQL password, enter a password for it and hit "OK".

4. Restart Apache to finish:

sudo /etc/init.d/apache2 restart

5. Configure your firewall as before.

That's all it takes! No manual configuration, no back and forth testing the integration of Apache, MySQL and PHP, it configures it all. Enjoy!

Pete Soheil
DigiOz Multimedia, Inc.
www.digioz.com