How can I set up a simple, always-on development environment with PHP and Nginx, like the one configued in elementary/mvp?

1 Answer 1


Step 1: Installation

The following commands both add repositories for the latest stack software, update and upgrade yourself, and then install the required system.

sudo apt-add-repository ppa:nginx/stable &&
sudo apt-add-repository ppa:ondrej/nginx &&
sudo apt-add-repository ppa:ondrej/php5-5.6 &&
sudo apt-get update &&
sudo apt-get dist-upgrade &&
sudo apt-get install nginx php5-fpm php5-curl php5-geoip php5-json php5-mcrypt php5-memcache

Note: To turn this into a LEMP stack, just install MariaDB as if you were using Ubuntu 14.04 Trusty, and then php5-mysql and ass phpmyadmin to suit.

Step 2: Configuration

sudo nano /etc/nginx/sites-enabled/sitename.conf

Paste some configuration in, modifying the root, include and error_log paths.

server {
    listen 80;
    server_name local.localtest.me;
    root /path/to/site;
    error_log /path/to/site_error.log;
    access_log off;
    autoindex on;
    index index.php index.html;

    location / {
        try_files $uri $uri.html $uri/ @extensionless-php;

    location @extensionless-php {
        rewrite ^(.*)$ $1.php last;

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;

You can test the configuration with Nginx.

sudo nginx -t

Now we just need to restart the service.

sudo service nginx restart

Step 3: Use

Finally, navigate to local.localtest.me


  1. https://github.com/elementary/mvp/blob/master/CONTRIBUTE.md

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.