{"id":5731,"date":"2017-03-31T16:27:37","date_gmt":"2017-03-31T08:27:37","guid":{"rendered":"https:\/\/sdeno.com\/?p=5731"},"modified":"2020-02-28T11:12:36","modified_gmt":"2020-02-28T03:12:36","slug":"centos-6-x%e6%89%8b%e5%8a%a8%e5%ae%89%e8%a3%85%e7%bc%96%e8%af%91nginx","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=5731","title":{"rendered":"centos 6.x\u624b\u52a8\u5b89\u88c5\u7f16\u8bd1nginx"},"content":{"rendered":"<p>centos\u5b89\u88c5nginx<\/p>\n<p>1\uff0c\u4e0b\u8f7dnginx<br \/>\nhttp:\/\/nginx.org\/download\/nginx-1.11.12.tar.gz<br \/>\nhttp:\/\/nginx.org\/en\/download.html<\/p>\n<p>&nbsp;<\/p>\n<p>2\uff0c\u5b89\u88c5Nginx\u6240\u4f9d\u8d56\u7684\u5305\uff1a<\/p>\n<p>gcc -v \u00a0 \/\/\u67e5\u770b\u7cfb\u7edf\u662f\u5426\u5b89\u88c5gcc<\/p>\n<p>rpm -qa | grep pcre \u00a0\u6216\u8005 pcre-config &#8211;version\u00a0 \/\/\u662f\u5426\u5b89\u88c5pcre<\/p>\n<p>rpm -qa | grep zlib\u00a0\/\/\u662f\u5426\u5b89\u88c5zlib<\/p>\n<p>openssl version \u00a0 \u6216\u8005 \u00a0openssl version -a \u00a0\/\/\u662f\u5426\u5b89\u88c5 \u00a0\uff08\u6700\u4f4e\u8981\u6c421.0.2\uff09<\/p>\n<pre>wget https:\/\/www.openssl.org\/source\/openssl-1.1.0e.tar.gz\r\ntar zxf openssl-1.1.0e.tar.gz<\/pre>\n<p>\uff08\u4e00\u822c\u60c5\u51b5\u4e0b\u7cfb\u7edf\u90fd\u4f1a\u5b89\u88c5\u7684\uff09<br \/>\nyum -y install pcre*<\/p>\n<p>yum -y install openssl*<\/p>\n<p>yum -y install zlib*<\/p>\n<p>&nbsp;<\/p>\n<p>3\uff0c\u5207\u6362\u5230\u4e0b\u8f7d\u597d\u7684\u538b\u7f29\u5305\u6240\u5728\u76ee\u5f55<br \/>\n\u4f8b\u5982\uff1atar -zxvf nginx-1.11.12.tar.gz<\/p>\n<p>&nbsp;<\/p>\n<p>4\uff0c\u67e5\u770bopenssl\u5b89\u88c5\u76ee\u5f55<br \/>\n\u4e00\u822c\u5728\u76ee\u5f55\uff1a<br \/>\n\/usr\/local\/ssl<br \/>\n\/usr\/local\/openssl<br \/>\n\/usr\/local\/lib64 \uff08\u6211\u7684\u5728\uff09<\/p>\n<p>\u5982\u679c\u4f60\u662f\u7528rpm\u5b89\u88c5\u7684<br \/>\n\u53ef\u4ee5\u7528\u547d\u4ee4<br \/>\nrpm -ql openssl<\/p>\n<p>&nbsp;<\/p>\n<p>5\uff0c\u8fdb\u5165\u5230\u89e3\u538b\u597d\u7684nginx\u76ee\u5f55\u91cc\u9762<\/p>\n<p>\u5173\u95ed\u9632\u706b\u5899\uff1aservice iptables stop<br \/>\n\u6267\u884c\uff1a<\/p>\n<pre>.\/configure --prefix=\/etc\/nginx\u00a0--conf-path=\/etc\/nginx\/nginx.conf --with-openssl=\/usr\/lib64\/openssl --with-http_stub_status_module --with-debug --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_v2_module<\/pre>\n<p>\u522b\u4eba\u7684\u5b89\u88c5\u53c2\u6570\uff1a<\/p>\n<pre>--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2'\r\n--with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now'\r\n--prefix=\/usr\/share\/nginx\r\n--conf-path=\/etc\/nginx\/nginx.conf\r\n--http-log-path=\/var\/log\/nginx\/access.log\r\n--error-log-path=\/var\/log\/nginx\/error.log\r\n--lock-path=\/var\/lock\/nginx.lock\r\n--pid-path=\/run\/nginx.pid\r\n--http-client-body-temp-path=\/var\/lib\/nginx\/body\r\n--http-fastcgi-temp-path=\/var\/lib\/nginx\/fastcgi\r\n--http-proxy-temp-path=\/var\/lib\/nginx\/proxy\r\n--http-scgi-temp-path=\/var\/lib\/nginx\/scgi\r\n--http-uwsgi-temp-path=\/var\/lib\/nginx\/uwsgi\r\n--with-debug\r\n--with-pcre-jit\r\n--with-ipv6\r\n--with-http_ssl_module\r\n--with-http_stub_status_module\r\n--with-http_realip_module\r\n--with-http_auth_request_module\r\n--with-http_addition_module\r\n--with-http_dav_module\r\n--with-http_geoip_module\r\n--with-http_gunzip_module\r\n--with-http_gzip_static_module\r\n--with-http_image_filter_module\r\n--with-http_v2_module\r\n--with-http_sub_module\r\n--with-http_xslt_module\r\n--with-stream\r\n--with-stream_ssl_module\r\n--with-mail\r\n--with-mail_ssl_module\r\n--with-threads<\/pre>\n<p>&nbsp;<\/p>\n<p>6\uff0c\u63a5\u7740\u7f16\u8bd1<br \/>\nmake &amp;&amp; make install<\/p>\n<p>&nbsp;<\/p>\n<p>7\uff0c\u542f\u52a8nginx<\/p>\n<p>cd \/usr\/local\/nginx\/sbin<br \/>\n\/usr\/local\/nginx\/sbin\/nginx -V \/\/\u67e5\u770b\u7248\u672c\u548c\u67e5\u770b\u5df2\u5b89\u88c5\u6a21\u5757<br \/>\n\u6267\u884c.\/nginx<br \/>\n\u542f\u52a8\uff1a.\/nginx<br \/>\n\u505c\u6b62\uff1a.\/nginx -s stop<br \/>\n\u91cd\u542f\uff1a.\/nginx -s reopen<br \/>\n\u6267\u884c.\/nginx -h \u53ef\u4ee5\u770b\u5230\u547d\u4ee4\u7684\u5e2e\u52a9\u4fe1\u606f<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\uff1a<br \/>\n\/nginx\/nginx\/conf\/nginx.conf<\/p>\n<p>&nbsp;<\/p>\n<p>8\uff0c\u52a0\u5165\u7cfb\u7edf\u6258\u7ba1\uff0c\u5229\u7528chkconfig\u63a7\u5236<\/p>\n<p>\/\/\u6267\u884c\u6587\u4ef6\u540d\u4e3a\uff1anginx<\/p>\n<p>\uff08\u6ce8\u610f\u8def\u5f84\uff09<\/p>\n<pre>#!\/bin\/bash\r\n# chkconfig: - 30 21\r\n# description: http service.\r\n# Source Function Library\r\n. \/etc\/init.d\/functions\r\n\r\n# Nginx Settings\r\nNGINX_SBIN=\"\/usr\/local\/nginx\/sbin\/nginx\"\r\nNGINX_CONF=\"\/usr\/local\/nginx\/conf\/nginx.conf\"\r\nNGINX_PID=\"\/usr\/local\/nginx\/logs\/nginx.pid\"\r\n\r\nRETVAL=0\r\nprog=\"Nginx\"\r\n\r\nstart() {\r\n echo -n $\"Starting $prog: \"\r\n mkdir -p \/dev\/shm\/nginx_temp\r\n daemon $NGINX_SBIN -c $NGINX_CONF\r\n RETVAL=$?\r\n echo\r\n return $RETVAL\r\n}\r\n\r\nstop() {\r\n echo -n $\"Stopping $prog: \"\r\n killproc -p $NGINX_PID $NGINX_SBIN -TERM\r\n rm -rf \/dev\/shm\/nginx_temp\r\n RETVAL=$?\r\n echo\r\n return $RETVAL\r\n}\r\n\r\nreload(){\r\n echo -n $\"Reloading $prog: \"\r\n killproc -p $NGINX_PID $NGINX_SBIN -HUP\r\n RETVAL=$?\r\n echo\r\n return $RETVAL\r\n}\r\n\r\nrestart(){\r\n stop\r\n start\r\n}\r\n\r\nconfigtest(){\r\n $NGINX_SBIN -c $NGINX_CONF -t\r\n return 0\r\n}\r\n\r\ncase \"$1\" in\r\n start)\r\n start\r\n ;;\r\n stop)\r\n stop\r\n ;;\r\n reload)\r\n reload\r\n ;;\r\n restart)\r\n restart\r\n ;;\r\n configtest)\r\n configtest\r\n ;;\r\n *)\r\n echo $\"Usage: $0 {start|stop|reload|restart|configtest}\"\r\n RETVAL=1\r\nesac\r\n\r\nexit $RETVAL<\/pre>\n<p>&nbsp;<\/p>\n<p>\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p>cp nginx\u00a0\/etc\/rc.d\/init.d\/<\/p>\n<p>chmod 755 \/etc\/init.d\/nginx<\/p>\n<p>chkconfig &#8211;level 2345 nginx on<\/p>\n<p>chkconfig &#8211;list\u00a0nginx \u00a0\/\/2345\u90fd\u662fon\u8868\u793a\u8bbe\u7f6e\u6210\u529f<\/p>\n<p>\u4e0b\u8f7d\uff1a\u00a0<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2017\/03\/nginx.zip\">nginx<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>nginx.conf \u00a0\/\/\u4e00\u4e9b\u5e38\u7528\u914d\u7f6e<\/p>\n<pre>\u00a0user root;\r\n#user nobody;\r\nworker_processes 1;\r\n\r\n#error_log logs\/error.log;\r\n#error_log logs\/error.log notice;\r\n#error_log logs\/error.log info;\r\n\r\n#pid logs\/nginx.pid;\r\n\r\n\r\nevents {\r\n worker_connections 1024;\r\n}\r\n\r\n\r\nhttp {\r\n proxy_cache_path \/var\/cache\/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;\r\n proxy_temp_path \/var\/tmp;\r\n include mime.types;\r\n default_type application\/octet-stream;\r\n sendfile on;\r\n keepalive_timeout 65;\r\n \r\n gzip on;\r\n gzip_comp_level 6;\r\n gzip_vary on;\r\n gzip_min_length 1000;\r\n gzip_proxied any;\r\n gzip_types text\/plain text\/css application\/json application\/x-javascript text\/xml application\/xml application\/xml+rss text\/javascript;\r\n gzip_buffers 16 8k;\r\n \r\n  ssl_certificate \/root\/www\/Nginx\/1_www.easynode.cn_bundle.crt;\r\n ssl_certificate_key \/root\/www\/Nginx\/2_www.easynode.cn.key;\r\n ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;\r\nssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK;\r\nssl_prefer_server_ciphers on;\r\n \r\n upstream silly_face_society_upstream {\r\n server 127.0.0.1:3000;\r\n #server 127.0.0.1:8887;\r\n keepalive 64;\r\n }\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n server {\r\n listen 80;\r\n listen 443 ssl;\r\n \r\n server_name www.easynode.cn;\r\n \r\n #error_page 502 \/errors\/502.html;\r\n \r\n if ($scheme = http) {\r\n return 301 https:\/\/$server_name$request_uri;\r\n }\r\n\r\n #location ~ ^\/(images\/|img\/|javascript\/|js\/|css\/|stylesheets\/|flash\/|media\/|static\/|robots.txt|humans.txt|favicon.ico) {\r\n #root \/root\/www\/easynode\/public;\r\n #access_log off;\r\n #expires max;\r\n #}\r\n \r\n location ~ .*\\.(woff|eot|svg|ttf|favicon.ico|gif|jpg|jpeg|png|bmp|swf)$\r\n {\r\n access_log off;\r\n log_not_found off;\r\n expires max;\r\n root \/root\/www\/easynode\/public; #\u91cd\u70b9\r\n }\r\n\r\n location ~ .*\\.(js|css)?$\r\n {\r\n access_log off;\r\n log_not_found off;\r\n expires max;\r\n root \/root\/www\/easynode\/public; #\u91cd\u70b9\r\n }\r\n\r\n\r\n\r\n\r\n\r\n #location \/errors {\r\n # internal;\r\n # alias \/usr\/local\/silly_face_society\/node\/public\/errors;\r\n #}\r\n \r\n location \/ {\r\n proxy_redirect off;\r\n proxy_set_header X-Real-IP $remote_addr;\r\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n proxy_set_header X-Forwarded-Proto $scheme;\r\n proxy_set_header Host $http_host;\r\n proxy_set_header X-NginX-Proxy true;\r\n proxy_set_header Connection \"\";\r\n proxy_http_version 1.1;\r\n proxy_cache one;\r\n proxy_cache_key sfs$request_uri$scheme;\r\n proxy_pass http:\/\/silly_face_society_upstream;\r\n }\r\n\r\n \r\n \r\n }\r\n\r\n\r\n\r\n\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>9\uff0c\u4e3anginx\u6dfb\u52a0\u989d\u5916\u6a21\u5757<\/p>\n<p>(1).\/nginx -V\u00a0 \/\/\u83b7\u53d6\u5230\u5f53\u524d\u7684\u53c2\u6570<\/p>\n<pre>\u4f8b\u5982\uff1a\r\n--prefix=\/etc\/nginx --conf-path=\/etc\/nginx\/nginx.conf --with-openssl=\/root\/openssl-1.1.0e --with-http_stub_status_module<\/pre>\n<p>(2)\u4f8b\u5982\u5b89\u88c5\u4e0b\u8f7dnginx-rtmp-module\u6a21\u5757\uff0c\u53bb\u4e0b\u8f7d\u8be5\u6a21\u5757\u89e3\u538b\u83b7\u53d6\u5230\u8be5\u6a21\u5757\u7684\u76ee\u5f55\u3002<\/p>\n<pre>\/root\/nginx-rtmp-module-master  \/\/\u89e3\u538b\u540e\u7684\u8def\u5f84<\/pre>\n<p>(3)\u5728nginx\u6839\u76ee\u5f55\u4e0b\u770b\u662f\u5426\u6709configure\u6587\u4ef6\uff0c\u6709\u53ef\u4ee5\u8fdb\u884c\u5b89\u88c5\uff0c\u8ffd\u52a0\u6a21\u5757\u5b89\u88c5<\/p>\n<pre>.\/configure --prefix=\/etc\/nginx --conf-path=\/etc\/nginx\/nginx.conf --with-openssl=\/root\/openssl-1.1.0e --with-http_stub_status_module <span style=\"color: #ff0000;\">--add-module=\/root\/nginx-rtmp-module-master\r\n<\/span>make \/\/\u5728\u63a5\u7740\u6267\u884c\uff0c\u5343\u4e07\u4e0d\u8981\u6267\u884cmake install<\/pre>\n<p>(4)\u5230sbin\u76ee\u5f55\u4e0b\u5907\u4efd\u4e00\u4e0b\u539f\u6765\u7684nginx\u6587\u4ef6\uff0c\u4f8b\u5982\u6539\u6210nginx_bak<\/p>\n<p>(5)\u5230objs\u76ee\u5f55\u4e0b\u628anginx\u590d\u5236\u5230sbin\u76ee\u5f55\u4e2d\u5373\u53ef\uff0c\u4e4b\u540e\u5230sbin\u76ee\u5f55\u6267\u884c.\/nginx -V\u770b\u770b\u662f\u5426\u8ffd\u52a0\u4e86\u5b89\u88c5\u7684\u6a21\u5757<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n","protected":false},"excerpt":{"rendered":"<p>centos\u5b89\u88c5nginx 1\uff0c\u4e0b\u8f7dnginx http:\/\/nginx.org\/download\/nginx [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-5731","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5731"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5731\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}