Linux Dash is a low-overhead server statistics monitoring application written in PHP. It is intended for anyone looking for a lightweight, easy to deploy server monitoring and view server resource usage via web interface in real time. In this step-by-step tutorial, we will show you how to install Linux Dash on an Ubuntu 14.04 VPS with Nginx and password protect the statistics pages.
Make sure your VPS is fully up-to-date by running the following:
apt-get update apt-get -y upgrade --show-upgraded
Check if Apache is already installed and running:
# /etc/init.d/apache2 status * apache2 is running
If so, stop the service and disable it from autostart:
/etc/init.d/apache2 stop * Stopping web server apache2 update-rc.d -f apache2 remove Removing any system startup links for /etc/init.d/apache2 ... /etc/rc0.d/K09apache2 /etc/rc1.d/K09apache2 /etc/rc2.d/S91apache2 /etc/rc3.d/S91apache2 /etc/rc4.d/S91apache2 /etc/rc5.d/S91apache2 /etc/rc6.d/K09apache2
Install Nginx, Git, PHP5-FPM and json and curl PHP extensions using the following command:
apt-get install git nginx php5-json php5-fpm php5-curl
Install Linux-dash to a ‘/var/www/html/’ directory on your server using Git:
cd /var/www/html/ git clone https://github.com/afaqurk/linux-dash.git
Create a new Nginx configuration file for your domain:
vi /etc/nginx/sites-available/your-domain.com
and add the following content to it:
server { listen 80; server_name your-domain.com; root /var/www/html/linux-dash; index index.html index.php; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location ~* \.(?:xml|ogg|mp3|mp4|ogv|svg|svgz|eot|otf|woff|ttf|css|js|jpg|jpeg|gif|png|ico)$ { try_files $uri =404; expires max; access_log off; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; } location / { index index.html index.php; } location ~ \.php(/|$) { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php5-fpm.sock; if (!-f $document_root$fastcgi_script_name) { return 404; } try_files $uri $uri/ /index.php?$args; include fastcgi_params; } } }
Enable the server block using the following command:
ln -s /etc/nginx/sites-available/your-domain.com /etc/nginx/sites-enabled/
Password Protect Linux Dash:
Add the following HttpAuthBasic module directives to your Nginx configuration file created above:
auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd;
so the ‘location’ block should look like this:
vi /etc/nginx/sites-available/your-domain.com
location / { index index.html index.php; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd; }
and your ‘dash’ directory, it’s sub directories and the files inside it should be password protected.
Restart the Nginx service for the changes to take effect:
service nginx restart
Use the htpasswd command (if you previously had apache installed on your server) to generate your htpasswd file:
htpasswd -b htpasswd NewUser NewPassword
Make sure you replace the ‘NewUserName’ and ‘NewPassword’ with your desired username and password for accessing the protected directory. For example:
htpasswd -bc /etc/nginx/.htpasswd rhadmin Xcnd6%s^cJc@d.M
will create a new file using ‘rhadmin’ as username and ‘Xcnd6%s^cJc@d.M’ as password.
Please note, once the new .htpasswd file is created and you want to create another user, use ‘htpasswd -b NewUser NewPassword’ command (using the -c flag would overwrite the original file).
Or, you could generate the encrypted password using Perl:
perl -le 'print crypt("your-password", "salt-hash")'
That is it. The installation of Linux-dash monitoring system is now complete. Open http://your-domain.com in your favorite web browser, enter your username and password to authenticate and start monitoring your server resources.
Of course you don’t have to do any of this if you use one of our Fully Managed Ubuntu Hosting services, in which case you can simply ask our expert Linux admins to install Linux Dash for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.