jul 202016
 

Introduction

I came across a few warnings when I wanted to list the modules of an
apache 2.4.7. server on an Ubuntu 14.04 server.

Error

This shocked me, but analyzing the server further showed me that
everything was up and running.

What’s going on?

There is nothing going on, except that if you request output from
the /usr/sbin/apache2 binary directly, the /etc/apache2/envvars file isn’t sourced.

Running the same command with apache2ctl gives correct output:

dec 162015
 

With the release of Ubuntu 14.04 and the proliferation of PHP 5.5, there is going to be a migration away from Alternative Performance Cache (APC) and toward PHP’s new built-in OPcache.

This is a logical move that seems destined for any interpreted language. As websites have become more and more complicated with many processes running, opcode caching has become a necessity – fortunately, it’s simple to implement.

The php.net site has a nice page of all the runtime options available, but we will cover the basics here to get you started quickly.

All you need to do to get OPcache set up is to make changes in the php.ini file on your server.

Open php.ini In Your Favorite Text Editor
To get started open your php.ini file.

Apache web-servers

/etc/php5/apache2/php.ini

Enable the OPcache
To enable the OPcache, change to the following lines — easy enough!
;opcache.enable=0
Change to:

opcache.enable=1
Note: you have to uncomment this line as well as change the “0″ to “1″.

Modify the Amount of RAM the OPcache Will Use
With OPcache, there is a trade-off between speed and the amount of RAM used. The more RAM you are willing to dedicate to storing opcode, the more opcode that can be stored. There is a diminishing return at some point, because some code will execute rarely, or your code base might not be that big. It is worth playing with this setting to see where you get the best performance-versus-RAM trade-off. This setting is in megabytes.

;opcache.memory_consumption=64
Change to:

opcache.memory_consumption=128
Boost the Number of Scripts that Can Be Cached
OPcache has a strange setting that requires you to not only adjust the amount of RAM, but also define the number of scripts that can be cached. You have the option of tuning this parameter for your own application too, especially if you find that your hit rate is not close to 100 percent.

;opcache.max_accelerated_files=2000
Change to:

opcache.max_accelerated_files=4000
Change the Revalidate Frequency
To make sure that the OPcache notices when you change your PHP code, you can set the revalidate frequency. Basically, this will tell the cache how often to check the timestamp on the files. This is measured in seconds.

;opcache_revalidate_freq = 2
Change to:

opcache_revalidate_freq = 240
Verify that the PHP OPcache Mod is Enabled
Believe it or not, that converts most of the settings you will need to get started. PHP5 has its own module system (since 5.4), so make sure that OPcache is enabled.

sudo php5enmod opcache
Restart PHP and Your Server
You should now be all set to start using PHP 5.5’s OPcache. You just need to restart your server to get it going.

Apache Web-Servers

sudo service apache2 restart
Nginx Web-Servers

sudo service nginx restart
Conclus

okt 072015
 

PHP has different functions which can be used to test the value of a variable. Three useful functions for this are isset(), empty() and is_null(). All these function return a boolean value. If these functions are not used in correct way they can cause unexpected results.

isset() and empty() are often viewed as functions that are opposite, however this is not always true. In this post I will explain the differences between these functions.

Continue reading »

okt 112014
 

If you are one of the people who has installed ESXi on a bootable flash drive and then wanted to either erase the drive or start over, you might realize that Windows doesn’t like to give you permissions to format the entire flash drive. I ran into this situation a few months back and decided to share the easiest way to re-format your drive without downloading additional software:

  1. From Command prompt type ‘diskpart‘
  2. type ‘list disk‘
  3. it should then look something like this:

Continue reading »