In the following example we will show some common customizations during the web server setup using Webinoly so that you can use it as a guide to learn in a practical way the use of some commands.
We will start installing Webinoly with the option “0”, this means that only Webinoly will be installed, but no extra package will be installed on the server.
wget -qO weby qrok.es/wy && sudo bash weby 0
Next we will modify some values prior to the installation of the packages.
sudo webinoly -conf-value_max-mb-uploads=200
sudo webinoly -conf-value_nginx-ppa=mainline
sudo webinoly -timezone=America/Mexico_City
We define a maximum size in PHP to upload files of 200Mb, also we will install the “mainline” branch of Nginx and set the time zone of your preference.
Now we are ready to install and configure all the necessary packages on the server. We use the “lemp” option for an installation, configuration and full optimization of Nginx, PHP and MariaDB (MySQL).
sudo stack -lemp
WordPress Multisite with Domain Mapping
Once all the necessary packages are installed, we can create the websites that we are going to host on the server. In this example we are going to create a WordPress site in Multisite configuration with subdirectories.
sudo site mymainsite.com -wpsubdir -cache=on
sudo site mymainsite.com -ssl=on
We have enabled the FastCGI cache for our site and we also created an SSL certificate to serve the content with HTTPS, as well as installing the necessary plugins to manage FastCGI and Redis cache directly from WordPress.
It is worth mentioning that Webinoly has made all the configurations in the server automatically and we are ready to visit the new site from your browser.
Webinoly protects WordPress admin or login pages with a basic HTTP authentication as an additional layer of security, so we must create a user.
sudo httpauth -add
Although it is not recommended, it is worth mentioning that you can disable HTTP authentication using the command
sudo httpauth -wp-admin=off.
Once we have visited our site from the browser we must perform the initial configuration of the WordPress installation.
Once we have logged in we must go to the menu “Tools> Network Configuration” to confirm the “subdirectory” Multisite installation and then add some lines in
wp-config.phpfile that in this case Webinoly has already added them automatically, you just have to edit the file to remove the comments “#”.
To have SFTP access to the server it is necessary to enable it using the following command, in order to be able to upload or modify files using “FileZilla” or any tool of your preference.
sudo webinoly -login-www-data=on
At this point we have created the main site and can upload files, new themes or plugins to customize WordPress or make changes and create content from the admin area that we have already had access.
For being a “multisite” installation, we can also create new sites and since we have chosen the “subdirectory” configuration, any new site will have the following form:
https://mymainsite.com/newsite which we can manage completely independently.
One of the current features of WordPress that I personally like the most is that it is no longer necessary to use a plugin for “Domain Mapping” and this is now a native WP function. What do I mean by this? It’s now possible to use a separate domain for each subsite of your multisite installation, that is, instead of using a subdirectory or a subdomain, you can use a new domain and in this way you can manage several completely different and independent websites from the same WordPress installation.
I recommend you read the official documentation “WordPress Multisite Domain Mapping” and with a couple of steps you will have configured your subsite to use an independent domain.
In the following example we consider that you have already created a new site from WordPress Multisite and you have configured it to use a new domain, in this case
anothersite.com, now you have to setup your server using Webinoly from the command line to host the new domain so that the server is able to respond to the requests of this new site and likewise create an SSL certificate for the new domain.
sudo site anothersite.com -parked=mymainsite.com
sudo site anothersite.com -ssl=on -root=mymainsite.com
We have already created two independent sites using two different domains and managed from the same WordPress installation. Now we will begin to configure some aspects of the server.
We all know the standard of using the subdomain www for some sites, that although except in special cases it does not represent any benefit, Webinoly has configured the server to respond in both ways for the new sites, that is,
www.anothersite.com all will be valid ways to access the new sites we have created.
In Webinoly we have the option to force the use of the subdomain
root (non-www). In the following example we will force the use of “www” for the new site
anothersite.com, this means that the server will respond in both forms, but will always redirect to
sudo site anothersite.com -force-redirect=www
Yoast SEO is perhaps one of the most used plugins in WordPress and to take advantage of its features to automatically create the sitemaps it asks us to add some lines of code to the Nginx configuration. Webinoly is already configured to be compatible with Yoast SEO plugin, so it is not necessary to add anything additional to make it work.
If you want to use a different plugin for sitemaps it is possible that it does not work properly due to the configuration that we have in a native way for Yoast SEO. You can disable Yoast SEO support in Webinoly as follows:
sudo webinoly -yoast-sitemap=off
Nginx server performance
So far we have a fully functional server with some custom settings. It is time to make some fine adjustments to improve the Nginx performance.
Normally the FastCGI cache is configured by Webinoly to expire every 30 days, this is a recommended value for websites with very low traffic. I explain briefly, the first time you visit a certain page of your site it is saved in the FastCGI cache and it will be there until the expiration period. If our site has just a few visitors in a day and we have configured a value, for example “1 hour”, most visitors will receive a non-cached version of the page, so it would not do any good to have the cache enabled.
To modify the configuration and values of FastCGI in Webinoly we use the following command:
sudo webinoly -config-cache
With the help of the “Nginx Helper” plugin that we already have installed in WordPress, we can activate the “timestamp” option to verify that we are effectively receiving cached versions of the visited pages. Remember that while you are logged in or with a session started in WordPress you will always receive fresh versions and not cached.
To clean/purge the cache you can do it from the “Nginx Helper” plugin or from the command line in the following way:
sudo webinoly -clear-cache=fastcgi
By default Nginx records all the access or error events on the server, Webinoly is configured to similarly segment this record individually for each site.
It is possible to disable the access logs to eliminate this task in each request and thus improve the performance of the server, especially in high traffic sites. It is not possible to disable the error logs.
sudo log -only-error=on
sudo log mymainsite.com -only-error=on
sudo log anothersite.com -only-error=on
We can also activate the “only-error” option since the beggining, before creating the sites and each site will be created with this option enabled automatically. For this example we just wanted to note that you can do it individually for each specific site.
To access tools such as phpMyAdmin, Webinoly has port 22222 configured by default. If we want to use another port, it is very easy to make the change using the following command:
sudo webinoly -tools-port=18915
sudo webinoly -tools-site=mymainsite.com
We also have forced the use of the domain “mymainsite.com” to access the tools section.
Aditionally and for security reasons to avoid malicious bots and scanners, we will add a black hole as default Nginx response. This way no content will be served, nor will it respond to requests that do not correspond to an existing domain or site, for example, requests using the IP of the server.
sudo webinoly -default-site=blackhole
If we want to block access to a specific IP or block of addresses, for example, a bot, service or unwanted visitor:
sudo webinoly -blockip=220.127.116.11
Finally, I like to add an external SMTP service like Amazon SES, Mailgun, SendGrid, etc; to improve the outgoing emails service.
sudo webinoly -smtp
With Webinoly as we could see in the previous example our idea is always to facilitate the routine tasks to fully manage a web server, everything is a command away. Although it is advisable, it is no longer necessary to have deep technical knowledge to manage your own server and host your website using a configuration as big sites would.
Please, if you have any recommendation or comment, do not hesitate to let us know by leaving a comment on this publication or through our support channels.