Usually with a budget of 70 to 150 USD per month, you’ll get a decent dedicated server to host a WordPress site with medium traffic. We are discussing unmanaged budget dedicated servers from any reputed web host. With proper optimization of the backend, the server can reliably run without 24×7 monitoring.
You must take regular backups and probably keeping a cheap OpenVZ server as live standby is a good idea since quickly changing the DNS will keep the website online. VPSDime is a good OpenVZ server provider for staging, testing etc. It is a costly option but less costly than adding a managed layer.
What Server Software/Packages We Need
We will need:
- Latest Apache2 web server with some modules
- PHP with some module
- Latest MariaDB
- PageSpeed module
and some time in hand. We suggest using Apache and PHP from Ondřej’s repository. Avoid installing a lot of server packages on the main server since they will consume resources. Avoid installing a web hosting panel and PHPMyAdmin in case you host a single website or a couple on one server and the server is unmanaged. They will consume resources and will increase security risks.
How to Optimize the Server for WordPress
sudo apt-get update
sudo add-apt-repository ppa:ondrej/apache2
sudo apt-get install apache2
Usually, you’ll need the below Apache modules (running
apache2ctl -M command will list the modules):
php7_module (shared) or php8_module
You need to install PHP to enable some of them. We have a lot of guides on Apache2 on this website (perform a site search with the phrase Apache2). These two guides will help you:
The MPM prefork handles one connection at a time without creating separate threads. Running
apache2ctl -V command will list the required info. It is good for non-thread-safe modules like mod_php. There are at least two ways of running PHP, one is by using CGI and the second way is to run PHP as an Apache module (mod_php). We have a guide on optimizing MPM prefork. There is a shell script to check the memory used by Apache2:
mpm_prefork cannot be made performant which is the reason people are abandoning it. But for WordPress, it is risky for the plugins to avoid mpm_prefork since it is the PHP code which makes the other modules to safe to use. Even with mpm_prefork, you’ll get PHP warnings from a few plugins. Optimization depends on traffic and plugins.
Next is PHP. Here is our old guide on installation of PHP 7.2. The installation will be similar in all versions of PHP and PHP will not need radical tweaking.
The final thing is MariaDB. It is a straightforward installation. Here is an example configuration file as GitHub gist.
You can secure the server with FTP software and port knocking. You can install memcached to test the response time. But, APCu will deliver a better result with WP Super Cache.
Required WordPress Plugins
You’ll need certain plugins to support and control the server software. All of them are free:
- APCu Manager
- IP Geo Block
- MySQL query cache stats
- PageSpeed Module
- Prevent XSS Vulnerability
- WP Super Cache
- WP Fail2Ban Redux
sudo apt install tuned tuned-utils tuned-utils-systemtap
sudo tuned-adm profile throughput-performance
You need to reboot the server. Always remember that any dedicated server takes a long time to reboot than a virtual server. Always check the status of major components after a reboot.