WebDock is a cloud-based WordPress hosting service that allows you to create multiple websites on one server.
The nginx multiple websites on same port is a tutorial that will teach you how to setup multiple WordPress sites with LEMP on WebDock.
WordPress is a popular content management system (CMS) that lets users build blogs, e-commerce sites, portfolios, news sites, and headless servers, among other things. A web server (Apache, Nginx, LiteSpeed), a database (MariaDB, MySQL), and PHP are all required by WordPress.
We’ll use WebDock to install several WordPress sites in this tutorial. WebDock is a fast and affordable VPS provider that offers semi-managed and unmanaged VPS servers to suit everyone’s needs. WebDock offers a management panel via which you may administer your VPS servers, such as installing LEMP stack, WordPress, phpMyAdmin, MonogDB, CertBot, FTP, and other applications. As a result, I labeled it as semi-managed. However, their control interface does not allow multiple WordPress installations, and they recommend that each server only have one site. This is why we created a guide on how to build several WordPress sites using LEMP on a single VPS server.
Construct a Server
Create a new server and instead of The Perfect Server, choose Clean OS. We should maintain our server ourselves to prevent inadvertent modifications from the WebDock management panel since WebDock does not allow numerous sites on a single server. And if you want to have several sites or web applications on your VPS, I suggest doing it this way. A web server can also operate on 512 MB of RAM, however for numerous WordPress sites, I suggest at least 2 GB of RAM.
choose a clean operating system
For the time being, WebDock only supports Ubuntu, therefore we’ll use Ubuntu Focal 20.4 as our server. Give your server a name and a slug, then start it up.
Congratulations, your server is up and running, and you’re ready to launch our website.
Setup SSH
Click Add Shell User at the bottom of the dashboard, then enter your login and password and hit ADD USER. You don’t need to alter any additional settings, and you shouldn’t unless you’re sure what you’re doing.
After adding a user to your server, you must login to make changes, and in order to do so, you must first create an SSH key. SSH is created locally, and a copy of the public key is sent to the server so that it knows who is attempting to connect.
SSH Key Generator
Use ssh-keygen in a terminal on your local computer to generate an SSH key.
ssh-keygen ssh-keygen ssh-keygen ssh-key Creating an rsa key pair using a public/private key pair. Save the key to the following file (/home/user/.ssh/id rsa):
Shell Session is a programming language (shell)
If you already have an SSH key, you will get an overwrite notice and will not need to generate a new one. Then it will prompt you for a password. It is suggested that you add a pass.
ssh-keygen ssh-keygen ssh-keygen ssh-key Creating an rsa key pair using a public/private key pair. Save the key to the following file (/home/user/.ssh/id rsa): Enter your password (or leave it blank if you don’t have one): Re-enter the same password: /home/user/.ssh/id rsa contains your identity. /home/user/.ssh/id rsa.pub contains your public key. The most important fingerprint is: user@myPc SHA256:6H5M8HkmTD1BPkPCA67a8CdWR7KKx8b4kN6fTMndQhQ SHA256:6H5M8HkmTD1BPkPCA67a8CdWR7KKx8b4kN6fTMndQhQ SHA256:6H5M8HkmTD The randomart picture for the key is: +—-[RSA 3072] [RSA 3072] [RSA 3072] [RSA 3072 ——+ |.oE.o | |. o=. | | o oo+. | |… oo | |.. +=S.. | | @ = =.o | | * @ *oo+. | | +——[SHA256] ——-+
Shell Session is a programming language (shell)
After you’ve finished creating an SSH key, this is what you’ll see.
Copies of the Public Key
We can obtain the public key using cat since our key is stored in /.ssh/id rsa.pub.
/.ssh/id rsa.pub /.ssh/id rsa.pub /.ssh/id rsa.pub /
Shell Session is a programming language (shell)
It will produce the following outcome:
ssh-rsa $ cat /.ssh/id rsa.pub AAAAB3NzaC1yc2EAAAADAQABAAABgQC7DFwx4hgyBKvhqd5ss56YIhU2PMgO1NEQ4Kln8dnHit6eLF4HKzCPfsIhkeWUGu4VdqS4Zg+U04Xvx/TG1z3N9klnvV7pHeZaxGciUT8+Ii6YUWosBUX/Ki8ZfC+QgmzkGmQwIefXzxOMijqa1j7CJH8JFigQYCw9B6LIwNhageQjPyPy68ido/XDuqI1xtbr/aJcuYxE2IHVzsNzMAoJlNEVjrhwTp0y78bWW2RodftPPNT670MwrFfiP+iqck1zQ/n+VwB9wW67cFlE/HX6Invc13i/psjn6UJcpKEDW3tHvvpX6Y/Nik79dSSTAX9lAAuOKwe3VJ6YQBSPpE0JInVE0veO+xEJkTnXz+kUWgQQT+PxfHSIE63v0mIAiPTW3WnFkZkjW23BZX+2Tty6xPyHuXJGtaiyyaZ+F4/A51jZ3yXR2G7pLOy9PdeDl1j3Doy466UX86p0z pPEG5KpRuis/JMve5vvPQBwppoBHCQTdkb2ApvA2XL3vtxoMyk= user@myPc pPEG5KpRuis/JMve5vvPQBwppoBHCQTdkb2ApvA2XL3vtxoMyk= user@myPc
Shell Session is a programming language (shell)
Save all of the output material to WebDock.
Then give the user the key.
SSH login to the server
The IP address of the server may be seen in the servers list.
ssh [email protected] $ ssh [email protected]
Shell Session is a programming language (shell)
LEMP Stack should be installed
L: We’ve already set up Linux.
Nginx should be installed (pronounce as Engine-X)
$ sudo apt update admin@webdocktutor $ sudo apt install nginx admin@webdocktutor
Shell Session is a programming language (shell)
Go to http://your ip address, which is http://45.148.30.37 for me. The nginx Welcome page is shown. This indicates that nginx is properly installed.
MariaDB should be installed
For the database used by WordPress, MariaDB or MySQL may be installed.
$ sudo apt install mariadb-server admin@webdocktutor
Shell Session is a programming language (shell)
We’ll need to set up MariaDB for the first time after installing it.
$ sudo mysql secure installation admin@webdocktutor
Shell Session is a programming language (shell)
Make a new root password and choose yes for the rest of the choices.
For the WordPress site, create a new user and database. To use mariadb, you must first log in.
$ sudo mariadb admin@webdocktutor
Shell Session is a programming language (shell)
Create two users for the two WordPress installations: wordpress1 and wordpress2. You don’t need to create a wordpress2 account if you don’t wish to install two WordPress sites. You are free to use your own names and are not required to use the identical wordpress name. Remember to include the ; after the sql command. If you omitted the ; and hit enter, the MySQL shell will switch to a new line. You may continue by typing forgotten; and pressing enter again.
CREATE DATABASE wordpress1; MariaDB [(none)]> CREATE DATABASE wordpress1; MariaDB [(none)]> CREATE DATABASE wordpress1; MariaDB [(none)]> CREATE DATABASE wordpress1;
Shell Session is a programming language (shell)
The SHOW DATABASES command may be used to examine freshly established databases.
SHOW DATABASES; MariaDB [(none)]>
Shell Session is a programming language (shell)
For the wordpress1 and wordpress2 databases, create new users.
GRANT ALL ON wordpress1.* TO ‘wordpress1user’@’localhost’ IDENTIFIED BY ‘password1’ WITH GRANT OPTION; MariaDB [(none)]> GRANT ALL ON wordpress1.* TO ‘wordpress1user’@’localhost’ IDENTIFIED BY ‘password1’ WITH GRANT OPTION;
Shell Session is a programming language (shell)
GRANT ALL ON wordpress2.* TO ‘wordpress2user’@’localhost’ IDENTIFIED BY ‘password2’ WITH GRANT OPTION; MariaDB [(none)]> GRANT ALL ON wordpress2.* TO ‘wordpress2user’@’localhost’ IDENTIFIED BY ‘password2’ WITH GRANT OPTION;
Shell Session is a programming language (shell)
We established two accounts, wordpress1user and wordpress2user, with full access to their respective databases wordpress1 and wordpress2. You may always choose your own users and database. For example, instead of creating wordpress2user, you may grant wordpress1user access to both databases. We did, however, establish users for each database for security reasons.
Keep a secure location for the root password, usernames, and passwords. We’ll need it subsequently and perhaps in the future.
To verify that privileges are accessible in the current session, flush them.
FLUSH PRIVILEGES; MariaDB [(none)]>
Shell Session is a programming language (shell)
[(none)]> MariaDB exit;
Shell Session is a programming language (shell)
Re-login to MariaDB and check to see if any databases are accessible. They should show up.
$ sudo mariadb admin@webdocktutor
Shell Session is a programming language (shell)
SHOW DATABASES; MariaDB [(none)]>
Shell Session is a programming language (shell)
Show databases in MariaDB [(none)]> +——————————+ +—————————————————————————————————————————————— | information schema | | mysql | | performance schema | | wordpress1 | | wordpress2 | wordpress3 | wordpress4 | wordpress5 | wordpress6 | wordpress7 | wordpress8 | wordpress9 | wordpress10 | wordpress11 | +——————————+ There are 5 rows in this set (0.001 sec)
Shell Session is a programming language (shell)
The sql command does not have to be written in all capital characters. to leave;
[(none)]> MariaDB exit;
Shell Session is a programming language (shell)
PHP should be installed
PHP is processed by Nginx using php-fpm. php-fpm and php-mysql must be installed:
$ sudo apt install php-fpm php-mysql admin@webdocktutor
Shell Session is a programming language (shell)
As a result, the LEMP stack has been deployed. We must now configure nginx to execute PHP. It does not execute PHP by default.
NGINX should be configured to utilize PHP-FPM
There are server blocks in the nginx config file that specify web servers. To function, these server blocks need a domain name. WebDock assigns each server a subdomain, which in my instance is webdocktutor.vps.webdock.io. Yours may be found in the alias section on the server overview page.
All web files are stored in /var/www/, which includes the html folder, which we can view by visiting our IP address at http://ip-address.
I’m going to assume that we have domain names like mycoolsite.com and mycoolblog.com for this lesson. As a result, all future setup will be based on these two domain names.
Create two folders with the same names as our domain names, which are mycoolsite.com and mycoolblog.com, for our two WordPress sites. So /var/www/mycoolsite.com/ and /var/www/mycoolblog.com/ are our new directories. We’ll put WordPress files in those folders and configure nginx to serve them.
Set up the NGINX configuration file for numerous sites
Nginx stores all configuration in /etc/nginx/nginx.conf, however since we’re on Ubuntu, we may find server config files in a different folder that corresponds to the Apache config folders. All available sites/servers config files are usually stored in /etc/nginx/sites-available/, and a symbolic link to those sites must be added to /etc/nginx/sites-enabled/ to activate them.
A file called default may be found in /etc/nginx/sites-available/, and it is responsible for serving pages in /var/www/html/. So, how do we get our WordPress blogs up and running? So, we’ll delete the default symbolic link from /etc/nginx/sites-enabled/, write our own config file, and then link it.
To disable the default site, go to:
$ sudo rm /etc/nginx/sites-enabled/default admin@webdocktutor
Shell Session is a programming language (shell)
This will delete the symbolic link but not the real config file inside /etc/nginx/sites-available/, which is the correct way to go.
To get WordPress (PHP) to function, build a new config file like follows:
$ sudo nano /etc/nginx/snippets/wordpress.conf admin@webdocktutor
Shell Session is a programming language (shell)
Also, add the following to your wordpress.conf file:
index.php; / / / / / / / / / $uri $uri/ /index.php?$args; try files $uri $uri/ /index.php?$args; location.php $ include fastcgi params; fastcgi pass unix:/var/run/php/php7.4-fpm.sock; fastcgi intercept errors on; fastcgi params on; fastcgi params on; fastcgi params on; fastcgi params on; fastcgi params on; fastcgi params on; fastcg SCRIPT FILENAME $document root ‘$fastcgi script name’; ‘$fastcgi script name’; ‘$fastc /favicon.ico is the location of the icon. log not found; access log; log not found; log not found; log not found; log not found; log not found /robots.txt is the location of the robots.txt file. allow all; log not found off; access log off; try files $uri $uri/ /index.php?$args; *.(xml|xsl) location $ try files $uri $uri/ /index.php?$args; log not found off; access log off; log not found off; log not found off; log not found off; log not found off; log not found off; log not found off; log not found *.(js|css|png|jpg|jpeg|gif|ico) location $ log not found off; expires max; location /. reject everything; /(?:uploads|files) /(?:uploads|files) /(?:uploads|files) /(?: /.*.php $ deny everything;
Nginx is the programming language (nginx)
You may need to check the location.php$ block, since it may vary depending on your configuration. It’s for php7.4 because it’s for php7.4.
We must now build a virtual host and utilize the aforementioned configuration. Build config files in the sites-available folder to create virtual hosts for our two domain names.
$ sudo nano /etc/nginx/sites-available/mycoolsite.com admin@webdocktutor
Shell Session is a programming language (shell)
Then paste the following configuration:
listen 80; listen [::]:80; include snippets/wordpress/wordpress.conf; server root /var/www/mycoolsite.com; server name mycoolsite.com;
Nginx is the programming language (nginx)
Similarly, here’s an example of a domain name:
$ sudo nano /etc/nginx/sites-available/mycoolblog.com admin@webdocktutor
Shell Session is a programming language (shell)
listen 80; listen [::]:80; include snippets/wordpress/wordpress.conf; server root /var/www/mycoolblog.com; server name mycoolblog.com;
Nginx is the programming language (nginx)
As a result, when you visit certain sites, it will attempt to deliver information from the root directory. We haven’t put anything in those folders yet, so if you go to your domains now, you’ll receive a 404 not found message.
It’s now time to set up WordPress. Download WordPress from the /tmp location.
wget https://wordpress.org/latest.tar.gz cd /tmp
Shell Session is a programming language (shell)
Extract the files as follows:
latest.tar.gz tar -zxvf
Shell Session is a programming language (shell)
Change the permissions on the files to www-data user/group so we don’t receive any permission errors while using WordPress.
sudo chown -R www-data:www-data wordpress wordpress wordpress wordpress wordpress wordpress wordpress wordpress wordpress wordpress wordpress wordpress wordpress
Shell Session is a programming language (shell)
COPY FILES TO /VAR/WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
sudo cp -a wordpress/. /var/www/mycoolsite.com/ sudo cp -a wordpress/. /var/www/mycoolblog.com/ sudo cp -a wordpress/. /var/www/mycoolblog.com/ sudo cp -a wordpress/.
Shell Session is a programming language (shell)
Make a symlink between sites-available and sites-enabled.
sudo ln -s /etc/nginx/sites-available/mycoolblog.com/etc/nginx/sites-enabled/ sudo ln -s /etc/nginx/sites-available/mycoolsite.com/etc/nginx/sites-enabled/ sudo ln -s /etc/nginx/sites-available/mycoolsite.com/etc/nginx/
Shell Session is a programming language (shell)
Examine the nginx configuration:
nginx -t sudo
Shell Session is a programming language (shell)
Reload nginx if everything is fine:
nginx -s reload sudo
Shell Session is a programming language (shell)
Now go to those domains/urls, mycoolblog.com and mycoolsite.com, and you’ll see the WordPress installation page. Provide the required information, such as the database name, username, and password that we previously established.
I hope you find this article to be beneficial.
WebDock allows you to setup multiple WordPress sites on one server. This is a great way to scale your website and make it easier for users to find.