1.检查cenos6的依赖包:
yum install -y ImageMagick ImageMagick-devel nginx ImageMagick ImageMagick-devel cmake
yum install -y libmcrypt-devel libmcrypt libiconv ImageMagick ImageMagick-devel libxml2-python libcurl libcurl-devel libpng libpng-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
yum install -y libjpeg-turbo libjpeg-turbo-devel openjpeg-libs mysql-devel fontconfig fontconfig-devel libcollection mcollective-common mcollective gd gd-devel
yum install -y libtool-ltdl libtool-ltdl-devel
yum -y install gcc gcc-c++ glibc automake autoconf libtool make
2.php编译安装
#下载:http://cn2.php.net/get/php-5.6.19.tar.gz/from/this/mirror
#编译:./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli--with-gd --with-freetype-dir=/usr/local/freetype --with-iconv-dir=/usr/local/iconv
#问题:
vi Makefile 找到下面这行:EXTRA_LIBS = -lcrypt ... 在最后添加-liconv 保存后make通过;make install通过。
3.php配置文件
cd /usr/local/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
vi etc/php-fpm.conf
主要修改user/group/error-log/pid 等参数
扩展包:/usr/local/php/bin/phpize (ImageMagick 等等)
4.php启动等操作
#测试php-fpm配置
/usr/local/php/sbin/php-fpm -t
/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf -t
#启动php-fpm
/usr/local/php/sbin/php-fpm
/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf
#关闭php-fpm
kill -INT `cat /usr/local/php/var/run/php-fpm.pid`
#重启php-fpm
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
5.nginx相关配置
#检查依赖包
make: yum -y install gcc automake autoconf libtool make
g++: yum install gcc gcc-c++
pcre: wget https://sourceforge.net/projects/pcre/files/pcre/8.38/pcre-8.38.tar.gz --no-check-certificate
./configure && make && make install
zlib: wget http://zlib.net/zlib-1.2.8.tar.gz
./configure && make && make install
openssl: wget http://openssl.skazkaforyou.com/source/openssl-1.0.2g.tar.gz
./config && make && make install#nginx安装
wget http://nginx.org/download/nginx-1.8.1.tar.gz
./configure --prefix=/usr/local/nginx
--with-pcre=/home/zhaolei/soft/src/pcre-8.38
--with-zlib=/home/zhaolei/soft/src/zlib-1.2.8
--with-openssl=/home/zhaolei/soft/src/openssl-1.0.2g
{
user www www;
worker_processes 8;
error_log /data/logs/nginx/error.log;
pid /var/run/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
#include proxy.conf;
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 300m;
#client_max_body_size 32m;
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
tcp_nodelay on;
#ssi on;
#ssi_silent_errors on;
#ssi_types text/shtml;
fastcgi_connect_timeout 180;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 2k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_x_forwarded_for" "$http_user_agent"';
#upstream backend {
# server 127.0.0.1:9000 weight=5 max_fails=3 fail_timeout=30s;
#}
include conf.d/*;
}
cms.conf
server {
listen 80;
server_name localhost;
access_log /data/logs/nginx/example.access.log main;
error_log /data/logs/nginx/example.error.log;
index index.php index.html index.shtml;
#rewrite ^/(.*) http://weihu.site.com/100806a_web-nopage.html last;
root /data/site/htdocs/cms;
if ($request_uri ~ " ") {
return 444;
}
location ~ .*\.svn\/.* { return 405; }
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
#location ~ \.php {
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /data/ifengsite/htdocs/$fastcgi_script_name;
# include fastcgi_params;
# include mcgi_params;
#}
#location / {
# proxy_pass http://backend;
# include proxy.conf;
#}
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
location ~* \.(html|shtml|htm|inc|log)$ {
expires 1m;
}
location ~* \.(css|js)$ {
expires 1m;
}
location ~* ^.+\.(jpg|jpeg|gif|swf|mpeg|mpg|mov|flv|asf|wmv|avi|ico)$ {
expires 15d;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# HTTPS server
#
#server {
# listen 443;
# server_name example.ifeng.com;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
6.参考文章:
http://www.cnblogs.com/zhuhongbao/archive/2013/06/04/3118061.html
http://www.cnblogs.com/argb/p/3604340.html