Site icon Ubuntu Free

Easily Install PHP5 With PHP Cache (APC) Support On Ubuntu 14.04

11

Hello everyone, how are you all doing today? I hope everyone is fine, as for me I am doing just fine. I have been busy planning a way to start my own ISP in my country lol, can you believe people here pay $200 USD a month for speeds less than 1mbps? Seriously.  Anyway, read on…

APC is a great caching software for PHP that can speed up your websites. Because PHP is a dynamic server-side scripting language that must be parsed and compiled on the server every time a page is requested, using caching software may greatly improve your website performance.

With APC or another PHP opcache installed and properly configured, the server won’t have to repeat the process of parsing and compiling PHP codes every time a page is requested. The first request is dynamically parsed and compiled, then stored in RAM memory as static objects. Subsequent pages are retrieved directly from APC memory cache and bypassing the the extra steps PHP must do before a page is rendered.

This is the beauty of using PHP opcode (operating code).

PHP Cache on Ubuntu 14.04

This brief tutorial is going to show you how to enable APC on Ubuntu 14.04 to help improve your website performance. For most webmasters, speed is important. If your website is slow, your users may not be happy when they visit your site, and may start to lose interest over time. That’s why you must focus on everything that will help speed up your pages.

There are many other things you may have to do to speed up your websites. However, if you’re running a PHP based websites like those running on WordPress or Drupal, then optimizing PHP is a must.

So, to get started with enabling APC on Ubuntu, continue below.

Ubuntu 14.04 comes ready for PHP5. PHP5 has it own Opcache module, so there’s no need to install additional software to enable  PHP opcode. So all you have to do is run the commands below to install PHP5 which will install its own opcache.

sudo apt-get update && sudo apt-get install php5

By default your operating system will install PHP5 with the basic configuration and disable the opcache feature. Optimizing PHP configuration will greatly improve your sites performance. So enable PHP caching.

After installing PHP5, go and begin configuring it. First enable it by adding un-commenting the line below.

Close to the bottom of the php.ini file, you’ll see the opcache section.

 sudo vi /etc/php5/apache2/php.ini

Then begin un-commenting the opcache section to suite your environment.

[….]
[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1
; The OPcache shared memory storage size.
opcache.memory_consumption=128
; The amount of memory for interned strings in Mbytes.
;opcache.interned_strings_buffer=4
; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=2000
[….]

When you’re done, save the file and restart Apache2 or what every web server you’re using.  To restart Apache2, run the commands below.

sudo service apache2 restart

To restart Nginx, run the commands below.

sudo service nginx restart

Remember to like our facebook and our twitter @ubuntufree for a chance to win a free Ubuntu laptop on December 25!

Quick Links: Schools in Download Linux 3.16 Free | Install LibreOffice 4.3 On Ubuntu 14.04 | Cute Girl Wallpapers For Ubuntu | Black Wallpapers For Ubuntu

Exit mobile version