habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

ISPConfig Ubuntu 18.04 Nginx MySQL

5 min read

In this blog post, I will show you how to install and configure ISPConfig Ubuntu 18 with Nginx web server. ISPConfig is a powerful and flexible web hosting control panel that allows you to manage multiple servers and services through a web interface.

ISPConfig supports Nginx as an alternative web server to Apache. Nginx is a fast and lightweight web server that can handle high traffic and concurrency. Nginx can also act as a reverse proxy, load balancer, and cache server. In this tutorial, we will use Nginx as the main web server for ISPConfig.

But in this case,I did not install all the components of the ISPconfig service package. Only Web server, PHP, PHP-fpm, database, and phpmyadmin that I installed. No DNS, Mail, FTP, Postfix, Dovecot, Pure-FTPD. Here’s the package I’m going to install.

Web server: Nginx + php-fpm
Php version: php 7.4
Database: Percona Server Mysql 5.6
Database Management: PhpMyadmin
Remote: SSH

Why I am use percona server 5.6? Because special requirement from application laravel that need running under mysql server 5.6.

Before we start, we need to have a basic Ubuntu 18.04 server installation with a static IP address and a hostname. I assume that ubuntu 18.04 is ready to use. do not start install from scratch.

The installation and configuration of ISPConfig on Ubuntu 18.04 with Nginx web server consists of the following steps:

  1. Update your system and install some required packages
  2. Install and configure Percona Server 5.6 database server From repository.
  3. Install and configure Nginx web server
  4. Install and configure PHP and PHP-FPM
  5. Install and configure PhpMyadmin
  6. Install and configure Let’s Encrypt SSL and ISPConfig control panel

Let’s begin!

Step 1: Update your system and install some required packages

The first step is to update your system and install some required packages for ISPConfig. Run the following commands as root or with sudo:

apt update && apt upgrade -y
apt install nano wget curl unzip bzip2 gnupg2 software-properties-common

Change the Default Shell

/bin/sh is a symlink to /bin/dash, however we need /bin/bash, not /bin/dash. For that goal we do this:

dpkg-reconfigure dash

Use dash as the default system shell (/bin/sh)? <– No

If you don’t do this, the ISPConfig not continue install.

Disable AppArmor

AppArmor is a security extension (similar to SELinux) that should provide extended security. Sometimes, some services not running properly. I decided to disable.

sudo systemctl stop apparmor.service
sudo systemctl disable apparmor.service

Setting Date and Hostname

timedatectl 
hostnamectl set-hostname ispconfig.habibza.in

in /etc/hosts, set also.

root@ispconfig:~# vim /etc/hosts
#list /etc/hosts

127.0.0.1 localhost
10.148.0.5      ispconfig.habibza.in ispconfig
34.143.156.166  ispconfig.habibza.in ispconfig

Step 2: Install and configure Percona Server.

The next step is to install and configure Percona Server 5.6. MariaDB is a fork of MySQL that provides better performance and features. ISPConfig uses Percona Server to store its configuration data and also allows you to create and manage databases for your websites.

Installing Percona Server for MySQL from Percona apt repository

To install Percona Server, run the following step below:

1. Install GnuPG, the GNU Privacy Guard:

$ sudo apt-get install gnupg2

2. Fetch the repository packages from Percona web:

$ wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb

3. Install the downloaded package with dpkg.

To do that, run the following commands as root or with sudo:

$ sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb

Once you install this package the Percona repositories should be added. You can check the repository setup in the /etc/apt/sources.list.d/percona-release.list file.

4. Update the local cache:

$ sudo apt-get update

5. After that you can install the server package:

$ sudo apt-get install percona-server-server-5.6

After finished install, check status server.

systemctl status mysql.service

 mysql.service - LSB: Start and stop the mysql (Percona Server) daemon
   Loaded: loaded (/etc/init.d/mysql; generated)
   Active: active (running) since Wed 2023-03-29 16:21:45 WIB; 1 day 18h ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 30 (limit: 4915)
   CGroup: /system.slice/mysql.service
           ├─1396 /bin/sh /usr/bin/mysqld_safe
           └─1637 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql ...

To secure your Percona Server installation, run the following command:

mysql_secure_installation

You will be asked to set a root password for MySql and answer some questions to remove some insecure defaults. You can follow these recommendations:

Enter current password for root (enter for none): Press Enter
Set root password? [Y/n]: Y
New password: Enter a strong password
Re-enter new password: Repeat the password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

