centos 6.4+nginx1.6+php5.2.17的安装配置

由于sina博客不支持代码段显示,完整版文章请看

下载PHP

wget http://museum.php.net/php5/php-5.2.17.tar.bz2
下载fpm
wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
解压
tar -jxpf php-5.2.17.tar.bz2
给php打补丁
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
====================================
yum install gd-devel curl-devel libxml2-devel
ln -s /usr/lib64/libjpeg* /usr/lib
ln -s /usr/lib64/libpng* /usr/lib
==================================
cd php-5.2.17
./configure --prefix=/usr/local/php5.2 --with-config-file-path=/usr/local/php5.2/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-intl --enable-xml --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization  --with-curlwrappers --enable-mbregex  --enable-mbstring --with-mcrypt --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap  --with-pdo-mysql=/usr/local/mysql --with-openssl-dir --enable-sockets  --with-curl --with-gd  --enable-inline-optimization --enable-fastcgi --enable-fpm --enable-force-cgi-redirect
==================================
如果在make时出现
/usr/bin/ld: cannot find -lltdl
安装ltdl
yum install *ltdl-devel
=================================
配置fpm
vi /usr/local/php5.2/etc/php-fpm.conf
=================================
修改用户组和用户
======================================
启动fpm
ulimit -SHn 51200
/usr/local/php/sbin/php-fpm start
 #包括:start|stop|quit|restart|reload|logrotate
=======================================
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2/
./configure --user=webserver --group=webserver --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
=======================================
nginx配置文件
#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 5;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    server {
        listen       8080;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ /|\.php$ {
            index  index.html index.htm;
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}
启动nginx
/usr/local/nginx/sbin/nginx

发表评论

电子邮件地址不会被公开。 必填项已用*标注