Let’s Learn how to Speed up VestaCP on CentOS 7. Vesta Control Panel is an open source hosting control panel that is simple and easy to use. The interface is clean and simple with lots of useful functionalities which should help you host websites on your VPS.
Vesta Control Panel currently can be installed on RHEL 5, RHEL 6, CentOS 5, CentOS 6, CentOS 7, Debian 7, Debian 8, Ubuntu 12.04, Ubuntu 12.10, Ubuntu 13.04, Ubuntu 13.10, Ubuntu 14.04, and Ubuntu 16.04 operating systems.
In this tutorial, we will teach you how to speed up VestaCP on CentOS 7.
Step 1: Upgrading PHP
Before you begin, make sure that your system is up-to-date.
# yum update
Next, enable the ‘remi-php70’ so you can upgrade VestaCP to PHP 7:
# yum-config-manager --enable remi-php70
Update the system once more using this command that will upgrade every PHP package to PHP 7.
# yum update
Next, restart the php-fpm service.
# systemctl restart php-fpm
Step 2: Installing Opcache
Opcache can be installed simply and by executing the command below.
# yum install php-opcache
Restart the php-fpm service once more:
# systemctl restart php-fpm
Restart Nginx as well.
# systemctl restart nginx
Now check if Opcache has been enabled by executing the command below.
php -i | grep opcache.enable
If Opcache is enabled, you will receive something like the output shown here.
opcache.enable => On => On
Step 3: Upgrading MariaDB
Before starting, create a backup from all of the databases.
Instead of the conventional ‘mysqldump’ utility, VestaCP CLI can be used to generate a backup for all of the users on your system. If you would like to do that, execute the following.
# v-backup-users
To restore the backup, if you want to, begin by retrieving the backup file name by entering the following.
# v-list-user-backups <username>
Now execute the command below to restore all the databases for a specific user:
# v-restore-user <username> <backup_name> no no no <username> no no no
Swap ‘<username>’ for the username you’d like to restore the databases for and ‘<backup_name> ‘for the name of the backup retrieved by the v-list-user-backups command.
You can now upgrade MariaDB. Begin by deleting the old MariaDB version:
# yum remove mariadb mariadb-server
Append the repository for Mariadb 10 by making the repo file with nano and then pasting the text below.
# nano /etc/yum.repos.d/MariaDB.repo # Used to install MariaDB 10 instead of default 5.5 # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = https://yum.mariadb.org/10.2/centos7-amd64/ gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Update the system another time.
# yum update
You can now install MariaDB 10.
# yum install mariadb mariadb-server
Once the installation is done, initiate MariaDB by executing the command shown below.
# systemctl start mariadb
Now enable the MariaDB service on boot:
# systemctl enable mariadb.service
Step 4: Installing Redis
Redis is an in-memory data structure store mainly used as a database and cache; A large benefit to speed can be gained by configuring Redis to cache your pages or to cache your database rows.
Install Redis by entering the command below.
# yum install redis
Once the yum package manager is done installing Redis, enter in the command below to initiate Redis.
# systemctl start redis
We may now enable the Redis service so that it initiates on boot.
# systemctl enable redis.service
Step 5: Configuring WordPress
If you would like to use WordPress for your site, it could be a good choice to install Redis as a caching system for WordPress.
This will require the Phpredis extension in order to configure WordPress to use Redis. First install this package.
# yum install php-devel
Next, install the Phpredis extension by executing this command.
# pecl install redis
Press enter once the message below shows up.
enable igbinary serializer support? [no]
Once PECEL is done installing Phpredis, open the ‘php.ini’ file and append the following line at the bottom.
# nano /etc/php.ini extension=redis.so
Restarting ‘php-fpm’ will allow the changes to take affect.
# systemctl restart php-fpm
Log into the WordPress backend and install the plugin ‘W3 Total Cache’ before activating it.
In the plugin settings for W3 Total Cache, choose ‘Redis’ as page cache and database cache then check the ‘enable’ checkbox for each option before clicking on the ‘Save all settings’ button.
Once this is done, restart Nginx.
# systemctl restart nginx
Next, turn on the Redis monitor by executing the command below.
redis-cli monitor
Open the web browser of your choice and navigate to your WordPress page. If Redis is working, you will see an output similar to the one shown below.
1510462482.538685 [0 127.0.0.1:48166] "GET" "w3tc_dreamvps.com_0_dbcache_0eacdb46b225fbe864f35d73500d5b5f" 1510462482.539190 [0 127.0.0.1:48166] "SETEX" "w3tc_dreamvps.com_0_dbcache_0eacdb46b225fbe864f35d73500d5b5f" "180" "a:7:{s:10:\"last_error\";s:0:\"\";s:10:\"last_query\";s:205:\"SELECT wp_comments.comment_ID FROM wp_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1 AND comment_parent IN ( 1 ) ORDER BY wp_comments.comment_date_gmt ASC, wp_comments.comment_ID ASC \";s:11:\"last_result\";a:0:{}s:8:\"col_info\";a:1:{i:0;O:8:\"stdClass\":13:{s:4:\"name\";s:10:\"comment_ID\";s:7:\"orgname\";s:10:\"comment_ID\";s:5:\"table\";s:11:\"wp_comments\";s:8:\"orgtable\";s:11:\"wp_comments\";s:3:\"def\";s:0:\"\";s:2:\"db\";s:14:\"admin_admin_wp\";s:7:\"catalog\";s:3:\"def\";s:10:\"max_length\";i:0;s:6:\"length\";i:20;s:9:\"charsetnr\";i:63;s:5:\"flags\";i:49699;s:4:\"type\";i:8;s:8:\"decimals\";i:0;}}s:8:\"num_rows\";i:0;s:10:\"return_val\";i:0;s:11:\"key_version\";i:1;}" 1510462482.542520 [0 127.0.0.1:48166] "GET" "w3tc_dreamvps.com_0_dbcache_b8bd04fe419b1c9d747a8bccb997d588" 1510462482.543239 [0 127.0.0.1:48166] "GET" "w3tc_ dreamvps.com_0_dbcache_a8b6d316b4c822ac63eaf77731ed617b" 1510462482.543760 [0 127.0.0.1:48166] "GET" "w3tc_dreamvps.com_0_dbcache_53058f6b83972cfc3253e30ef06fcaa9" 1510462482.544272 [0 127.0.0.1:48166] "GET" "w3tc_dreamvps.com_0_dbcache_276679217e6dc451b6353e7a1901990c"
Also, here we have a few hand-picked guides that you must read next: