Install a LAMP stack on Ubuntu or Debian
This article provides instructions for installing a LAMP (Linux, Apache, MySQL, PHP) stack on your server. Linux (Ubuntu or Debian) is your operating system, and Apache is your web daemon, which serves information that is stored in your MySQL database through PHP scripting for your users. By the end of this article, you will have a fully operational LAMP server, ready to serve out multiple virtual hosts.
- Basic understanding of SSH.
- Ability to copy and paste.
Install the LAMP stack
Log on to your server via SSH and then use either the automated or manual installation method.
Automated installation method
Recent versions of Ubuntu and Debian can use
tasksel to automate the LAMP stack installation.
- If necessary, install
sudo apt-get update
sudo apt-get install tasksel
taskselwith the lamp-server installation argument:
sudo tasksel install lamp-server
The software necessary for a LAMP stack is installed automatically. For more information about using the Debian wiki.
Manual installation method
Use a one-line command for an expedient manual set up of your LAMP server on your server operating system, or perform manual installation steps.
sudo "apt-get update && apt-get install apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql && service mysql start && mysql_secure_installation && service mysql restart && service apache2 restart && ufw allow 80/tcp"
Manual installation steps
Recent Ubuntu and Debian releases typically work with the preceding one-line command. If the that installation method doesn't work, complete the following steps, which break the one-line command into individual steps.
- Update the apt repository:
sudo apt-get update
- After the update has completed, install the necessary packages:
sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql
- Run the following command to start and secure the MySQL server:
sudo sh -c "service mysql start && mysql_secure_installation"
Provide answers for the following system prompts:
- current mysql password: (Leave blank.)
- new password: (You decide, but make it secure.)
- delete test data? (Select Yes.)
- remove anonymous-user accounts? (Select Yes.)
- allow remote users? (Select No.)
- Restart the MySQL server and allow port 80 through the firewall.
sudo sh -c "service mysql restart && service apache2 restart && ufw allow 80/tcp"
The installation is complete. To test it, browse to http://serverIpAddress/.
© 2011-2013 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER