centos源码安装php、nginx

lzihua 9年前

来自: http://my.oschina.net/u/232595/blog/607486


 wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz   tar zxf libiconv-1.14.tar.gz   cd libiconv-1.14   ./configure --prefix=/usr/local/lib/libiconv   make && make install         wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz   cd libmcrypt-2.5.7    ./configure --prefix=/usr/local/lib/libmcrypt   make && make install      wget http://cn2.php.net/distributions/php-7.0.2.tar.gz   tar -zxvf php-7.0.2.tar.gz   cd php-7.0.2   ./configure --prefix=/usr/local/php --enable-fpm \  --with-config-file-path=/usr/local/php/etc --with-openssl --with-zlib --enable-bcmath --with-bz2 --with-curl \  --enable-ftp --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-gettext --with-mhash \  --enable-mbstring --with-mcrypt=/usr/local/lib/libmcrypt --enable-soap --enable-zip --with-iconv=/usr/local/lib/libiconv --enable-mysqlnd \  --with-mysqli=mysqlnd \  --with-pdo-mysql=mysqlnd --without-pear   make && make install      php -i(测试)      cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm   vi /usr/local/php/etc/php-fpm.conf
[global]  pid = /usr/local/php/var/run/php-fpm.pid  error_log = /usr/local/php/var/log/php-fpm.log  log_level = notice  [www]  listen = /tmp/php-cgi.sock  listen.backlog = -1  listen.allowed_clients = 127.0.0.1  listen.owner = www  listen.group = www  listen.mode = 0666  user = www  group = www  pm = dynamic  pm.max_children = 196  pm.start_servers = 147  pm.min_spare_servers = 98  pm.max_spare_servers = 196  request_terminate_timeout = 100  request_slowlog_timeout = 0  slowlog = /usr/local/php/var/log/slow.log
chkconfig --add php-fpm  chkconfig php-fpm on    wget tar -zxvf pcre-8.38.tar.gz  cd pcre-8.38  ./configure --prefix=/usr/local/pcre --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre  make && make install  wget    tar -zxvf nginx-1.8.0.tar.gz  cd nginx-1.8.0  ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx \  --conf-path=/usr/local/nginx/conf/nginx.conf \  --error-log-path=/home/wwwlogs/error.log \  --http-log-path=/home/wwwlogs/access.log \  --pid-path=/var/run/nginx.pid \  --lock-path=/var/run/nginx.lock \  --user=nginx \  --group=nginx \  --with-http_ssl_module \  --with-http_realip_module \  --with-http_addition_module \  --with-http_sub_module \  --with-http_dav_module \  --with-http_flv_module \  --with-http_mp4_module \  --with-http_gunzip_module \  --with-http_gzip_static_module \  --with-http_random_index_module \  --with-http_secure_link_module \  --with-http_stub_status_module \  --with-http_auth_request_module \  --with-mail \  --with-mail_ssl_module \  --with-file-aio \  --with-http_spdy_module \  --with-ipv6 \  --with-threads \  --with-pcre=../pcre-8.38(pcre源码路径)  make && make install  groupadd -f nginx  adduser -M -r -g nginx nginx    vi /usr/local/nginx/conf/nginx.conf
user  www www;    worker_processes auto;    error_log  /home/wwwlogs/nginx_error.log  crit;    pid        /dev/shm/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;          multi_accept on;      }    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 50m;            sendfile   on;          tcp_nopush on;            keepalive_timeout 60;            tcp_nodelay 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;            gzip on;          gzip_min_length  1k;          gzip_buffers     4 16k;          gzip_http_version 1.1;          gzip_comp_level 2;          gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;          gzip_vary on;          gzip_proxied   expired no-cache no-store private auth;          gzip_disable   "MSIE [1-6]\.";            #limit_conn_zone $binary_remote_addr zone=perip:10m;          ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.            server_tokens off;          #log format          log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '               '$status $body_bytes_sent "$http_referer" '                               access_log off;    server      {          listen 80;          server_name _;          index index.html index.htm index.php;          root /home/wwwroot/;      location / {                          if (!-e $request_filename) {                                  rewrite  ^/(.*)$  /index.php/$1  last;                                  break;                          }                  }                    location ~ .+\.php($|/) {                           set $script    $uri;                           set $path_info  "/";                           if ($uri ~ "^(.+\.php)(/.+)") {                                   set $script     $1;                                   set $path_info  $2;                            }                             fastcgi_pass unix:/tmp/php-cgi.sock;                           fastcgi_index  index.php;                           include fastcgi_params;                           fastcgi_param PATH_INFO $fastcgi_script_name;                           fastcgi_param SCRIPT_FILENAME  /home/wwwroot/$script;                           fastcgi_param SCRIPT_NAME $script;                  }                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$          {              expires      30d;          }            location ~ .*\.(js|css)?$          {              expires      12h;          }            location ~ /\.          {              deny all;          }                access_log  /home/wwwlogs/access.log  access;      }  include vhost/*.conf;  }

自己安装一遍可能有错,希望多指点~~