Install Apache on Debian and Ubuntu

Install Apache
sudo apt-get install apache2
sudo vi /etc/apache2/sites-available/default

change AllowOverride None > AllowOverride All in line 11

Enable Apache rewrite and restart

Achtung! Don’t forget or things will not work and you’ll waste hours trying to find out why

sudo a2enmod rewrite

Restart Apache

sudo service apache2 restart

If no error, its working

Optional: The following “example” is used to test that Apache is setup properly. You could skip the this part and go directly to installing MySQL Server.

Test that Apache is Setup Properly
sudo vi /etc/apache2/sites-available/www.example.com

copy this code into the file

<VirtualHost *:80>
     ServerAdmin webmaster@example.com
     ServerName www.example.com
     ServerAlias www.example.com
     DocumentRoot /var/www/www.example.com/
</VirtualHost>
sudo mkdir /var/www/www.example.com
sudo vi /var/www/www.example.com/index.html

enter some text “it lives”

{esc}:wq{return}

to save and exit vi

sudo chown -Rf www-data:www-data /var/www/www.example.com
sudo chmod -Rf 755 /var/www/www.example.com
a2ensite www.example.com
sudo service apache2 restart

You may also like...