To test if Percona Server is working, run the following command:

habibza@ispconfig-server:~$ mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9904
Server version: 5.6.51-91.0 Percona Server (GPL), Release 91.0, Revision b59139e
Copyright (c) 2009-2021 Percona LLC and/or its affiliates
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

Type “quit;” to or ctrl + d exit.

Step 3: Install and configure Nginx

Nginx is available as a package for Ubuntu. Install with the following command:

sudo apt-get install nginx

Start nginx afterwards:

systemctl start nginx.service

Step 4: Install and configure PHP and PHP-FPM

The next step is to install and configure PHP and PHP-FPM. PHP is a popular scripting language for web development that can run on Nginx with PHP-FPM (FastCGI Process Manager). PHP-FPM is a daemon that manages multiple PHP processes and handles requests from Nginx.

I will use version php7.4. To install PHP 74 and PHP-FPM, run the following command:

Install PHP and Modul

apt -y install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update
apt -y install php7.4 php7.4-common php7.4-gd php7.4-mbstring php7.4-mcrypt php7.4-memcache php7.4-mysql php7.4-cli php7.4-cgi php7.4-curl php7.4-intl php7.4-zip php7.4-soap php7.4-imagick php7.4-dev php7.4-xml php7.4-xmlrpc

Install PHP-FPM.74

PHP 7 work in nginx through PHP-FPM (PHP-FPM FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. Which we install as follows:

apt-get -y install php7.4-fpm

And then check fpm start or not.

root@server2:~# systemctl status php7.4-fpm.service

 php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2023-03-29 16:21:44 WIB; 1 day 18h ago

Next open /etc/php/7.4/fpm/php.ini.

nano /etc/php/7.4/fpm/php.ini

and set cgi.fix_pathinfo=0 and your timezone:

[...]
cgi.fix_pathinfo=0
[...]
date.timezone="Asia/Jakarta"
[...]

Next reload PHP-FPM:

service php7.2-fpm reload

Step 5: Install and configure PhpMyadmin

Install phpMyAdmin as follows:

add-apt-repository ppa:phpmyadmin/ppa
apt update
apt-get -y install phpmyadmin php7.4-mbstring php7.4-gettext

You will see the following questions:

Web server to reconfigure automatically: <-- select none (because only apache2 and lighttpd are available as options)
MySQL application password for phpmyadmin: <-- Press Enter
phpmyadmin skip select web server
Select NONE, then Ok.

Folder phpMyAdmin in the /usr/share/phpmyadmin/ directory. After you have installed ISPConfig 3, we can access phpMyAdmin as follows:

The ISPConfig apps vhost on port 8081 for nginx comes with a phpMyAdmin configuration, so access in url like below:

http://server1.example.com:8081/phpmyadmin 
or
http://server1.example.com:8081/phpMyAdmin

If we use both http and https for your vhost, you need to add the following section to the http {} section in /etc/nginx/nginx.conf (before any include lines) which determines if the visitor uses http or https and sets the $fastcgi_https variable (which we will use in our phpMyAdmin configuration) accordingly:

nano /etc/nginx/nginx.conf
[...]
http {
[...]
        ## Detect when HTTPS is used
        map $scheme $fastcgi_https {
          default off;
          https on;
        }
[...]
}
[...]

reload nginx afterwards:

service nginx reload

Step 6: Install and configure Let’s Encrypt SSL and ISPConfig control panel.

Install Let’s Encrypt

ISPConfig 3.x has built-in support for the free SSL Certificate Authority Let’s encrypt. The Let’s Encrypt function create free SSL Certificates for your website in ISPConfig.

Now make ISP Config support for Let’s encrypt.

apt-get -y install certbot python3-certbot-nginx

Install ISPConfig 3.x

To install ISPConfig 3.x from GIT stable branch, do this:

cd /tmp
wget -O ispconfig.tar.gz https://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ispconfig.tar.gz
cd ispconfig3*/install/

The next step is to run

php -q install.php

Follow the wizard, and after installation finished we can access via browser like this.

https://our-hostname:8080

There is ISPConfig Ubuntu 18 with nginx, please feel free for comment. Might be usefull.

Troubleshoot

By default, ubuntu 18 came with php7.2. But in my case, i am install php7.4. There is an adjustment by manually changing the virtual host and php-fpm pool per host.
In this case it is the ispconfig and phpmyadmin hosts. So that it can be opened from a browser.

Please see our video for details.

habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox