How to Test Website Loading Speed in Linux Terminal

A website response time can have a great impact on user experience, and if you are a web developer, or simply a server administrator who is particularly responsible for organizing the pieces together, then you have to make it a point that users don’t feel frustrated while accessing your site – so there is really “need for speed”.

Read Also: httpstat – A Curl Statistics Tool to Check Website Performance

This guide will show you how to test a website response time from the Linux command line. Here, we will show how to check the time in seconds, it takes:

  • to perform name resolution.
  • for TCP connection to the server.
  • for the file transfer to begin.
  • for the first byte to be transferred.
  • for the complete operation.

Additionally, for HTTPS-enabled sites, we will also see how to test the time, in seconds, it takes: for a redirect, and SSL connection/handshake to the server to be completed. It sounds good right, okay, let’s get started.


cURL is a powerful command line tool to transfer data from or to a server, using protocols such as FILE, FTP, FTPS, HTTP, HTTPS and many others. In most cases, it is used as a command line downloader, or for checking HTTP headers. However, here, we will describe one of its lesser-known functionalities.

cURL has a useful option: -w for printing information on stdout after a completed operation. It has some variables that we can use to test the different response times listed above, of a website.

We will use some of the time-related variables, which can be passed in a given format as a literal string or inside a file.

So open your terminal and run the command below:

$ curl -s -w 'Testing Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null http://www.google.com
Test Website Loading Speed

Test Website Loading Speed

The variables in the above format are:

  • time_namelookup – time, in seconds, it took from the start until the name resolving was completed.
  • time_connect – time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.
  • time_pretransfer – time, in seconds, it took from the start until the file transfer was just about to begin.
  • time_starttransfer – time, in seconds, it took from the start until the first byte was just about to be transferred.
  • time_total – total time, in seconds, that the full operation lasted (millisecond resolution).

If the format is too long, you can write it in a file and use the syntax below to read it:

$ curl -s -w "@format.txt" -o /dev/null http://www.google.com

In the above command, the flag:

  • -s – tells curl to work silently.
  • -w – print the information on stdout.
  • -o – used to redirect output (here we discard the output by redirecting it to /dev/null).

For HTTPS sites, you can run the command below:

$ curl -s -w 'Testing Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nAppCon Time:\t\t%{time_appconnect}\nRedirect Time:\t\t%{time_redirect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null https://www.google.com
Test HTTPS Website Speed

Test HTTPS Website Speed

In the above format, the new time variables are:

  • time_appconnect – time, in seconds, it took from the start until the SSL connect/handshake to the remote host was completed.
  • time_redirect – time, in seconds, it took for all redirection steps including name lookup, connect, pretransfer and transfer before the final transaction was started; it computes the full execution time for multiple redirections.

Important points to be noted.

  • You will notice that the response time values keep on changing (due to several factors) as you run different tests, therefore it is advisable to collect several values and get an average speed.
  • Secondly, from the results of the commands above, you can see that accessing a website over HTTP is much faster than over HTTPS.

For more information, see the cURL man page:

$ man curl

Last but not least, if your results are not pleasing, then you have some adjustments to make on your server or within the code. You may consider using the following tutorials which explain programs and tips to make website(s) load faster in Linux:

  1. Install Nginx with Ngx_Pagespeed (Speed Optimization) on Debian and Ubuntu
  2. Speed Up Nginx Performance with Ngx_Pagespeed on CentOS 7
  3. Learn How to Speed Up Websites Using Nginx and Gzip Module
  4. How to Boost Linux Server Internet Speed with TCP BBR

That’s all! Now you know how to test website response time from the command line. You can ask questions via the feedback form below.

How to Install Zen Cart E-commerce Shopping Store in Linux

This topic will cover the step by step installation process of Zen Cart open source e-commerce platform in Debian-based Linux distributions and in RHEL and CentOS 7 Linux operating systems.

Zen Cart is an easy to manage and popular shopping CMS platform, written in PHP server-side programming language and deployed on top of LAMP stack that is mainly used to create online stores for advertising products and merchandises.

Requirements

  1. LAMP stack installed in CentOS 7
  2. LAMP stack installed in Ubuntu
  3. LAMP stack installed in Debian

Step 1: Install System Pre-Requirements for Zen Cart

1. On the first step, log in to your server console and issue the following commands in order to install unzip and curl utilities in your system.

# yum install unzip zip curl [On CentOS/RHEL]
# apt install zip unzip curl [On Debian/Ubuntu]

2. Zen Cart online e-commerce platform is very often installed on top of LAMP stack in Linux systems. If LAMP stack is already installed in your machine you should also make sure you install the following PHP extensions required by Zen Cart e-commerce application by issuing the following command.

------------------ On CentOS/RHEL ------------------ # yum install epel-release
# yum install php-curl php-xml php-gd php-mbstring
------------------ On Debian/Ubuntu ------------------
# apt install php7.0-curl php7.0-xml php7.0-gd php7.0-mbstring


3. After all required PHP modules and installed in your system, open default PHP configuration file specific to your Linux distribution and update the below PHP settings.

