Linux installation php and memcache process record

  

The installation environment is Ubuntu13.10 version i386, the nginx server and mysql server have been installed, the task is to install php and memcache. Direct dry goods, not to say redundant.

1, php installation and error troubleshooting

Because php needs to install a lot of library files before installation, so you need to be patient in a certain order to install. I installed in the following order:

zlib -> freetype -> libxml2 -> libpng -> libgd2 -> libmcrypt

One of the dependencies is that installing gd2 is required Use zlib, freetype, libpng (libjpeg), etc., so you need to install these before installing gd2. The installation here is configured according to the common directory to the /usr/local/xxx directory. Generally, there will be no problems. There may be problems when installing freetype:


Note, when installing freetype You may be prompted with the following error: either set the LIBPNG_CFLAGS and LIBPNG_LDFLAGS environment variables This is the installation location where you can't find libpng, so you need to configure the bin directory of libpng into the environment variable: Solution: edit: vi /etc/profileLIB_PNG=/usr /local/libpng/binPATH=$LIB_PNG: $PATH export PATH takes effect: . /etc/profile Here I want to record that I did not report an error when installing GD2, the installation was successful. But when I installed php, after configuring the installation directory of GD2 in the configuration, there was an error, and configure is no problem. It was wrong during the installation. It should be known that when configuring php, configure will take a long time, then it is correct. It takes a long time to make, so waiting for a long time and then suddenly said that the compilation error, it is a bit of a crash. The error is as follows: 
/usr/local/src/php-5.5.6/ext/gd/gd.c:57:22: error: X11/xpm.h: No such file or directorymake: *** [ext /gd/gd.lo] Error 1 Description: This is a hint that the libXpm library is not installed. It is not configured when the gd2 library is installed. 

This way I went to check the configuration before installing gd2, I did not support the libXpm library, as follows:

** Configuration summary for libgd 2.1.0: Support for Zlib: yes Support for PNG library : Yes Support for JPEG library: no Support for VPX library: no Support for TIFF library: no Support for Freetype 2.x library: yes Support for Fontconfig library: no Support for Xpm library: no Support for pthreads: yes

The solution is to download the libXpm library installation:

sudo apt-get install libXpm-dev After this installation, I thought it would be fine, just re-install the gd2 library, add one more when configuring gd2 --with- Xpm=/usr/lib. 

But the configuration will prompt to find the xpm library, here I found a solution online, create a soft connection file under /usr/lib to the real xpm library file, as follows:

ln -s /usr/lib/(x86_64 or i386 ) /libXpm.a /usr/lib/libXpm.a ln -s /usr/lib/(x86_64 or i386 ) /libXpm.so /usr/lib/libXpm.so ln -s /usr/lib/(x86_64 or i386 ) /libXpm.so.4 /usr/lib/libXpm.so.4 ln -s /usr/lib/(x86_64 or i386 ) /libXpm.so.4.11 /usr/lib/libXpm.so.4.11

After the operation is complete, you can re-install the gd2 library, the configuration is completed successfully:


will find "Support for Xpm library : yes" this item, explain the configuration Success, then make && make install to complete the installation of the gd2 library.

After installing all the library files, you can configure the php installation. Since the configuration was successful before, the compilation error occurred. Therefore, you need to add --with-xpm-dir=/usr/lib/to this configuration. Can compile successfully. The complete configuration is as follows:

 ./configure \\ --prefix=/usr/local/php5.5 \\ --with-libxml-dir=/usr/local/libxml2/\\ --with-png-dir =/usr/local/libpng/\\ --with-freetype-dir=/usr/local/freetype/\\ --with-gd=/usr/local/gd2/\\ --with-zlib-dir=/usr/Local/zlib/\\ --with-mcrypt=/usr/local/libmcrypt/\\ --with-xpm-dir=/usr/lib/\\ --with-mysql \\ --with-mysqli \\ --enable-pdo \\ --with-pdo-mysql \\ --with-iconv \\ --enable-soap \\ --enable-mbstring=all \\ --enable-sockets \\ --enable-fpm After configure and make, make install, Can complete the php installation. Then use 
sudo /usr/loca/php5.5/sbin/php-fpm to open the php-fpm service. You can add this command to the /etc/rc.local file as a self-starting service. 

Adding support for php to the nginx configuration file can be developed using php.

2, install memcache and error handling

memcache is divided into server-side and php extensions, server-side use memcached, complete all kinds of data storage and delete management, php extension is php use An extension of memcache, represented by memcache, is used to call and access the system's memcache service, using new Memcache directly in php.

(1) First need to install the server, this can be used directly by default installation of ubuntu:

sudo apt-get install memcached

After installing the Memcache server, use the following command to start Service:

memcached -d -m 128 -p 11111 -u Startup parameter description of rootmemcached service: 
-p <num> TCP listening port, default is 11211-l <addr> IP address, default is native -d start memcached service -d restart restart memcached service -d stop|
 Shutdown Shut down the running memcached service -d install Install the memcached service -d uninstall Uninstall the memcached service -u <username> Run identity (only valid when running as root) -m <num> Maximum memory usage, in megabytes. The default 64MB-M memory returns an error, instead of deleting the item -c <num> maximum number of simultaneous connections, the default is 1024-C. It is forbidden to use CAS-P <file> to set the file name saved by PID, only and - The d option calls -f <factor> block size growth factor, the default is 1.25-n minimum allocation space, key+value+flags defaults to 48-t <num> the number of threads used, the default is 4-b setting backup The size of the log queue. The default is 1024-R. Set the maximum number of requests per event. The default is 20-h. Display Help 

You can check whether the memcached server is enabled from the following figure:


You can see port 11211 to be in the LISTEN state, indicating that the memcached server is already open.

(2) Install memcache client

This installation is actually based on the php has been installed, to install a new extension to php, similar to a php without a socket installation The principle of reinstalling a socket extension without uninstalling php is similar.

First of all, you can use the pecl installer that comes with php:

/usr/local/php5.5/bin/pecl install memcache. You can also use the following command to download the source package and extract it: 
wget http://pecl.php.net/get/memcache-2.2.6.tgz But the problem I am having is that no matter which method is used, the final result is to use phpize tool to generate configuration for memcache. File, and this requires autoconf this library, from the configuration of the previous installation php can be seen, I have installed the autoconf library, so I use the above two methods to install will report the same error: 

Similarly, when I use the source code When the package is installed, after entering the memcache source package, you need to use the /usr/local/php5.5/bin/phpize tool to generate the configure file, which will report the same error as the above figure. It can also be explained from the above that the above two installation methods are the same and the principle is the same.

Copyright © Windows knowledge All Rights Reserved