server setup linux

This page describes how to get Apache and php running on a computer running Debian 9 (nicknamed Stretch). These installation steps will probably also work on kindred systems like Ubuntu and Linux Mint. In case it doesn't work out for your Linux system, search the web for help on installing a so called 'LAMP' stack (for Linux-Apache-MySQL-Php), there are lots of tutorials to be found.

1. Install Apache and php

Open a terminal and type

sudo apt-get update

to update the repositories, then

sudo apt-get install apache2 php libapache2-mod-php

If you now open a browser and navigate to 'localhost' you should see a page with the reassuring text 'It works!'

2. Enable url rewriting

Still in terminal, enter

sudo a2enmod rewrite

to load the rewriting module, then restart Apache with

sudo /etc/init.d/apache2 restart

3. Set up a webfolder

Create a folder where you want to place your website(s), e.g. /home/username/www

In terminal, type

sudo nano /etc/apache2/sites-available/000-default.conf

This opens a text editor. Change the line

DocumentRoot /var/www

into

DocumentRoot /home/username/www

Close and save by pressing CTRL-X and then Y.

4. Test

Create a file in your webfolder, named 'index.php' with the following content

<?php
  echo 'Hello world';
?>

And use your webbrowser to navigate to the address 'localhost'.

languages: en