How to enable the APC extension in php

Mar-18th-2011

Alternative PHP Cache (APC) is a free, open source framework that optimizes PHP intermediate code and caches data and compiled code from the PHP bytecode compiler in shared memory. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP library files can be fetch from the parsed cache. This will generally lead to a speed increase when serving a PHP site, especially one with a lot of library files. APC, allows your web server to save the compiled PHP so it can skip that compiling step. This can give your server a huge performance boost.

Please take the backup of php directory first because if anything goes wrong you can revert your configuration and then use the following steps to install the apc extension  :-

First of all we need to download the APC code from the PHP PECL library. So change directory to somewhere like /home or /usr/local/ and then get the latest version like so

[root@piyush ~]#  cd /opt
[root@piyush opt]#  wget http://pecl.php.net/get/APC

This will always get the latest version, downloaded APC-3.0.16.tgz like so: And then you need to extract the files:

[root@piyush opt]# tar -zxvf APC-3.0.16.tgz

[root@piyush opt]# cd APC-3.0.16

The next step is to run the “phpize” command. This requires that you have PHP development package installed(Php-devel,. Installed by running “yum install php-devel”).

[root@piyush APC-3.0.16]# phpize

Then configure APC, telling it where the executable file php-config is. If you don’t know where this is, then do this and it will return something like:

[root@piyush APC-3.0.16]# whereis php-config
php-config: /usr/bin/php-config

And then run the configure command like :-

[root@piyush APC-3.0.16]# ./configure –enable-apc –enable-apc-mmap –with-apxs=/usr/sbin/apxs(your apache apxs path) –with-php-config=/usr/bin/php-config  (your php-config path)

[root@piyush APC-3.0.16]# make

[root@piyush APC-3.0.16]# make install

Libraries have been installed in [ /opt/APC-3.0.16/modules]. Check your php.ini location by following command.

[root@piyush APC-3.0.16]# php -i | grep php.ini

Now open php.ini file in your favorite editor, And go to the last line and paste the following :-

[root@piyush APC-3.0.16]# vi /etc/php.ini

extension=”apc.so”

Now restart your apache web server.

[root@piyush APC-3.0.16]# /etc/init.d/httpd restart

The APC cache will now be enabled. You can verify this by creating a script or custom page which calls the phpinfo() command and looking for the APC section. It will have been switched on by default by adding a “extension=apc.so” line to your /etc/php.ini file.

=============================================================================

Enjoy Linux !!!

Access Your MySQL Server Remotely Over SSH

Mar-7th-2011

Hello Friends,

Access Your MySQL Server Remotely Over SSH | SSH Tunnel

Everybody wants to secure their server and also wants to access application from remotely. So if you have MYSQL server, But bydefault its only opened for local machine for the security reasons. And if you want to access your database server or database from remote machine by any mysql client. You allow access to your client’s ip but its not secure.

So instead of doing this we can use port forwarding through ssh tunnel, so MySQL client thinks it’s connecting to your localhost machine, but it’s really connecting to the other server through the ssh tunnel.  SSH (Secure SHell) is protocol which allows user to remotely connect to server and use specified service in same manner as he is directly connected on local console. This proces is called tunelling.

If you are using the command line ssh or not using any mysql client, then command will be :-

ssh -L <localport>:hostname:<remoteport> <username>@<servername>

And if you are using any mysql client you can do simple by configuring that client :-

Here we are using navicat lite for mysql, Just open your navicat for mysql

Navicat lite >> Connection >> Mysql

Now in General tab :

Connection Name :-  LinuxSurgeon Mysql Server  (Its just connection name)
HostName / IP  :-  localhost  (your mysql hostname after ssh)
Port :- 3306
User :-  root      (your mysql user name)
Pass :-  ****     ( your mysql password)

Now in SSH tab :

Check mark on “Use SSH Tunnel ”
HostName / IP : Your Mysql Server’s ip address
Port  :    22
User Name :        root
Auhentication :    Password / Public Key
Password :      *****

=======================================================================

Enjoy Linux !!!