SHARE

Hey guys,

Now in the market there are so many options about hosting for people with a lot of benefits they bring. If you are using Shared Web Hosting, nearly make sure that you will use cPanel to manage. cPanel is so popular in the world because of its easy to use, suitable with so many kinds of users. However, I believe that not all people know how to optimize their website to use hosting more efficiently. Today we will share you 4 tips to optimize your website using cPanel Hosting. Please take time and follow our simple tips to get more knowledge.

I. Optimize PHP 7.1

  1. Choose the version PHP 7.1

The providers of hosting usually select default version PHP 5.6 because this version existed for a long time and the ability to be compatible with many different open sources is higher than the version PHP 7.0 or PHP 7.1

However, if you are using WordPress, Joomla, Magento…please choose the version PHP 7.1 instead of PHP 5.6. Because these popular open sources are updated normally, compatible 100% with the latest PHP version. According to some researches, WordPress uses PHP 7 brings the productivity three times higher than PHP 5.6. The one thing is that the version PHP 5.6 now stops developing, only supports some dangerous cases.

So Using PHP 7 is an inevitable trend, if your code is not well-compatible, our advice is to take time to optimize, replace the deprecated functions, make use of the power of PHP 7. Most hosting providers allow you to switch between PHP versions. In cPanel, select Select PHP Version

Then select PHP version 7.1 and click button Set as current

2. Activate some necessary extensions

PHP 7.1 comes with a number of extensions that improve the performance of your website, such as Zend Opcache, Memcached. These extensions that are not activated when using cPanel are too expensive.

Still in the PHP Selector | Extensions, click opcache and memcached options then click Save to save. See picture above.

Opcache is a very important extension helping the files .PHP do not need to be recompiled at runtime, increasing the processing speed and responsiveness of the website. Opcache only needs to activate it will run, no additional configuration. This extension is almost mandatory for you to activate when using the hosting, please note.

Memcached cache query, which helps reduce the load on your MySQL server, depending on which hosting provider supports it or not, which you can activate.

3. Configure the necessary parameters

In addition to changing the default PHP version, you can also reconfigure PHP’s parameters to suit better with your actual usage needs.

Still in the page Select PHP Version, click the Switch to PHP Options link. The parameters you are allowed to adjust will appear:

The parameters have been adjusted to be green, but the default is gray.

The meaning of some options is as follows:

– Allow_url_fopen: Enables the use of the fopen function.
– Date.timezone: Change the default timezone in PHP.
– Display_errors: Turns on / off displaying PHP errors outside the website.
– Error_reporting: Optional PHP errors are reported.
– File_uploads: Allow upload via PHP.
– Include_path: The path to save the PHP configuration, should not change.
– Log_errors: Turn off log files.
– Mail.force_extra_parameters: Add custom parameters when sending mail.
– Max_execution_time: Customize the maximum time to execute PHP.
– Max_input_time: Maximum time for PHP to analyze input data, -1 is not limited.
– Max_input_vars: Limit the number of parameters passed to.
– Memory_limit: Maximum memory that PHP is allowed to use.
– Open_basedir: Set the directory path that PHP is allowed to execute, leaving it blank to use the server’s default settings.
Post_max_size: Set the max data size to be sent.
– Session.save_path: Set up the directory containing the session in PHP.
– Short_open_tag: Allow PHP to use shortcut <? Instead of <? Php.
– Upload_max_filesize: set the maximum file size allowed to upload to the server via PHP.

II. Activate Let’s Encrypt

About one third of the world’s sites have switched to HTTPS instead of HTTP, and the number is still increasing because of the benefits that HTTPS brings. It’s great that we can use SSL completely free, activated directly in cPanel with support from Let’s Encrypt.

By default, the certificate is activated for 3 months, but cPanel automatically renews you automatically, so after activation you are free to use, no worries anymore.

In addition to securing data transfer between the user and the server, there is a huge benefit that many of you are not aware of when using Let’s Encrypt enabled via cPanel, which is HTTP2.

HTTP2 is an upgraded version of the old HTTP / 1.1 transport protocol that was introduced in 1999, which we are using today. HTTP2 helps web pages load 3 to 10 times faster, longer “live” connections, faster content, and support for multiple parallel connections. Direct HTTP / 1.1 experience with HTTP / 2 here.

After enabling Let’s Encrypt, check the site load process using Developer Tools, you will see all image data, .js files, .css files have been transferred to the HTTP2 protocol. No further configuration is needed.

With a lot of great benefit like so, please quickly check your provider of hosting support or not and activate Let’s Encrypt

III. Activate LiteSpeed Cache

The LiteSpeed Webserver is a perfect replacement for Apache, which is 900% faster than Apache for static data processing and up to 50% faster when handling PHP requests.

When using LiteSpeed, most vendors will enable the powerful caching LiteSpeed Cache, which behaves similarly to Apache’s mod_cache, but has the same powerful performance as the Varnish Cache.

Because of the server-level cache, LiteSpeed Cache will work better than application-level cache.

Enable LiteSpeed Cache with WordPress

To use the cache first, you must change the default WordPress Permalink path to another custom form, such as Post name:

Then install and activate plugin LiteSpeed Cache:

The plugin will automatically enable the cache feature, so you can configure it further in the Settings section of the LiteSpeed Cache. The cache check does not work with the tool check header, the first time you request you can see the X-LiteSpeed-Cache => miss, but the second request returns an X-LiteSpeed-Cache => hit. So LiteSpeed Cache works.

Activate LiteSpeed Cache with other code

With other code, if there is no corresponding plugin, you just add the code below to the top of the file. Htaccess:

<IfModule LiteSpeed>
CacheLookup public on
</IfModule>

Some providers use LiteSpeed Webserver has support caches such as Hawk Host, Stable Host, AZDIGI…

IV. Optimized Browser Caching

Both Apache and LiteSpeed Webserver support .htaccess files, which you can use to optimize Browser Caching, require the browser not to load static files, such as JS, CSS, images and other media files (pdf , Flash, …) whenever a request is made.

Open the .htaccess file at the root of your website, insert the following code:

<IfModule mod_expires.c>
 # Enable expirations
 ExpiresActive On 
 # Default directive
 ExpiresDefault "access plus 1 month"
 # My favicon
 ExpiresByType image/x-icon "access plus 1 year"
 # Images
 ExpiresByType image/gif "access plus 1 month"
 ExpiresByType image/png "access plus 1 month"
 ExpiresByType image/jpg "access plus 1 month"
 ExpiresByType image/jpeg "access plus 1 month"
 # CSS
 ExpiresByType text/css "access plus 1 month"
 # Javascript
 ExpiresByType application/javascript "access plus 1 month"
</IfModule>

To test, you use the tool check header with a URL image or CSS file, if the header contains Cache-Control and Expires plus one month is successful

Hopefully with this article, you will use more efficient hosting. If you know any other tricks, share them by leaving a comment below.

Thanks a lot!

Leave a Reply

1 Comment on "4 Tips to optimize your website using cPanel Hosting"

Notify of
avatar
Sort by:   newest | oldest | most voted
Piter
Guest

I tried this setup but it show me error:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

I changed back to PHP 5.6 and now it works.

wpDiscuz