First let’s grab the packages we need for a basic LAMP setup:
apt-get install apache2 php5-cgi libapache2-mod-php5 mysql-server php5-mysql php5-common apache2.2-common ssl-cert
If using Ubuntu, be sure to install libapache2-mod-auth-mysql
apache2.2-common and ssl-cert are needed to generate a ssl cert
make-ssl-cert /usr/share/ssl-cert/ssleay.cnf apache.crt
mkdir /etc/apache2/ssl
mv apache.crt /etc/apache2/sslcd /etc/apache2/mods-enabled
ln -s ../mods-available/ssl.conf ssl.conf
ln -s ../mods-available/ssl.load ssl.load
Make sure /etc/apache2/ports.conf is listening on 443
Listen *:443
In your 000-default file in /etc/apache2/sites-enabled (or where ever your VirtualHosts are managed) Change:
NameVirtualHost *
<VirtualHost *>
to
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
Add a site for SSL:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/wwws
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/wwws>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
/etc/init.d/apache2 restart
By default, the User/group is www-data so make sure all your website files are owned by this user/group.
chown -R www-data:www-data /var/wwws/
Will accomplish this
All website files should be located in /var/www and /var/wwws (you can choose different directories, of course, like /home/www but make sure you change the config)