Issue the below command according to your distribution to open and edit PHP configuration file.

# vi /etc/php.ini [On CentOS/RHEL]
# nano /etc/php/7.0/apache2/php.ini [On Debian/Ubuntu]

Search and replace the following PHP settings as shown in the below excerpt:

file_uploads = On
allow_url_fopen = On
memory_limit = 64M
upload_max_file_size = 64M
date.timezone = Europe/Bucharest

Visit the official PHP time zone list in order to find the correct timezone according to your server geographical location.

4. After you’ve updated PHP configuration file with the required settings, save and close the file and restart Apache service to re-read the configurations by issuing the following command.

# systemctl restart httpd [On CentOS/RHEL]
# systemctl restart apache2 [On Debian/Ubuntu]

5. Zen Cart e-commerce platform needs a RDBMS database to store application data. To create a Zen Cart database, log to MySQL server console and issue the below command to create Zen Cart database and the credentials needed to access the database.

Replace the database name, user and password variables with your own settings.

# mysql -u root -p
MariaDB [(none)]> create database zencart_shop;
MariaDB [(none)]> grant all privileges on zencart_shop.* to 'your_user'@'localhost' identified by 'your_password';
MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit

Step 2: Install Zen Cart in CentOS, Debian and Ubuntu

6. In order to install Zen Cart e-commerce application, first download the latest Zen Cart zip archive file in your system by issuing the below command.

# wget https://sourceforge.net/projects/zencart/files/CURRENT%20-%20Zen%20Cart%201.5.x%20Series/zen-cart-v1.5.5e-03082017.zip 

7. After Zen Cart zip file download finishes, issue the following commands to extract the zip archive and copy the installation files to web server document root path.

# unzip zen-cart-v1.5.5e-03082017.zip
# cp -rf zen-cart-v1.5.5e-03082017/* /var/www/html/

8. Next, issue the following command to grant Apache HTTP server full write permission to Zen Cart installation files from server’s document root path.

# chown -R apache:apache /var/www/html/ [On CentOS/RHEL]
# chown -R www-data:www-data /var/www/html/ [On Debian/Ubuntu]

9. Next, open a browser and navigate to your server IP address or domain name via HTTP protocol and hit on Click here link in order to start the installation process of Zen Cart.

http://your_domain.tld/
ZenCart Installation Wizard

ZenCart Installation Wizard

10. In the next step, Zen Cart installer will inspect your system and report eventual problems in case the system configuration does not meet all requirements to install the shopping platform. If no warnings or errors are displayed, click on Continue button to move to the next step.

ZenCart System Check

ZenCart System Check

11. On the next installation stage, check to agree the license terms and verify your store frontend URL addresses as illustrated in the below screenshot. Replace the IP address or domain name to match your server configuration. When you finish hit the Continue button to move forward with the installation process.

ZenCart System Setup

ZenCart System Setup

12. Next, supply MySQL database information (database host address, database name and credentials), check the Load Demo Data into Zen Cart database and select database character set, database prefix and SQL Cache Method as illustrated in the below screenshot. Click on Continue button when you finish in order to further configure Zen Cart.

ZenCart Database Setup

ZenCart Database Setup

13. In the next installation screen, supply an Admin Superuser name that will be used to log in to store backed and an email address for the Superuser admin account. Write or make a picture of the Admin temporary password and Admin directory name and hit on Continue button to start the installation process.

ZenCart Admin Setup

ZenCart Admin Setup

14. Wait for the installation process to finish and you will redirected to Zen Cart final installation screen. Here you will find two links for accessing Zen Cart Admin Backed dashboard and Your Storefront link, as illustrated in the below screenshot. Make sure you note the store admin backend address.

ZenCart Installation Finished

ZenCart Installation Finished

15. Now, before actually logging in to your store backend panel, first return to your server bash console and issue the below command in order to delete the installation directory.

# rm -rf /var/www/html/zc_install/

16. Afterwards, go back to browser and click on Admin backend link in order to be redirected to Zen Cart backend dashboard login page. Log in to Zen Cart admin panel with the admin user and password configured earlier and you should be prompted to change admin account temporary password in order to secure your store.

ZenCart Admin Login

ZenCart Admin Login

Setup ZenCart Admin Password

Setup ZenCart Admin Password

17. When you first log in to Zen Cart backend panel, a new initial setup wizard will be displayed in your screen. In the initial wizard add your store name, owner, store owner email address, store country, store zone and store address and click on Update button to save changes. After completing this last step you can start managing your online store, configure locations and taxes and add some products.

ZenCart Initial Setup Wizard

ZenCart Initial Setup Wizard

18. Finally, in order to visit your Zen Cart frontend store, navigate to your server IP address or domain name via HTTP protocol, as illustrated in the below screenshot. This is the webpage where your advertised products will be displayed for your clients.

http://ww.yourdomain.tld 
ZenCart Store Frontend

ZenCart Store Frontend

Congratulations! You have successfully deployed Zen Cart online e-commerce platform in your system.

Improvements to cPanel Account Package Extensions

