Optimizing PHP installation..

Since virtualmin uses standard precompiled php package, what is best way to optimize PHP. I have already install APC and instantly saw good improvement but I further want to optimize it. If it was cPanel, I would have used easy apache, selected modules I need and recompile it…

How do I do same in virtualmin ?

Here is my php info :

'./configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' '--enable-calendar' '--without-sqlite' '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbregex' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/lib64/mysql/mysql_config' '--enable-dom=shared' '--with-pgsql=shared' '--enable-wddx=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--with-curl=shared,/usr' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--with-sqlite3=shared,/usr' '--enable-json=shared' '--enable-zip=shared' '--without-readline' '--with-libedit' '--with-pspell=shared' '--enable-phar=shared' '--with-tidy=shared,/usr' '--enable-sysvmsg=shared' '--enable-sysvshm=shared' '--enable-sysvsem=shared' '--enable-posix=shared' '--with-unixODBC=shared,/usr' '--enable-fileinfo=shared' '--enable-intl=shared' '--with-icu-dir=/usr' '--with-enchant=shared,/usr' '--with-recode=shared,/usr'

So, you can se eits install with lots of things I don’t use like odbc support, ldap-sasl, psql etc…

The APC module is available for the stock PHP as well. If there are modules you don’t need you can uninstall them (if they are separate), or comment them out in the php.d directory. The problem with compiling PHP yourself is you have to do it every time there is a new release, you can perform the same “optimizations” on any other PHP install.

Well, I am coming from cPanel which makes very easy to manage server for webhosting. Here I am not sure how to do that, I understand it can be done but without breaking anything… one more thing I understand that if you are using package based system then package based installation should be preferred.
Since, all required libraries are installed, if I re-compile PHP with required one, I guess it can make good difference.

PS: May be I was not clear about APC, I have already installed it and it working and working good.

When you compile something you have to stay on top of updates, otherwise security flaws/bugs start happening and your server gets hacked.

I like to use RPMs as they are easy to install and upgrade. When you compile software you can’t easily remove it, can’t upgrade it without compiling the new version.

There is a RPM available for almost everything, the APC module is available from the EPEL repository. I use it on a server with several WP sites.

If you are using cPanel, by all means use EasyApache. For Virtualmin stick to RPMs, it will make things easier if you need to troubleshoot anything, or if you need help with something in the future.

As far as disabling modules you don’t need, for example to disable the “odbc” module, just comment out the “extension=” line in “/etc/php.d/odbc.ini”

You should enable Zend opcache and memcached for php 5.4 and newer.

OPcache is included in the PHP 5.5 core and it will have to be maintained with every new PHP release. There should be no more weird problems caused by incompatibilities between a new PHP release and the opcode cache. Also, the development of APC has slowed down and, at least for now, APC is not compatible with PHP 5.5.

Here’s a page that explains how to enable opcache and view cache statistics.