LAMP on Debian 7

Install Apache Web

sudo apt-get install apache2

Edit Apache's httpd.conf

The apache2.conf can be found in /etc/apache2/ and configures resource usage.

This is an example of a configuration for a VPS with 2GB of RAM:

KeepAlive Off
<IfModule prefork.c>
StartServers 4
MinSpareServers 20
MaxSpareServers 40
MaxClients 200
MaxRequestsPerChild 4500


NOTE:  The Apache config should be closely monitored. Different sites may require adjustment of these values to optimize performance. This configuration is presented as a good baseline.

Set Up Virtual Hosts

Create a file named in /etc/apache2/sites-available/ using your own domain in place of in the filename and configuration:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/
ErrorLog /var/www/
CustomLog /var/www/ combined
NOTE: you will need to make a new entry in your file like this for each domain you intend to host on your VPS

Now you must make the directories referenced in your vhost.conf file - remember to replace with your actual domain name:
sudo mkdir -p /var/www/
sudo mkdir /var/www/

Enable virtual host

sudo a2ensite

Restart Apache

sudo service apache2 restart

Install MySQL

sudo apt-get install mysql-server

Secure MySQL

We suggest you answer "yes" to all the options given when you run this command:


Create a Database

First you will need to log in to MySQL:

mysql -u root -p

Now, create a database and user, replacing webdata with your database name, webuser with your username, and password with a strong password:

create database webdata;
grant all on webdata.* to 'webuser' identified by 'password';

Quit MySQL:


Install PHP

sudo apt-get install php5 php-pear

Install MySQL support:

sudo apt-get install php5-mysql

Edit the /etc/php.ini to improve performance, error messages, and logs:

error_log = /var/log/php/error.log
max_input_time = 30

Create the error directory

sudo mkdir /var/log/php
sudo chown www-data /var/log/php

Restart Apache:

sudo service apache2 restart

  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

IP rDNS/PTR records

You can configure PTR or Reverse DNS records via the VPS Control Panel under rDNS. The record...

Serial Console

You may wish to use the Serial Console if the SSH console becomes inaccessible. The Serial...

LAMP on CentOS 6

Install Apache Web sudo yum install httpd Edit Apache's httpd.confThe httpd.conf...

LAMP on Ubuntu 14.04

Install Apache sudo apt-get update sudo apt-get install apache2 Install MySQL...

WordPress on Ubuntu 14.04

NOTE: You must have the LAMP stack installed before installing WordPress.Create the WordPress...