cPanel & WHM is a very powerful piece of software, that allows server managers to more easily manage their servers. The real power, though, comes from its extendability. In most webhosting environments, cPanel accounts are built using Account Packages. To help cPanel & WHM integrators, we released a new feature four years ago, in cPanel & WHM version 11.40, called package extensions. Package extensions allow our technology partners like CloudLinux to extend cPanel account packages to include their own features. However, features that we have added starting in version 60 have caused unintended problems with package extensions. We have markedly improved this interaction in version 68.

The old problem with editing packages in 66 and below

Customers and third-party developers have successfully used our package extensions for many years. However, in the last two years or so when they attempt to edit a package to add a package extension using the editpkg WHMAPI1 call, they trigger a problematic series of events. The below scenario explains the problem we needed to fix.

Consider a package named ‘Rutabaga’ which allows accounts to use up to 1024M of bandwidth per month. Five accounts are subscribed to the package. The image below shows what that might look like.

Package extensions improved 1

The hosting provider then modifies account number five, allowing them to use up to 2048M of bandwidth per month. We now have a common situation where account number five is assigned to the Rutabaga package, with a custom value for the bandwidth limit. The other accounts are still using the value for bandwidth specified in the Rutabaga package.

Package extensions improved 2

Here is where the problem comes in: when the package, Rutabaga, is edited to add a package extension, the accounts subscribed to the package have their limits reset to the values specified in the package. In our scenario, account number five will have her bandwidth limit reset to match the rest of the accounts assigned to the Rutabaga package.

pkg extentions improved 3

From research and conversations, the expectation is for the custom limits defined in an account to be retained, so that’s what we wanted to fix.

New functions in Version 68!

Instead of changing the functionality of the existing API function and potentially breaking existing integrations, we opted to add additional functionality that could be incorporated by our integrators over time. In version 68 we added two new WHM API 1 functions to manage package extensions on packages: addpkgext and delpkgext. In the above scenario, if the integrator uses addpkgext instead of editpkg, the custom bandwidth limit will be retained, and the customer will remain unimpacted.

Package extensions improved 4

If your integration has historically needed to edit a package extension setting we recommend that you now use the addpkgext function in your integration. Running the addpkgext function against a package that already has that extension defined will result in the same package extension being added with the desired setting.

Though we did not deprecate or remove the package extensions parameter in the editpkg WHM API 1 function (to avoid the aforementioned potential errors), we strongly recommend that any existing integrators modify them to use the new addpkgext and delpkgext functions to handle package extension management.

What are your other integration pain points?

These functions are now used by our user interfaces and scripts as well, to ensure a consistent experience, and we will eventually move toward deprecating the editpkg call. For now, though: What other API and integration improvements would you like to see?

If you need help with your integrations, the best place to get it is our developer forum on the cPanel Forums, but you can always comment below, find me on twitter, or send me an email!

Upgrade Fedora 27 from Fedora 26 Using DNF (F26 to F27)

Fedora-vertical-logoThis is guide, howto upgrade Fedora 26 to Fedora 27 using DNF. This method works on desktop and server machines.

I have tested this method on several machines, but if you have problems, please let me know. Always remember backup, before upgrade!

1. Before Upgrade

1.1 Backup Your Data

Before doing anything, do full system backup or backup at least your important data: documents, pictures, videos, config files, log files, databases etc. This is very important step, because if something goes wrong and you have to do fresh install, then you can easily restore your data.

2. Upgrade Fedora 26 to Fedora 27 using DNF

2.1 Change root user


su -
## OR ##
sudo -i

2.2 Update Fedora 26 Packages

Just make sure that you have all latest packages installed.


dnf update

2.3 Reboot Your System

Just make sure that you are running latest kernel.


reboot

2.4 Install/Update dnf-plugin-system-upgrade package

It’s probably installed already.


dnf install dnf-plugin-system-upgrade --best

2.5 Start Upgrading Using DNF


dnf system-upgrade download --releasever=27

When this finish, check if there is any errors. You might need

--best

and

--allowerasing

options to get all packages downloaded.

2.6 Start (F26 to F27) Upgrade Process


dnf system-upgrade reboot

2.7 Grub 2 Menu Boot with Latest Kernel

Fedora Upgrade 27 from 26 grub2

2.8 Starting System Upgrade

Fedora Upgrade 27 from 26 Starting

2.9 dnf-plugin-system-upgrade Upgrading Fedora 26 to Fedora 27

Fedora Upgrade 27 From 26 Upgrading

Fedora Upgrade 27 From 26 Upgrading

Fedora Upgrade 27 From 26 Cleanup

3. Fedora 27 Screenshots

3.1 Fedora 27 GDM Login Screen

Fedora 27 GDM Login Window

3.2 Fedora 27 Plain Desktop Gnome Shell 3.26.1

Fedora 27 Gnome Shell 3.26.1 Plain

3.3 Fedora 27 and Gnome 3.26.1

Fedora 27 Gnome 3.26.1 Details

4. Fedora 27 Clean Up Post Upgrade (as root user)

4.1 Rebuilding the RPM DB


rpm --rebuilddb

4.2 Do Distro Sync


dnf distro-sync --setopt=deltarpm=0

