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



6 comments:

  1. I am presented with a screen to install various software after typing sudo tasksel into a Terminal.

    I select Lamp server, I then have to tab for the OK. Then I'm returned to the Terminal and nothing is installed.

    ReplyDelete
  2. Hello Robert,

    Can you post a screenshot of the various screens on our Forum at http://www.digioz.com/forum/? I will be happy to help you further as much as I can.

    ReplyDelete
  3. Anyone who thinks that trying to install software via a command line is "easy" is deluding themselves.

    There are millions of humans out there that would really appreciate a GUI based install for a Linux web server. For some sick reason Linux people think that typing obscure incomprehensible white text into a little black box is somehow is intuitive. It must be some special mental defect that affects them.

    20 years ago Redhat would install all of the GUI tools and servers at install and by using their admin tools you could confirm their versions and that they were installed. You could start and stop without memorizing a single command.

    ReplyDelete
    Replies
    1. Note that I said its "easier" not "easy". It sounds like you are not a fan of command line, which is fine. However, this is meant to show how it is done using command line. I am sure there are other ways to accomplish the same thing through GUI.

      Delete