Linux下安装Nginx注意事项Nginx统一安装1.10.2版本1.安装编译工具和库文件yum-yinstallmakezlibzlib-develgcc-c++libtoolopensslopenssl-devel2.安装PCREcd/data/software/wgethttp://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gztarzxvfpcre-8.35.tar.gzcdpcre-8.35./configuremake&&makeinstallpcre-config--version3.安装Nginxcd/data/software/wget-O/data/software/nginx-1.10.2.tar.gzhttp://nginx.org/download/nginx-1.10.2.tar.gztar-zxvf/data/software/nginx-1.10.2。tar.gzcd/data/software/nginx-1.10.2./configure--prefix=/data/apps/nginx-main\--pid-path=/data/logs/nginx-main/nginx.pid\--锁定路径=/data/apps/nginx-main/nginx.lock\--error-log-path=/data/logs/nginx-main/error.log\--http-log-path=/data/logs/nginx-main/access.log\--http-client-body-temp-path=/data/temps/nginx-main/client_body_temp\--http-proxy-temp-path=/data/temps/nginx-main/proxy_temp\--http-fastcgi-temp-path=/data/temps/nginx-main/fastcgi_temp\--http-uwsgi-temp-path=/data/temps/nginx-main/uwsgi_temp\--http-scgi-temp-path=/data/temps/nginx-main/scgi_temp\--with-http_stub_status_module\--with-http_ssl_module\--with-http_realip_module\--with-pcre=/data/software/pcre-8.35makemakeinstall4.Nginx配置cd/data/apps/nginx-main/conf/vimnginx.confuserroot;worker_processes2;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;events{worker_connections1024;}http{includemime.types;default_type应用程序/八位字节流;#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'#'$status$body_bytes_sent"$http_referer"'#'"$http_user_agent""$http_x_forwarded_for"';log_formatmain'$remote_addr$host$remote_user[$time_local]"$request"''$status$body_bytes_sent"$http_referer"''"$http_user_agent""$http_x_forwarded_for""$request_time""$bytes_sent""$body_bytes_sent"';access_log/data/apps/nginx-main/access.logmain;#access_log日志/access.logmain;发送文件;#tcp_nopush上;#keepalive_timeout0;keepalive_timeout65;#gzip上;client_max_body_size100m;gzip上;上游manage_upstream{服务器127.0.0.1:8080;}服务器{听8888;服务器名称本地主机;#charsetkoi8-r;#access_log日志/host.access.logmain;位置/管理{proxy_passhttp://manage_upstream;proxy_set_header主机$host;proxy_set_headerX-Real-IP$proxy_protocol_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_headerX-Forwarded-Port$server_port;}位置/{根html;indexindex.htmlindex.htm;}#error_page404/404.html;#将服务器错误页面重定向到静态页面/50x.html#error_page500502503504/50x.html;location=/50x.html{根html;}#将PHP脚本代理到侦听127.0.0.1:80的Apache##location~\.php${#proxy_passhttp://127.0.0.1;#}#将PHP脚本传递给侦听127.0.0.1:9000的FastCGI服务器##location~\.php${#roothtml;#fastcgi_pass127.0.0.1:9000;#fastcgi_indexindex.php;#fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;#包含fastcgi_params;#}#如果是Apache,则拒绝访问.htaccess文件的文档根#与nginx的一致##location~/\.ht{#denyall;#}}#另一个混合使用基于IP、名称和端口的配置的虚拟主机##server{#listen8000;#听某个名字:8080;#server_namesomename别名another.alias;#位置/{#根html;#索引index.htmlindex.htm;#}#}#HTTPS服务器##server{#listen443ssl;#server_name本地主机;#ssl_certificatecert.pem;#ssl_certificate_keycert.key;#ssl_session_cache共享:SSL:1m;#ssl_session_timeout5m;#ssl_ciphersHIGH:!aNULL:!MD5;#ssl_prefer_server_ciphers开启;#位置/{#根html;#索引index.htmlindex.htm;#}#}}4.启动Nginx/data/apps/nginx-main/sbin/nginxmkdir-pv/data/temps/nginx-main/client_body_temp/data/apps/nginx-main/sbin/nginx-sreload重新加载配置