4.3 Check All Your Config Files

Use rpmconf to find .rpmnew, .rpmsave and .rpmorig files. You can keep current version, place back old version, watch the diff or merge.


dnf install rpmconf rpmconf -a

Fedora 27 Workstation Install Guide

This is guide with screenshots, howto install Fedora 27 (F27) using Live DVD or Live USB. Fedora 27 Installation can be done also with using Fedora NetInstall (Net Install) with gPXE and BFO (boot.fedoraproject.org).

1. Before Fedora 27 Installation

1.1 Download Fedora 27 Live DVD/USB Image

Download Fedora 27 here.

Select your version, Fedora 27 Workstation, (Fedora 27 Server). On this guide I use Fedora 27 Workstation 64-bit.

1.2 Burn Fedora 27 Image to DVD, Create Live USB or use image directly and Boot Computer Using Fedora 27 Installation Media

Remember to check Fedora 27 image MD5 sum and then burn image to DVD, create Live USB example with liveusb-creator, dd or use directly on virtual environment. And boot computer using Fedora 27 Installation Media.

2. Fedora 27 Installation

2.1 Fedora 27 Boot Option Menu

Fedora 27 Boot Option Menu

2.2 Start Fedora 27 Installation Click Install to Hard Drive

Fedora 27 Install to Hard Drive

2.3 Select Language

Fedora 27 Select Language

2.4 Fedora 27 Workstation Installation Summary Window

Fedora 27 Workstation Installation Summary Window

2.5 Setup Date and Time

Fedora 27 Setup Date and Time

2.6 Setup Keyboard Layout

Fedora 27 Setup Keyboard Layout

2.7 Setup Network and Hostname

Fedora 27 Setup Network and Hostname

2.8 Select Installation Destination and Storage Configuration

Fedora 27 Select Installation Destination and Storage Configuration

2.9 Full Disk Summary and Bootloader Configuration

Fedora 27 Full Disk Summary and Bootloader Configuration

2.10 Modify Partitions Manually

Fedora 27 Manual Partitioning

Fedora 27 Manual Partitioning 2

2.11 Accept Changes

Fedora 27 Accept Changes

2.12 Begin Fedora 27 installation

Fedora 27 Begin Fedora 27 Installation

2.13 Package Installation and Setup

Fedora 27 Package Installation and Setup

2.14 Setup root Password

Fedora 27 Setup root Password

2.15 Create User Account

Select “Create User Account” and create user.
Fedora 27 Create User Account

2.16 Installing Software

Fedora 27 Installing Software

2.17 Fedora 27 Installation Done

Then simply reboot/restart computer and remove installation media
Fedora 27 Installation Done

Fedora 27 Restart 1

Fedora 27 Restart 2

3. Finishing Fedora 27 Installation

3.1 Fedora 27 Boot Menu (Grub 2)

Fedora 27 Grub2

3.2 Fedora 27 GDM Login Window

Fedora 27 GDM Login Window

3.3 Fedora 27 Gnome 3.26.1 Welcome Screen

Fedora 27 Gnome 3.26.1 Welcome Screen

3.4 Select Typing

Fedora 27 Select Typing

3.5 Privacy Settings

Fedora 27 Privacy Settings

3.6 Online Accounts

Fedora 27 Online Accounts

3.7 Ready to go / Start Using Gnome 3.26

Ready to go / Start Using Gnome 3.26

3.9 Fedora 27 Desktop Screenshots

Fedora 27 Gnome Shell 3.26.1 Plain

Fedora 27 Gnome Shell 3.26.1 Plain

Fedora 27 Gnome 3.26.1 Details

Fedora 27 Gnome 3.26.1 Details

What to do next?

Install nVidia Drivers on Fedora 27

Install Google Chrome on Fedora 27

Install LAMP (Linux, Apache, MySQL/MariaDB, PHP) on Fedora 27

Install LEMP (Linux, Nginx, MySQL/MariaDB, PHP) on Fedora 27

Install Adobe Flash Player 27 on Fedora 27

Install PostgreSQL 10.0 on Fedora 27

Install MariaDB 10.2 on Fedora 27

Install Memcached on Fedora 27

How to Install Piwik (Alternative to Google Analytics) in Linux

This tutorial will guide you on how to install Piwik open source analytics application in CentOS 7 and in Debian 9 and Ubuntu Server 16.04 LTS edition.

Piwik is a powerful self-hosted alternative to Google Analytics services that can be deployed on top of a LAMP stack in Linux.

With the help of Piwik Analytics platform, which uses a small JavaScript code that must be embedded into the targeted websites in between <head>...</head> html tags, you can track the number of websites visitors and create complex reports for the analyzed websites.

Requirements

  1. LAMP stack installed in CentOS 7
  2. LAMP stack installed in Ubuntu
  3. LAMP stack installed in Debian

Step 1: Initial Configurations for Piwik

1. Before starting to install and configure Piwik application, first log in to server terminal and issue the following commands in order to install unzip utility in your system.

# yum install unzip zip [On CentOS/RHEL]
# apt install zip unzip [On Debian/Ubuntu]


