Guides 11792 Published by

The guide walks a user through setting up NestaCMS on an Ubuntu or Debian server by first listing essential prerequisites such as PHP 8.1+, Composer, a database backend, and a web server. It then shows how to install the required system packages, create an SQLite database file, clone the CMS repository into the web root, and run Composer to fetch dependencies while keeping files owned by www‑data. After copying the example environment file and adjusting database settings, the tutorial provides detailed configuration snippets for both Apache and Nginx, including virtual host rules, rewrite modules, and fastcgi handling. Finally, it covers securing directory permissions, troubleshooting common errors like missing PHP extensions or upload failures, and offers next steps such as logging into the admin panel, adding pages, and exploring community support.



How to install NestaCMS on Ubuntu or Debian Server

If you’re looking to spin up a minimal, flat‑file CMS that actually works on an older server, NestaCMS is the sweet spot. In the next few minutes you’ll know exactly which packages to pull in, how to set file permissions right, and why each step matters.

1 Prerequisites: what you need before you start
Item Reason
Ubuntu 20.04+ or Debian 11+ The scripts we use assume a recent LTS with systemd.
PHP 8.1+ (or 7.4 at minimum) Nesta requires the newer PHP syntax and the sqlite3 extension.
Composer Handles all of Nesta’s dependencies.
A database backend SQLite is fine for small sites; MySQL or PostgreSQL gives you a bit more power.
Web server (Apache 2 or Nginx) Needed to serve pages, but we’ll keep the config lean.

If your box already runs PHP and Composer, you’re halfway there.

2 Install the system packages
sudo apt update
sudo apt install -y php8.1 php8.1-cli php8.1-mbstring php8.1-json php8.1-xml \
    php8.1-curl php8.1-sqlite3 git unzip

We pull in the mbstring, json, and sqlite3 extensions because Nesta’s core code uses string functions, JSON for configuration, and SQLite as its default store.

If you skip any of those extensions the CMS will explode with a 500 error before you even hit the admin panel. I once saw a site die on boot because the mbstring module was missing, so double‑check.

3 Create an SQLite database file (or MySQL user)

For a quick start we’ll use SQLite:

sudo mkdir -p /var/www/nesta/data
sudo touch /var/www/nesta/data/db.sqlite
sudo chown -R www-data:www-data /var/www/nesta/data

If you prefer MySQL, create a database and user with the usual mysql client commands; just remember to update .env later.

4 Clone NestaCMS into the web root
cd /tmp && git clone https://github.com/nestacms/nesta.git
sudo mv nesta /var/www/nesta
sudo chown -R www-data:www-data /var/www/nesta

We move it out of /tmp because that directory is usually cleared on reboot. Changing ownership to www-data lets Apache/Nginx write the .cache, data, and other runtime directories without extra tricks.

Install Composer dependencies
cd /var/www/nesta
sudo -u www-data composer install --no-dev --optimize-autoloader

Running as www-data ensures that all generated files are owned correctly. The --no-dev flag keeps the image lean, and --optimize-autoloader speeds up autoloading in production.

6 Set up configuration

Copy the example environment file:

sudo cp .env.example .env

Open .env with your editor of choice. If you’re using SQLite, make sure this line points at the right file:

DB_CONNECTION=sqlite
DB_DATABASE=/var/www/nesta/data/db.sqlite

If you’re on MySQL change DB_CONNECTION=mysql, DB_HOST, DB_PORT, DB_NAME, DB_USER, and DB_PASSWORD accordingly. After that, run migrations to create the necessary tables:

sudo -u www-data php bin/console doctrine:migrations:migrate --no-interaction
7 Configure your web server
Apache

Create /etc/apache2/sites-available/nesta.conf:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/nesta/web

    <Directory /var/www/nesta/web>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/nesta_error.log
    CustomLog ${APACHE_LOG_DIR}/nesta_access.log combined
</VirtualHost>

Enable the site and rewrite module:

sudo a2ensite nesta.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
Nginx

Create /etc/nginx/sites-available/nesta:

server {
    listen 80;
    server_name example.com;

    root /var/www/nesta/web;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Link to sites-enabled and reload:

sudo ln -s /etc/nginx/sites-available/nesta /etc/nginx/sites-enabled/
sudo systemctl reload nginx
8 Secure permissions

The web server needs write access to the cache and data directories but no more. A quick sweep:

sudo find /var/www/nesta -type d -exec chmod 750 {} \;
sudo find /var/www/nesta -type f -exec chmod 640 {} \;
sudo chown -R www-data:www-data /var/www/nesta/{cache,data,public/uploads}

If you get a “Permission denied” when uploading an image from the admin panel, it’s almost always because of this.

9 Common pitfalls and what to look for
Symptom Likely cause
500 Internal Server Error on first visit Missing PHP extension (e.g., mbstring or sqlite3)
Admin login fails .env values are wrong or database file is unreadable
Images not uploading File permissions on /public/uploads
Slow page loads in prod Autoloader not optimized or cache folder not writable

If you hit a 500, check the web server error log (/var/log/apache2/nesta_error.log or /var/log/nginx/error.log). The message will usually point to the missing extension or permission issue.

10 What’s next?

You now have a fully working NestaCMS instance. From here you can:

If you ran into trouble, the community forums are surprisingly helpful. And remember: if something breaks after an update, a quick check of PHP extensions and file ownership will usually save the day.