环境
centos6
php5.6
nginx 1.8
防火墙均关闭
我在这里简单描述一下过程
#install nginx
yum -y install pcre pcre-devel openssl opensll-devel gcc* #only mini install centos6
adduser www
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make ; make install
#install php5.6
yum install -y zlib-devel fontconfig fontconfig-devel libXpm* libtool* libxml2 libxml2-devel curl curl-devel
./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
make ; make install
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
Change nginx configuration file support php
#There is only a change of content.
vim /usr/local/nginx/conf/nginx.conf
user www;
location ~ \.php$ {
root html;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
Change php-fpm configuration file(sock)
#There is only a change of content.
vim /usr/local/php/etc/php-fpm.conf
user = www
group = www
;listen = 127.0.0.1:9000
listen = /dev/shm/php-cgi.sock
/usr/local/php/sbin/php-fpm #start php-fpm chmod 777 /dev/shm/php-cgi.sock /usr/local/nginx/sbin/nginx #start nginx
test nginx and php
cat >> /usr/local/nginx/html/info.php << EOF <?php phpinfo(); ?> EOF
If the test page ok,php and nginx is good.
#=========================install memcache extension==================================
/usr/local/php/bin/pecl install memcache #auto install memcache module cd /usr/local/php/bin/php --ini #find php.ini file directory. my php.ini file directory is /usr/local/php/lib . or open test page info.php search "php.ini". echo "extension=memcache.so" >> /usr/local/php/lib/php.ini /usr/local/php/bin/php -m #see php load module
restart nginx php-fpm
killall nginx /usr/local/nginx/sbin/nginx ps -ef |grep php-fpm #mark PID kill -INT PID /usr/local/php/sbin/php-fpm
find memcache on test page or php -m
#===========================memcached===============================================
wget https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gz
wget http://pecl.php.net/get/memcached-2.2.0.tgz
./configure --prefix=/usr/local/libmemcached --with-memcached make ; make install cd memcached-2.2.0 /usr/local/php/bin/phpize ./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl make ; make install
ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
-rwxr-xr-x 1 root root 335433 1月 8 12:37 memcached.so
-rw-r--r-- 1 root root 259968 1月 8 11:32 memcache.so
-rwxr-xr-x 1 root root 1104016 1月 8 10:28 opcache.a
-rwxr-xr-x 1 root root 585616 1月 8 10:28 opcache.so
echo "extension=memcached.so" >> /usr/local/php/lib/php.ini
restart php nginx .don't forget chmod php-cgi.sock
author:V