2. Piwik platform can be deployed on top of an existing LAMP stack in Linux systems. In addition to the standard PHP extensions installed in LAMP stack, you should also install the following PHP modues in your system by issuing the following command.

Install PHP Modules on CentOS and RHEL

# yum install epel-release
# yum install php-mbstring php-curl php-xml php-gd php-cli php-pear php-pecl-geoip php-pdo mod_geoip 

Install PHP Modules on Debian and Ubuntu

# apt install php7.0-mbstring php7.0-curl php7.0-gd php7.0-xml php7.0-opcache php7.0-cli libapache2-mod-geoip php-geoip php7.0-dev libgeoip-dev

3. You should also install GeoIP package, GeoIP Geo location and PECL extension in your system by issuing the below command.

Install GeoIP on CentOS and RHEL

# yum install GeoIP GeoIP-devel httpd-devel
# pecl install geoip 

Install GeoIP on Debian and Ubuntu

# apt install geoip-bin geoip-database geoip-database-extra
# pecl install geoip
# phpenmod geoip

4. After all required packages are installed into your system, next, issue the below command, depending on your Linux distribution, to open PHP configuration file and make change the following lines.

# vi /etc/php.ini [On CentOS/RHEL]
# nano /etc/php/7.0/apache2/php.ini [On Debian/Ubuntu]

Search and change the following PHP variables as illustrated in the below line samples:

allow_url_fopen = On
memory_limit = 64M
upload_max_file_size = 64M
date.timezone = Europe/Bucharest

Visit the official PHP time zone list in order to find the suitable timezone according to your server geographical location.

5. Next, append the following line to PHP geoip configuration file, as shown in the below file excerpt.

# vi /etc/php.d/geoip.ini [On CentOS/RHEL]
# nano /etc/php/7.0/apache2/conf.d/20-geoip.ini [On Debian/Ubuntu]

Add the following lines to file.

extension=geoip.so
geoip.custom_directory=/var/www/html/misc

Make sure you replace /var/www/html/ directory according to the path where you will install Piwik application.

6. Finally, restart Apache daemon to reflect changes by issuing the following command.

# systemctl restart httpd [On CentOS/RHEL]
# systemctl restart apache2 [On Debian/Ubuntu]

7. Now, create Piwik MySQL database. Log in to MySQL/MariaDB console and issue the following commands to create the database and the credentials required to access the database.

Replace the database name, user and password variables accordingly.

# mysql -u root -p
MariaDB [(none)]> create database piwik;
MariaDB [(none)]> grant all privileges on piwik.* to 'piwik' identified by 'yourpass';
MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit

Step 3: Install Piwik on CentOS, Debian and Ubuntu

8. To install Piwik web analytics platform in your system, first go to Piwik download page and grab the latest zip package by executing the following command.

# wget https://builds.piwik.org/piwik.zip 

9. Next, extract Piwik zip archive and copy the installation files located in piwik directory to /var/www/html/ directory by issuing the below commands.

Replace /var/www/html/ directory with your domain document root path, if that’s the case.

# unzip piwik.zip
# ls -al piwik/
# cp -rf piwik/* /var/www/html/

10. Before starting to install Piwik application via web interface, issue the following command in order to grant Apache HTTP server with write permissions to your domain document root path.

# chown -R apache:apache /var/www/html/ [On CentOS/RHEL] # chown -R apache:apache /var/www/html/ [On Debian/Ubuntu] 

List webroot path permission by executing ls command.

# ls -al /var/www/html/
List Piwik Files

List Piwik Files

11. Now, start to install Piwik application in your system by opening and browser and visiting your server IP address or domain name via HTTP protocol. On the first welcome screen hit on Next button to start installation procedure.

http://your_domain.tld/
Piwik Setup Wizard

Piwik Setup Wizard

12. In the next System Check screen, scroll down and verify if all system and PHP requirements to install Piwik application are satisfied. When you finish hit on Next button to continue the installation procedure.

Piwik System Check

Piwik System Check

13. In the next step, add Piwik database information required by the installation script to access MySQL server, such as database server address, Piwik database name and credentials. Use piwik_ table prefix, select PDO/MYSQL adapter and hit on Next button to create database tables, as illustrated in the below screenshot.

Piwik Database Settings

Piwik Database Settings

14. On the next step, add a Piwik super user admin name, type a strong password for super user admin and an email address and hit on Next button to continue the installation process.

Setup Piwik Admin User

Setup Piwik Admin User

15. Next, add a website domain URL to be tracked and analyzed with Piwik, the added website time zone and specify if the added website is an e-commerce site and click on Next button to continue.

Setup Website on Piwik

Setup Website on Piwik

16. In the next installation screen, the JavaScript tracking code that needs to be inserted to your tracked website will be displayed in your browser. Copy the code to a file and hit on Next button to finish the installation process.

Piwik Website Tracking Code

Piwik Website Tracking Code

17. Finally, after Piwik installation completes, a “Congratulations” screen will appear in your browser. Review the congratulations screen and click on Continue to Piwik button in order to be redirected to Piwik log in page.

Piwik Installation Completed

