1 安装依赖:
yum install -y gcc gcc-* libxml2 libxml2-devel openssl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel mcrypt mhash gd gd-* autoconf libtool make mysql mysql-* libcurl libcurl-* curl curl-*
2 提供压缩包
freetype-2.1.9.tar.gz jpegsrc.v8b.tar.gz libmcrypt-2.5.8.tar.gz mcrypt-2.6.8.tar.gz nginx-1.12.2.tar.gz
ngx_http_substitutions_filter_module-master.zip pcre-8.39.zip php-5.6.32.tar.gz gd-2.0.33.tar.gz libiconv-1.14.tar.gz libpng-1.2.7-config.tar.gz
mhash-0.9.9.9.tar.gz nginx-http-concat-master.zip openssl-1.1.0.tar.gz php-5.5.38.tar.gz zlib-1.2.8.tar.gz
3 a安装压缩包
cd /export1/soft
for i in `ls| grep gz`;do tar zxvf $i; done&&for i in `ls| grep zip`;do unzip $i; done
4 安装 nginx
4.1 安装 pcre-8.39.zip zlib-1.2.8
cd /export1/soft/pcre-8.39 && ./configure && make && make install
cd /export1/soft/zlib-1.2.8 && ./configure && make && make install
4.2 安装 nginx
cd /export1/soft/nginx-1.12.2
./configure --prefix=/export1/webroot/nginx --with-cc-opt=-DFD_SETSIZE=4096 --with-pcre=/export1/soft/pcre-8.39 --with-zlib=/export1/soft/zlib-1.2.8 --with-openssl=/export1/soft/openssl-1.1.0 --with-http_gzip_static_module --with-http_ssl_module --with-http_addition_module --with-http_auth_request_module --with-http_flv_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-mail --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-mail_ssl_module --with-ipv6 --with-select_module --with-http_perl_module --with-http_realip_module --with-http_image_filter_module --add-module=/export1/soft/nginx-http-concat-master --add-module=/export1/soft/ngx_http_substitutions_filter_module-master
make&&make install
5 安装php5.6
5.1 安装依赖
freetype (){
???????cd /export1/soft/freetype-2.1.9&&./configure&&make&&make install
???????sleep 5
}
jpeg () {
???????cd /export1/soft/jpeg-8b&&./configure&&make&&make install
???????sleep 5
}
libpng () {
???????cd /export1/soft/libpng-1.2.7-config&&./configure&&make&&make install
???????sleep 5
}
libiconv () {
???????cd /export1/soft/libiconv-1.14&&./configure&&make&&make install
???????sleep 5
}
gd (){
???????cd /export1/soft/gd-2.0.33&&./configure&&make&&make install
???????sleep 5
}
libmcrypt (){
???????cd /export1/soft/libmcrypt-2.5.8&&./configure&&make&&make install
???????sleep 5
???????/sbin/ldconfig
???????cd /export1/soft/libmcrypt-2.5.8libltdl&&./configure --enable-ltdl-install&&make&&make install
???????sleep 5
}
mhash (){
???????cd /export1/soft/mhash-0.9.9.9&&./configure&&make&&make install
???????sleep 5
}
mcrypt (){
???????export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
???????cd /export1/soft/mcrypt-2.6.8&&./configure&&make&&make install
???????ldconfig
???????sleep 5
}
freetype
jpeg
libpng
libiconv
gd
libmcrypt
mhash
mcrypt
5.2 安装php
cd /export1/soft/php-5.6.32
./configure --prefix=/export1/webroot/php --with-config-file-path=/export1/webroot/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-gd --with-openssl --with-mhash --enable-mysqlnd --enable-sockets --with-zlib --with-curl --enable-mbstring=all --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-discard-path --enable-safe-mode --enable-fastcgi --enable-fpm --enable-mbstring --with-mcrypt --enable-gd-native-ttf --enable-pcntl --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --enable-ftp --enable-json --with-jpeg-dir --with-png-dir --with-freetype-dir --with-libxml-dir --with-xpm-dir --enable-force-cgi-redirect --enable-mbregex
make ZEND_EXTRA_LIBS=‘-liconv‘&&make install
############################################################
6 测试
6.1 修改 php配置文件
cp /export1/soft/php-5.6.32/php.ini-development /export1/webroot/php/etc/php.ini
cp /export1/webroot/php/etc/php-fpm.conf.default /export1/webroot/php/etc/php-fpm.conf
6.2 修改 nginx 配置文件
useradd www
mkdir /export1/webroot/nginx/tmp/
###################################
vim /export1/webroot/nginx/conf/nginx.conf
user www www; 用户
worker_processes 8; # cpu 个数
worker_cpu_affinity ?00000001 00000010 00000011 00000100 00000101 00000110 00001000 00001001; # cpu个数 进程数
events {
???????use epoll;
???????worker_connections 65535;
}
http {
???????include ??????mime.types;
???????default_type ?application/octet-stream;
???????server_names_hash_bucket_size 128;
???????client_header_buffer_size 32k;
???????large_client_header_buffers 4 32k;
???????client_max_body_size 80m;
???????sendfile on;
???????tcp_nopush ????on;
???????ssi on;
???????ssi_silent_errors on;
???????ssi_types text/shtml;
???????keepalive_timeout 60;
???????tcp_nodelay on;
???????fastcgi_cache_path /export1/webroot/nginx/tmp/fastcgi_cache levels=1:2
???????keys_zone=TEST:10m
???????inactive=5m;
???????fastcgi_intercept_errors on;
???????fastcgi_connect_timeout 300;
???????fastcgi_send_timeout 300;
???????fastcgi_read_timeout 300;
???????fastcgi_buffer_size 64k;
???????fastcgi_buffers 4 64k;
???????fastcgi_busy_buffers_size 128k;
???????fastcgi_temp_file_write_size 256k;
???????fastcgi_cache_valid 200 302 1h;
???????fastcgi_cache_valid 301 1d;
???????fastcgi_cache_valid any 1m;
???????fastcgi_cache_min_uses 1;
???????fastcgi_cache_use_stale error timeout invalid_header http_500;
???????open_file_cache max=65535 inactive=20s;
???????open_file_cache_min_uses 1;
???????open_file_cache_valid 30s;
???????gzip on;
???????gzip_min_length ?1k;
???????gzip_buffers ????4 16k;
???????gzip_http_version 1.0;
???????gzip_comp_level 2;
???????gzip_types ??????text/plain application/x-javascript text/css application/xml;
???????gzip_vary on;
???????gzip_proxied ???????expired no-cache no-store private auth;
???????gzip_disable ???????"MSIE [1-6]\.";
???????gzip_static on;
???????server_tokens off;
???????log_format ?access ?‘$remote_addr - $remote_user [$time_local] $http_host $request_method "$uri" "$query_string" ‘
?????????????????‘$status $body_bytes_sent "$http_referer" $upstream_status $upstream_addr $request_time $upstream_response_time ‘
?????????????????‘"$http_user_agent" "$http_x_forwarded_for"‘
??????????????????‘"$http_Client"‘;
server {
???????listen ??????80;
???????server_name localhost
???????index index.html index.htm index.php;
???????root ?/export1/www/;
???????error_page 404 ?/404.html;
location ~ \.php {
???????????????try_files $uri =404;
???????????????fastcgi_pass ?127.0.0.1:9000;
???????????????fastcgi_index index.php;
???????????????include fastcgi.conf;
???????????????set $path_info "";
???????????????set $real_script_name $fastcgi_script_name;
???????????????if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
???????????????????????????????set $real_script_name $1;
???????????????????????????????set $path_info $2;
???????????????}
???????????????fastcgi_param SCRIPT_FILENAME
???????????????$document_root$real_script_name;
???????????????fastcgi_param SCRIPT_NAME $real_script_name;
???????????????fastcgi_param PATH_INFO $path_info;
???????????????????????}
location ~ /\.ht {
???????deny all;
?????????????????}
###### 开启nginx 监控
location /ngx_status {
???????stub_status on;
???????access_log off;
???????????????????}
#########开启php监控
location /status {
???????fastcgi_param ?SCRIPT_FILENAME ?$document_root$fastcgi_script_name;
???????include ???????fastcgi_params;
???????fastcgi_pass ??127.0.0.1:9000;
???????????????}
???????
location / {
???????index index.html index.htm index.php;
???????????}
????}
???????access_log ?/export1/www/wap.log access ;
???????error_log ?/export1/www/wap-error.log;
???}
mkdir /export1/www/source
chown www.www -R /export1/www/source
###########################################################################################################################################
6.2 php-fpm 服务化
vim /etc/init.d/php-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides: ?????????php-fpm
# Required-Start: ???$remote_fs $network
# Required-Stop: ????$remote_fs $network
# Default-Start: ????2 3 4 5
# Default-Stop: ?????0 1 6
# Short-Description: starts php-fpm
# Description: ??????starts the PHP FastCGI Process Manager daemon
### END INIT INFO
prefix=/usr
exec_prefix=/usr
php_fpm_BIN=/export1/webroot/php/sbin/php-fpm
php_fpm_CONF=/export1/webroot/php/etc/php-fpm.conf
php_fpm_PID=/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"
wait_for_pid () {
???????try=0
???????while test $try -lt 35 ; do
???????????????case "$1" in
???????????????????????‘created‘)
???????????????????????if [ -f "$2" ] ; then
???????????????????????????????try=‘‘
???????????????????????????????break
???????????????????????fi
???????????????????????;;
???????????????????????‘removed‘)
???????????????????????if [ ! -f "$2" ] ; then
???????????????????????????????try=‘‘
???????????????????????????????break
???????????????????????fi
???????????????????????;;
???????????????esac
???????????????echo -n .
???????????????try=`expr $try + 1`
???????????????sleep 1
???????done
}
case "$1" in
???????start)
???????????????echo -n "Starting php-fpm "
???????????????$php_fpm_BIN $php_opts
???????????????if [ "$?" != 0 ] ; then
???????????????????????echo " failed"
???????????????????????exit 1
???????????????fi
???????????????wait_for_pid created $php_fpm_PID
???????????????if [ -n "$try" ] ; then
???????????????????????echo " failed"
???????????????????????exit 1
???????????????else
???????????????????????echo " done"
???????????????fi
???????;;
???????stop)
???????????????echo -n "Gracefully shutting down php-fpm "
???????????????if [ ! -r $php_fpm_PID ] ; then
???????????????????????echo "warning, no pid file found - php-fpm is not running ?"
???????????????????????exit 1
???????????????fi
???????????????kill -QUIT `cat $php_fpm_PID`
???????????????wait_for_pid removed $php_fpm_PID
???????????????if [ -n "$try" ] ; then
???????????????????????echo " failed. Use force-quit"
???????????????????????exit 1
???????????????else
???????????????????????echo " done"
???????????????fi
???????;;
???????force-quit)
???????????????echo -n "Terminating php-fpm "
???????????????if [ ! -r $php_fpm_PID ] ; then
???????????????????????echo "warning, no pid file found - php-fpm is not running ?"
???????????????????????exit 1
???????????????fi
???????????????kill -TERM `cat $php_fpm_PID`
???????????????wait_for_pid removed $php_fpm_PID
???????????????if [ -n "$try" ] ; then
???????????????????????echo " failed"
???????????????????????exit 1
???????????????else
???????????????????????echo " done"
???????????????fi
???????;;
???????restart)
???????????????$0 stop
???????????????$0 start
???????;;
???????reload)
???????????????echo -n "Reload service php-fpm "
???????????????if [ ! -r $php_fpm_PID ] ; then
???????????????????????echo "warning, no pid file found - php-fpm is not running ?"
???????????????????????exit 1
???????????????fi
???????????????kill -USR2 `cat $php_fpm_PID`
???????????????echo " done"
???????;;
???????*)
???????????????echo "Usage: $0 {start|stop|force-quit|restart|reload}"
???????????????exit 1
???????;;
esac
###################################################
chmod +x /etc/init.d/php-fpm
###################################################
6.3 修改 vim /export1/webroot/php/etc/php-fpm.conf
pid = /var/run/php-fpm.pid
pm.status_path = /status
user = www
group = www
################################################
service php-fpm start
##############################################
6.5 优化php-fpm
http://www.cnblogs.com/qtxdy/p/7770756.html
############################################
7 动态添加模块:
cd /export1/soft/php-5.6.32/ext/pdo_mysql
/export1/webroot/php/bin/phpize
./configure --with-php-config=/export1/webroot/php/bin/php-config && make&& make install
vim /export1/webroot/php/etc/php.ini
extension_dir = "./"
extension_dir = "/export1/webroot/php/lib/php/extensions/no-debug-non-zts-20131226/"
extension = pdo_mysql.so
###########################################################################################################
centos6.6+nginx1.12+php5.6
原文地址:http://www.cnblogs.com/qtxdy/p/7767792.html