Install Cockpit on Ubuntu 16.04

Install Cockpit on Ubuntu 16.04

We’ll show you, how to Install Cockpit on Ubuntu 16.04. In this article, we will show you how to install Cockpit CMS on an Ubuntu 16.04 VPS with PHP-FPM 7.0 and Nginx. Cockpit is open source self-hosted API-driven content management system (CMS) application written in PHP. Cockpit stores the data in an SQLite database so you don’t need to install or configure a database server such as MySQL. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 16.04 VPS.

1. Log in to your VPS via SSH with your sudo user

ssh user@vps_IP

2. Update the system and install necessary packages

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install nano git
[user]$ sudo apt-get install sqlite3 libsqlite3-dev

3. Install PHP and required PHP modules

To install the latest stable version of PHP version 7.0 and all necessary modules, run:

[user]$ sudo apt-get -y install php-fpm php-cli php-json php-curl php-gd php-common php-sqlite3

Edit the php.ini file as follows:
Set the PHP memory limit to 128MB

[user]$ sudo sed -i "s/memory_limit = .*/memory_limit = 128MB/" /etc/php/7.0/fpm/php.ini

Set fix_pathinfo to 0:

[user]$ sudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini

Set the timezone to your local timezone:

[user]$ sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/fpm/php.ini

Change the values of upload_max_filesize and post_max_size to 100M:

[user]$ sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 100M/" /etc/php/7.0/fpm/php.ini
[user]$ sudo sed -i "s/post_max_size = .*/post_max_size = 100M/" /etc/php/7.0/fpm/php.ini

Create a new PHP-FPM pool for your user if you already don’t have one:

[user]$ sudo nano /etc/php/7.0/fpm/pool.d/your_user.conf
[your_user]
user = your_user
group = your_user
listen = /var/run/php/php7.0-your_user-fpm.sock
listen.owner = your_user
listen.group = your_user
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /

Do not forget to change your_user with your username.
Finally restart the PHP-FPM service:

[user]$ sudo service php7.0-fpm restart

4. Download Cockpit

Create a root directory for your Cockpit CMS using the following command:

[user]$ mkdir -p ~/myCockpit.com

Clone the project repository from GitHub:

[user]$ git clone https://github.com/COCOPi/cockpit.git ~/myCockpit.com

5. Install and configure Nginx

To install the latest stable version of Nginx available on the Ubuntu repositories, run:

[user]$ sudo apt-get install nginx

Next, create a new Nginx server block:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
[user]$ sudo nano /etc/nginx/sites-available/myCockpit.com
server {
    listen 80;
    server_name _ myCockpit.com;
    root /home/your_user/myCockpit.com;
    index index.php;

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

    access_log  /var/log/nginx/myCockpit.com.access.log;
    error_log   /var/log/nginx/myCockpit.com.error.log;

    # Deny direct access to .sqlite
    location ~ .sqlite$ {
        deny all;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-your_user-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param COCKPIT_URL_REWRITE On;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~ /\.ht {
        deny all;
    }
}

Do not forget to change your_user with your username.

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/myCockpit.com /etc/nginx/sites-enabled/myCockpit.com

Test the Nginx configuration and restart nginx:

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

6. Install Cockpit

To finish the installation and populate the sqlite database open http://myCockpit.com/install in your favorite web browser. The default credentials are username: admin password: admin. Once logged in, you should change the default admin password.

That’s it. You have successfully installed Cockpit CMS on your Ubuntu 16.04 VPS. For more information about how to manage your Cockpit installation, please refer to the official Cockpit documentation.


Of course you don’t have to Install Cockpit on Ubuntu 16.04, if you use one of our optimized CMS hosting plans, in which case you can simply ask our expert Linux admins to Install Cockpit on Ubuntu 16.04, for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to Install Cockpit on Ubuntu 16.04,  please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

1 thought on “Install Cockpit on Ubuntu 16.04”

Leave a Comment