Piwik Installation Completed

18. Sign in to Piwik web application with the super admin account and password configured earlier, as illustrated in the below screenshot, and you should be redirected to Piwik dashboard, from where you can further start managing the application.

Piwik Admin Login

Piwik Admin Login

17. After logging in to Piwik web admin panel, skip the tracking code page and navigate to System -> Geolocation -> Location Provider and click on Get Started button from GeoIP Databases section in order to download and install the free GeoLiteCity database available for Piwik platform.

Download GeoIP Database for Piwik

Download GeoIP Database for Piwik

That’s all! You have successfully installed Piwik web analytics platform in your system. In order to add new websites to be tracked by the application, go to Websites -> Manage and use the Add a new website button.

After you’ve added a new website to be analyzed by Piwik, insert the JavaScript code to each page of the tracked website in order to start the tracking and analytics process.

How to Configure Custom Access and Error Log Formats in Nginx

Nginx HTTP server has a phenomenal logging facility which is highly customizable. In this article, we will explain how to configure you own formats for access and error logs for Nginx in Linux.

The aim of this guide is to help you understand how logs are generated, so as to configure custom log formats for purposes of debugging, troubleshooting or analysis of what unfolds within your web server as well as web applications (such as tracing requests).

Read Also: 4 Good Open Source Log Monitoring and Management Tools for Linux

This article is made of three sections which will enlighten you about configuring access/error logs and how to enable conditional logging in Nginx.

Configuring Access Logs in Nginx


Under Nginx, all client requests to the server are recored in the access log in a specified format using the ngx_http_log_module module.

The default log file is log/access.log (usually /var/log/nginx/access_log on Linux systems) and the default format for logging is normally the combined or main format (this can vary from one distro to another).

The access_log directive (applicable in the http, server, location, if in location and limit except context) is used to set the log file and the log_format directive (applicable under the http context only) is used to set the log format. The log format is described by common variables, and variables that generated only at the time when a log is written.

The syntax for configuring a log format is:

log_format format_name 'set_of_variables_to_define_format';

and the syntax for configuring access log is:

access_log /path/to/log_file format_name; #simplest form OR
access_log /path/to/log_file [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];

The following is a excerpt from the default Nginx configuration file /etc/nginx/nginx.conf on CentOS 7.

/etc/nginx/nginx.conf

http {
#main log format log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
}

This log format yields the following log entry.

127.0.0.1 - dbmanager [20/Nov/2017:18:52:17 +0000] "GET / HTTP/1.1" 401 188 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0"

The following is another useful logging format which we use for tracing requests to our web applications using the some of the default variables, it most importantly has the request ID and logs client location details (country, country code, region and city).

/etc/nginx/nginx.conf

log_format custom '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '"$http_x_forwarded_for" $request_id ' '$geoip_country_name $geoip_country_code ' '$geoip_region_name $geoip_city ';

You can use it like this:

access_log /var/log/nginx/access.log custom;

This will produce a log entry which appears like this.

153.78.107.192 - - [21/Nov/2017:08:45:45 +0000] "POST /ngx_pagespeed_beacon?url=https%3A%2F%2Fwww.example.com%2Fads%2Ffresh-oranges-1509260795 HTTP/2.0" 204 0 "https://www.suasell.com/ads/fresh-oranges-1509260795" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0" "-" a02b2dea9cf06344a25611c1d7ad72db Uganda UG Kampala Kampala 

You can specify several logs using the access_log directives on the same level, here we are using more than one log file in the http context.

/etc/nginx/nginx.conf

http{
##default log format
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
##request tracing using custom format
log_format custom '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '"$http_x_forwarded_for" $request_id ' '$geoip_country_name $geoip_country_code ' '$geoip_region_name $geoip_city ';
##this uses the default log format
access_log /var/log/nginx/access.log;
##this uses the our custom log format
access_log /var/log/nginx/custom_log custom;
}

The following are more advanced logging configurations examples, which are useful for log formats that contain compression-related variables and for creating compressed log files:

access_log /var/log/nginx/custom_log custom buffer 32k;
access_log /path/to/log.gz compression gzip flush=5m;

Configuring Error Logs in Nginx

In case Nginx experiences any glitches, it records information concerning them in the error log. These issues fall under different severity levels: debug, info, notice, warn, error (this is the default level and works globally), crit, alert, or emerg.

The default log file is log/error.log, but it is normally located in /var/log/nginx/ on Linux distributions. The error_log directive is used to specify the log file, and it can be used in the main, http, mail, stream, server, location context (in that order).

You should also note that:

  • Configurations in the main context are always inherited by lower levels in the order above.
  • and configurations in the lower levels override the configurations inherited from the higher levels.

You can configure error logging using the following syntax:

error_log /path/to/log_file log_level;

For example:

error_log /var/log/nginx/error_log warn; 

This will instruct Nginx to log all messages of type warn and more severe log level crit, alert, and emerg messages.

In the next example, messages of crit, alert, and emerg levels will be logged.

error_log /var/www/example1.com/log/error_log crit;

