A crashed VPS because the Apache service or MySQL service is taking all the memory? Well, then you definitely have to read this guide on how to fix a slow WordPress website, a crashing server and an Apache service which spawns a lot of processes.
Create a backup if you do not have one
Important things first, your DATA. It is important to have a backup of the environment you are going to work on. So if it is possible to create a full backup of the server, then certainly do so.
You can download and install Filezilla, this is a FTP client which also supports SFTP protocol, this protocol allows you to transfer files securely between a private connection with your server and your client (the device you are currently using).
- Create a connection to your server by using the “FILE” -> “SITE MANAGER” -> “NEW SITE” functions which can be found in the top menu of Filezilla.
Database backup
It is also important to create a backup of your MySQL server which is providing the WordPress database.
TIP: If you are uncertain which database you have to backup, take a look in your wp-config file.
Login to your VPS by using a SSH tunnel, once you have logged in, perform the following command to backup your WordPress database.
mysqldump database_name > database_name.sql
If mysqldump asks for a username and password, then perform the command like this
mysqldump database_name > database_name.sql –u USERNAME –p
Now that you have created a backup of your database, you can use the Filezilla tool to download the MySQL database from your VPS.
TIP: The MySQL database is often stored in /var/lib/mysql/
How to speed up Apache
I could explain on how you can speed up Apache, but to be honest, there are posts on the internet which give way better instructions on how to speed up Apache servers – so in order to help you forward, I have listed the sources which I think that can be useful for you in order to speed up Apache.
The first one I would want to mention is the “3 small Tweaks to make Apache run Faster” by Jeff Geerling, this small but direct post instructs you on how to speed up Apache with KeepAlive, MaxClients and AllowOverride configs.
The list:
- https://www.giftofspeed.com/apache-server/
- https://www.howtoforge.com/tutorial/install-apache-pagespeed-and-memcached-on-ubuntu-15-10/
- http://www.monitis.com/blog/2011/07/05/25-apache-performance-tuning-tips
How to speed up WordPress
This might sound weird, but in order to speed up WordPress, you will first have to install a Plugin on WordPress which is called “P3 (Plugin Performance Profiler)”. The P3 (Plugin Performance Profiler) plugin will allow you to check your WordPress site for plugins which use a lot of memory or processes – which in order result in a slow WordPress site.
This plugin creates a profile of your WordPress site’s plugins’ performance by measuring their impact on your site’s load time. Often times, WordPress sites load slowly because of poorly configured plugins or because there are so many of them. By using the P3 plugin, you can narrow down anything causing slowness on your site.
Run the P3 (Plugin Performance Profiler) plugin and check the results – then think about which plugins can be disabled – or simply verify that it is not a plugin which is causing WordPress to perform slowly.
Check your logs
In the /var/log/ section, you will be able to find logfiles of services which run on your VPS. If you are using Apache, the logs will be stored in the /var/log/httpd/ folder.
Open the file /var/log/error_log in order to view the errors which the Apache service has reported.
Disable XML-RPC
Navigate to your WordPress folder and edit the .htaccess file with the following code in order to block any XML-RPC connection.
XML-RPC is often used by hackers to perform DDoS attacks.
<files xmlrpc.php>
order allow,deny
deny from all
</files>
WARNING: DO NOT PERFORM THIS STEP IF YOU ARE HOSTING YOUR SITE ON WORDPRESS.COM – INSTEAD USE THE JETPACK PLUGIN.
Questions
If this did not help you, do not hesitate to leave a question in the comment section or the forum.