upeksha@uwlab:~$ sudo adduser uwapc
Adding user `uwapc' ...Adding new group `uwapc'(1002) ...
Adding new user `uwapc' (1002) with group `uwapc' ...
Creating home directory `/home/uwapc' ...Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for uwapc
Enter the new value, or press ENTER for the default
Full Name []: UW APC Testing
Room Number []: 123
Work Phone []: +94 011 7776665
Home Phone []: +94 011 1122334
Other []: +94 077 1234567
Is the information correct? [Y/n] Y
3) Setup a Virtual Host
‘Setup the Virtual Host’
12345
upeksha@uwlab:/home$ cd /etc/apache2/sites-available/
upeksha@uwlab:/etc/apache2/sites-available$ ls
default default-ssl wisidagama.dev
upeksha@uwlab:/etc/apache2/sites-available$ sudo cp wisidagama.dev uwapc.dev
upeksha@uwlab:/etc/apache2/sites-available$ sudo vi uwapc.dev
Change the APC size to 100MB in the wrapper script. Please refer to the post linked at the top of this post on how to change the APC size per user.
3) Setup MySQL database
‘WordPress Database Setup’
123456789101112131415
uwapc@uwlab:~$ mysql -u root -p
Enter password:
mysql> create database uwapc;
Query OK, 1 row affected (0.00 sec)mysql> grant usage on *.* to uwapc@localhost identified by 's9sd%sd@1DS!A(6,sld69s%sHEaRWad9#@)X~sd7ZzdffzzzZZZdd9df%^';
Query OK, 0 rows affected (0.00 sec)mysql> grant all privileges on uwapc.* to uwapc@localhost;
Query OK, 0 rows affected (0.00 sec)mysql> exitBye
upeksha@uwlab:/var/www/bin$ mysql -u uwapc -p
4) Become ‘uwapc’ and setup WordPress
‘Download WordPress’
123456789101112131415161718
upeksha@uwlab:/var/www/bin$ su uwapc
Password:
uwapc@uwlab:/var/www/bin$ cduwapc@uwlab:~$ wget http://wordpress.org/latest.tar.gz
--2013-07-08 15:28:15-- http://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 66.155.40.250, 66.155.40.249
Connecting to wordpress.org (wordpress.org)|66.155.40.250|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4988077 (4.8M)[application/x-gzip]Saving to: `latest.tar.gz'100%[======================================>] 4,988,077 25.9K/s in 3m 22s2013-07-08 15:31:40 (24.1 KB/s) - `latest.tar.gz' saved [4988077/4988077]uwapc@uwlab:~$ tar -xzvf latest.tar.gz
uwapc@uwlab:~$ mv wordpress public_html
uwapc@uwlab:~$ ls
latest.tar.gz public_html
5) Install WordPress via web interface.
Enable the new site and restart.
‘Enable new site’
1234567
upeksha@uwlab:/var/www/bin$ sudo a2ensite uwapc.dev
[sudo] password for upeksha:
Enabling site uwapc.dev.
To activate the new configuration, you need to run:
service apache2 reload
upeksha@uwlab:/var/www/bin$ sudo service apache2 restart
* Restarting web server apache2 ... waiting
We are not running a DNS server. Map the new site address to the host ip via /etc/hosts file.
Install APC Info Interface
‘APC Info Interface Installation’
1234567891011121314
uwapc@uwlab:~$ wget http://pecl.php.net/get/APC
--2013-07-08 16:12:48-- http://pecl.php.net/get/APC
Resolving pecl.php.net (pecl.php.net)... 76.75.200.106
Connecting to pecl.php.net (pecl.php.net)|76.75.200.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 171591 (168K)[application/octet-stream]Saving to: `APC'100%[======================================>] 171,591 121K/s in 1.4s2013-07-08 16:12:55 (121 KB/s) - `APC' saved [171591/171591]uwapc@uwlab:~$ tar -zxf APC
uwapc@uwlab:~$ mv APC-3.1.13 public_html/apc
Visit APC Info Interface to see the APC status.
Benchmarking WordPress Response Time with APC
Disable APC.
Set apc.enabled=0 in ‘/etc/php5/cgi/conf.d/apc.ini’.
Restart the server.
sudo service apache2 restart.
Run Apache Benchmarking tool to collect performance data.
ab -n 1000 -c 30 -g without-apc.dat http://www.uwapc.dev/
Enable APC. Restart the server. Again, run ab tool.
ab -n 1000 -c 30 -g with-apc.dat http://www.uwapc.dev/
‘APC Info Interface Installation (APC-benchmarking.p)’
123456789101112131415161718192021222324
# output as png imageset terminal png
# save file to "apc-benchmarking.png"set output "apc-benchmarking.png"# graph titleset title "WordPress Benchmarking with APC"# nicer aspect ratio for image sizeset size 1,0.7
# y-axis gridset grid y
# x-axis labelset xlabel "request"# y-axis labelset ylabel "response time (ms)"#plot data from data filesplot "without-apc.dat" using 9 smooth sbezier with lines title "Without APC", \"with-apc.dat" using 9 smooth sbezier with lines title "With APC"
gnuplot APC-benchmarking.p
WordPress Performance Gain While Many PHP5-CGI Children share the same APC under One User with High Concurrency
Next, increase the PHP-CGI children from 2 to 6 (PHP_FCGI_CHILDREN=6 in FastCGI wrapper script). Increase the concurrency to 60 -c 60. Benchmark again.
The above plots clearly show the Performance Gain in Response Time when using APC to cache the PHP Opcodes.