Consider the configuration below, here, we have defined error logging on different levels (in the http and server context). In case of an error, the message is written to only one error log, the one closest to the level where the error has appeared.

/etc/nginx/nginx.conf

http {
log_format compression '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" "$gzip_ratio"';
error_log /var/log/nginx/error_log crit;
server {
listen 80;
server_name example1.com;
#this logs errors messages for example1.com only
error_log /var/log/nginx/example1.error_log warn;
…...
}
server {
listen 80;
server_name example2.com;
#this logs errors messages for example2.com only
error_log /var/log/nginx/example1.error_log;
…….
}
}

If you use more than one error_log directives as in the configuration below (same level), the messages are written to all specified logs.

/etc/nginx/nginx.conf

server {
listen 80;
server_name example1.com;
error_log /var/www/example1.com/log/error_log warn;
error_log /var/log/nginx/example1.error_log crit;
…...
}

Configuring Conditional Logging in Nginx

In some cases, we may want Nginx to perform conditional logging of messages. Not every message has to be logged by Nginx, therefore we can ignore insignificant or less important log entries from our access logs for particular instances.

We can use the ngx_http_map_module module which creates variables whose values depend on values of other variables. The parameters inside a map block (which should exist in the http content only) specify a mapping between source and resulting values.

For this kind of setting, a request will not be logged if the condition evaluates to “0” or an empty string. This example excludes requests with HTTP status codes 2xx and 3xx.

/etc/nginx/nginx.conf

http{
map $status $condition {
~^[23] 0;
default 1;
}
server{
access_log /path/to/access.log custom if=$condition;
}
}

Here is another useful example for debugging a web application in a development phase. This will ignore all messages and only log debug information.

/etc/nginx/nginx.conf

 http{
map $info $debuggable { default 0; debug 1; } server{
……..
access_log /var/log/nginx/testapp_debug_access_log debug if=$debuggable; #logs other requests access_log /var/log/nginx/testapp_access.log main; …….
}
}

You can find out more information, including logging to syslog here.

That’s all for now! In this guide, we explained how to configure custom logging format for access and error logs in Nginx. Use the feedback form below to ask questions or share you thoughts about this article.

Support for HTTP/2 and Virtuozzo 7

The latest version of cPanel is not only loaded with new features but we’ve also made some tiny updates under the hood. In cPanel & WHM 68 we now offer support for both Virtuozzo 7 and HTTP/2! These enhancements will allow you to enjoy the same hosting platform you love, but with more operating power and efficiency than ever before.

HTTP/2 Support

The new application protocol for data communication on the world wide web has become the standard among most major web browsers. In this latest version of cPanel & WHM, we’ve made all of the efforts to ensure EasyApache 4 is fully capable of utilizing the speed that HTTP/2 has to offer. After months of testing EasyApache 4 on the latest OpenSSL, we’re happy to announce that we’re fully supported. This update, which will make page load times faster and more responsive, will also be particularly helpful for mobile connections.

Check out this nifty tool created by some of our techs and explore the differences between HTTP and HTTPS (powered by HTTP/2).

Virtuozzo 7 Support

Last year, the leading virtualization platform Virtuozzo upped the ante on their offering to hosting providers using cPanel & WHM with the release of Virtuozzo 7. Virtuozzo 7 provided greater server density than ever and allowed hosting providers to run more instances of cPanel per physical server.

Since this release, our team has spent further time testing and exploring the integration between cPanel & WHM and Virtuozzo. We’ve combed through every instance where there is a compatibility opportunity between our products, fixed a handful of bugs, and are happy to announce that Virtuozzo 7  has been added to the list of cPanel & WHM’s fully supported platforms.


Have suggestions and tips for our team? Head over to over Feature Request site and drop us a line

How to Install WordPress with FAMP Stack in FreeBSD

In this tutorial we’ll learn how to install WordPress in FAMP stack in FreeBSD. FAMP stack is an acronym that stands for FreeBSD Unix operating system, Apache HTTP server (a popular popular open-source web server), MariaDB relational database management system ( MySQL database fork currently maintained by community), and PHP dynamic programming language which runs in server-side.

WordPress is the most famous CMS framework in the world that is used for building simple blogs or professional websites.

Requirements

  1. FreeBSD Installation Guide

Step 1: Install FAMP Stack in FreeBSD

1. In order to deploy a WordPress website at your premises, you need to assure that the following FAMP components are installed and operational in FreeBSD.

The first service you need to install in FreeBSD is Apache HTTP server. To install Apache 2.4 HTTP server binary package via official FreeBSD ports repositories, issue the following command in your server console.

# pkg install apache24


2. Next, enable and start the Apache HTTP daemon in FreeBSD by executing the following commands.

# sysrc apache24_enable="yes"
# service apache24 start

3. Open a browser and navigate to your server’s IP address or FQDN via HTTP protocol to view Apache default web page. ‘It works!’ message should be displayed in your browser.

http://yourdomain.tld

4. Next, install PHP 7.1 version in your server with the below required extension by issuing the below command. Our WordPress website will be deployed in top of this PHP version.

# pkg install php71 php71-mysqli mod_php71 php71-mbstring php71-gd php71-json php71-mcrypt php71-zlib php71-curl

