Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

Install Cockpit server manager on Ubuntu 18.04

Cockpit is a server manager that helps the system admins to access the GNU/Linux servers via web browser. This software helps to access the server logs and to start and stop the services, see resource usage via a graphical interface.

By using the Cockpit we can monitor the server activities and add several servers, it is not only the monitoring tool it also allow us to do everything on the server.

Step 1 

Login and update all Server OS packages


ssh root@IP_Address -p Port_number

IP_Address‘ and ‘Port_number‘ must be replaced by your IP and SSH port number of the respective servers (if using a custom port number). In addition, if necessary, replace “root” for the username of the admin account.

We must be sure that all Ubuntu OS required packages that have been installed on the server are up to date before starting the Cockpit installation. By using the following commands we can do this:

sudo apt-get update
sudo apt-get upgrade

Step 2

Install Cockpit

To install the latest version of Cockpit, run the following command in the official repositories of Ubuntu:


sudo apt-get install cockpit

We need to install a web server, an SSL certificate on that domain, and configure Cockpit behind a reverse proxy in order to access Cockpit solely using your domain name, e.g.https://your-domain.com, without the port number 9090 within the URL. Don’t worry, we’ll go over those stages as well in this guide.

Step 3

Install Apache

Check whether Apache is installed and running on the server:

dpkg -l | grep -i apache2
ps aux | grep apache2

If not installed, use the following Apache Web Server installation command:

apt-get install apache2

Enable Apache service to start on server boot automatically with:

systemctl enable apache2

The following command can also be used to check the status of the Apache service. It should already be up and running, but let’s double-check:

systemctl status apache2

This is how the output should appear:

apache2.service – The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Sun 2019-06-30 11:12:05 CDT; 9min ago
Main PID: 9277 (apache2)
Tasks: 7 (limit: 2321)
CGroup: /system.slice/apache2.service
├─ 9277 /usr/sbin/apache2 -k start
├─ 9280 /usr/sbin/apache2 -k start
├─ 9281 /usr/sbin/apache2 -k start
├─ 9282 /usr/sbin/apache2 -k start
├─ 9283 /usr/sbin/apache2 -k start
├─ 9284 /usr/sbin/apache2 -k start
└─22386 /usr/sbin/apache2 -k start

Step 4

Install a Let’s Encrypt SSL certificate

Install Certbot, a programme that automates the installation of SSL/TLS certificates using Let’s Encrypt Free SSL. This provides free security for your website. Run the following command to install the Let’s Encrypt packages:

sudo apt-get install certbot python-certbot-apache

On your domain, install Let’s Encrypt SSL certificate. Certbot configures the Apache configuration to use SSL automatically:

sudo certbot --apache -d your-domain.com -d www.your-domain.com

Enter a genuine email address because that is where information regarding your certificate status (for example, an expiring certificate) will arrive. During installation, select the option to redirect HTTP traffic to HTTPS.

Step 5

Configure an Reverse Proxy in Apache

Now in Apache we can set a reverse proxy. To do this, some additional proxy modules must be enabled in Apache. Execute the commands below:

a2enmod proxy
a2enmod proxy_http
a2enmod proxy_wstunnel

To apply the modifications, restart Apache:

systemctl restart apache2

Create a new configuration file for your domain with the following command once mod_proxy, mod_proxy http, and proxy_wstunnel have been enabled in Apache:

NOTE: It’s important that you replace “your-domain.com” in ALL places where it appears in the config file and elsewhere. Your settings may not work if you don’t.

nano /etc/apache2/sites-available/your-domain.com.conf

And then enter the following lines:

<VirtualHost *:80>

ServerName your-domain.com
ServerAlias www.your-domain.com

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.your-domain.com [OR]
RewriteCond %{SERVER_NAME} =your-domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<IfModule mod_ssl.c>

<VirtualHost *:443>

ServerName your-domain.com
ServerAlias www.your-domain.com

ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:9090/\ [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://127.0.0.1:9090/\ [P,L]

ProxyPass / http://127.0.0.1:9090/
ProxyPassReverse / http://127.0.0.1:9090/
<Location />
Order allow,deny
Allow from all
</Location>

SSLCertificateFile /etc/letsencrypt/live/your-domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your-domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

</VirtualHost>

</IfModule>

Remember to change the domain name of your ‘your-domain.com‘ Save the file, close it down, and disable the default Apache setup:

a2dissite 000-default

In Apache, enable the configuration “your-domain.com.conf” with:

a2ensite your-domain.com

To enable it, we will use the subsequent command:

ln -s /etc/apache2/sites-available/your-domain.com.conf /etc/apache2/sites-enabled/your-domain.com.conf

Then, in order for the modifications to take effect, restart Apache:

systemctl restart apache2

Add the following lines to the Cockpit configuration file:

[WebService]
Origins = https://your-domain.com http://127.0.0.1:9090
ProtocolHeader = X-Forwarded-Proto
AllowUnencrypted = true

Restart Cockpit and set it to start when the server boots:

sudo systemctl restart cockpit.socket
sudo systemctl enable cockpit.socket

We can now visit Cockpit without having to utilise port 9090 in a web browser – instead, we may use https//your-domain.com.

Login as root or use the server’s existing system user account.

We can create it with this command if there are currently no user accounts created on the server:

adduser username

Replace the username with the actual new user account name and the new user account password will be set and confirmed. Make sure you use a strong new account password.

Now you have an installation of Cockpit working on your server Ubuntu 18.04.

Do you want our expert team to install Cockpit?

CONTACT US NOW

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Can't get what you are looking for?

Available 24x7 for emergency support.