In this tutoriaI I will explain how to set up a LAMP-stack on Debian.
LAMP is an acronym for a software bundle consisting of Linux, Apache, MySQL and PHP, all running together in order to power websites.
I will be using Debian “wheezy” 7.7.0, but the instructions will still be viable to newer and earlier releases.
1. Install software
Fire up a shell, and type the following.
Make sure you are logged in as root, or use sudo, when running this command.
root@debian:~# apt-get install -y mysql-server apache2 libapache2-mod-php5 php5-mysql
You will be asked to choose a password for the root user of MySQL.
We will use this password later to create a database for your website.
2. Configure Apache
Create a file with your domain name, “mydomain.com”, and place it under the following location: /etc/apache2/sites-available/mydomain.com
Put the following content inside the file:
ServerName www.mydomain.com ServerAlias mydomain.com DocumentRoot /var/www Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all
ServerName is the primary hostname you are going to use.
ServerAlias is variations of the hostname that you also want to resolve to the same content, you can put multiple variations separated by a space ” “.
DocumentRoot is the path to your content.
Directory is the same as DocumentRoot, and specifies permissions and settings for the path.
Options Indexes will display a directory listing of all files, if there is not Index file. You can change this to Options -Indexes if you dont want a directory listing to occur.
Options FollowSymLinks will allow the usage of symlinks to link folders to the DocumentRoot path.
Options MultiViews will try to find the closest match if the specified file is not found.
AllowOverride All will allow custom .htaccess files to be allowed.
Enable the new configuration for your site:
root@debian:~# a2ensite mydomain.com
root@debian:~# a2enmod rewrite
Reload the configuration for apache:
root@debian:~# service apache2 reload
3. Configure MySQL
Login as the root user of MySQL, use the password you chose in step #1:
root@debian:/etc/apache2# mysql -u root -p Enter password:
Create a database:
mysql> create database mydomaincom; Query OK, 1 row affected (0.00 sec)
Create a username and password to access the new database:
mysql> grant all on mydomaincom.* TO 'user'@'localhost' IDENTIFIED BY 'password'; Query OK, 1 row affected (0.00 sec)
Specifying @’localhost’ after the username, will only allow access from within the server itself, not remote access.
The username and password you choose here will be used by the website in order to use the database.
You are now ready to start deploying your website! (WordPress, Joomla, Drupal etc..)