[TOC] ## 注意 nginx 与 php 配置的 user 与 group 必须一直 ## nginx ``` wget http://nginx.org/download/nginx-1.10.3.tar.gz tar -zxf nginx-1.10.3.tar.gz ./configure \ --prefix=/usr/local/nginx \ --conf-path=/usr/local/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/usr/local/nginx/nginx.pid \ --user=www \ --group=www \ --with-pcre \ --with-http_v2_module \ --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-ipv6 \ --with-http_v2_module \ --with-threads \ --with-stream \ --with-stream_ssl_module make && make install //添加 nginx 用户 useradd www ``` ## php 总体与 同目录下的 ` php / apache` 一直,只需在 编译是添加 `--anable-fpm` 点击跳转 [php / apache](php-apache%E7%BC%96%E8%AF%91.md) ``` ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-openssl --with-mysqli --with-pdo-mysql --enable-mbstring --with-zlib --enable-sockets --with-curl --with-pcre-regex --with-mcrypt=/usr/local/libmcrypt --with-gd --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-opcache '--enable-fpm' '--disable-maintainer-zts' ``` > 一般 php 为 线程安全则 扩展目录为`no-debug-zts-20131226` > 非线程安全则为`no-debug-no-zts-20131226` ### 启动 php-fpm ``` /usr/local/php/sbin/php-fpm ``` ## 配置 nginx /usr/local/nginx/nginx.conf ``` user www; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; server { listen 8002; server_name localhost; root /home/www/; // 若在 location 下配置,则 其他 location 都要指定一个 location / { index index.html index.htm; } error_page 500 502 503 504 /50x.html; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } } ``` ### 启动/重启/停止 ``` /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx -s reload /usr/local/nginx/sbin/nginx -s stop ```