5. On the next step, create the php.conf configuration file for Apache web server with the following content.

# nano /usr/local/etc/apache24/Includes/php.conf

Add following configuration to php.conf file.

<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>

6. Save and close this file and restart Apache daemon in order to apply the changes by issuing the below command.

# service apache24 restart

7. The final component missing is MariaDB database. To install the latest version of MariaDB database server in FreeBSD execute by the following command.

# pkg install mariadb102-client mariadb102-server

8. Next, make enable MariaDB service in FreeBSD and start database daemon by running the below commands.

# sysrc mysql_enable="YES"
# service mysql-server start

9. On the next step, execute mysql_secure_installation script in order to secure MariaDB. Use the below script output sample in order to secure MariaDB database.

# /usr/local/bin/mysql_secure_installation
Sample Output
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

10. Finally, create a WordPress installation database in MariaDB server. To create the database, log in to MariaDB console and issue the following commands.

Choose a descriptive name for this database, create a database user and password to manage this database.

# mysql -u root -p
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> grant all privileges on wordpress.* to 'user_wordpress'@'localhost' identified by 'password';
MariaDB [(none)]> flush privileges;

Step 2: Install WordPress in FreeBSD

11. To install the latest version of WordPress in FreeBSD, go to WordPress download page and grab the latest available traball version with the help of the wget utility.

Extract the tarball and copy all WordPress installation files to Apache document root by issuing the following commands.

# wget https://wordpress.org/latest.tar.gz
# tar xfz latest.tar.gz
# cp -rf wordpress/* /usr/local/www/apache24/data/

12. Next, grant Apache www group write permissions to WordPress installation directory by issuing the below commands.

# chown -R root:www /usr/local/www/apache24/data/
# chmod -R 775 root:www /usr/local/www/apache24/data/

13. Now, start to install WordPress. Open a browser and navigate to your server IP address or domain name via HTTP protocol. In the first screen, hit on Let’s go! button to start the installation process.

Install WordPress in FreeBSD

Install WordPress in FreeBSD

14. Next, add MySQL database name, user and password and hit on Submit button to continue, as illustrated in the below screenshot.

WordPress Database Settings

WordPress Database Settings

15. On the next screen, WordPress installer will inform you that it can successfully connect to MySQL database. Hit on Run the install button to install database schema.

WordPress Installation

WordPress Installation

16. In the next screen, choose your site title and a username with a strong password to manage WordPress site. Also, add your e-mail address and hit on Install WordPress button to finish the installation process.

WordPress Website Settings

WordPress Website Settings

17. When the installation process completes, a message will inform you that WordPress CMS has been successfully installed. On this page you will also find the credentials needed to log in to your website admin panel, as illustrated in the below image.

WordPress Login Details

WordPress Login Details

18. Finally, log in to WordPress admin dashboard using the credentials presented in the previous step and you can now start to add new posts for your website.

WordPress Dashboard

WordPress Dashboard

19. In order to visit your website frontend page, navigate to your server IP address or domain name where you will see a default post named “Hello World!”, as illustrated in the below image.

http://yourdomain.tld

Congratulations! You’ve successfully installed WordPress content management system under FAMP stack in FreeBSD.

InsecRes – A Tool to Find Insecure Resources on HTTPS Sites

After switching your site to HTTPS, you probably want to test if resources such as images, slides, embedded videos and others, are correctly pointed to HTTPS protocol or displaying warnings about the insecure content on the pages. After some research I found a useful tool for this purpose, called insecuRes.

InsecuRes is a small, free and open source command line based tool for finding insecure resources on HTTPS sites, written in Go programming language. It utilizes the power of “multi-threading” (goroutines) to crawl and parse site pages.

Read Also: How to Redirect HTTP to HTTPS on Apache

It crawls all your website pages in parallel, scans and catches: IMG, IFRAME, OBJECT, AUDIO, VIDEO, SOURCE and TRACK resources with full HTTP (insecure) urls. To prevent blacklisting by web server, it employs a random delay between requests. Additionally, you can redirect its output to a CSV file for later analysis.

Requirements

  1. Install Go Programming Language in Linux

Install InsecuRes in Linux Systems


Once Go Programming Language installed on the system, run the command below on the terminal to get insecres.

$ go get github.com/kkomelin/insecres

Once you have downloaded and installed insecres, run the command below to scan your site for insecure resources. If it shows no output, that probably means there are no insecure resources on your site.

$ $GOPATH/bin/insecres https://example.com

To save the output in a CSV file for later examination, use the -f flag.

$ $GOPATH/bin/insecres -f="/path/to/scan_report.csv" https://example.com

Display usage guide.

$ $GOPATH/bin/insecres -h

Some of the features to be added include displayiny result counters and comparing performance of simple regex parsing and tokenized parsing.

InsecRes Github repository: https://github.com/kkomelin/insecres

In this article, we showed you how to find insecure resources on HTTPS sites, using a simple command line tool called insecres. You can ask questions or share your thoughts via the comment section below. If you know of any similar tools out there, do share information about them as well.