{"id":6755,"date":"2017-06-03T18:05:22","date_gmt":"2017-06-03T10:05:22","guid":{"rendered":"http:\/\/rmohan.com\/?p=6755"},"modified":"2017-06-03T18:05:22","modified_gmt":"2017-06-03T10:05:22","slug":"red-hat-enterprise-linux-installation-at-7-3-nginx","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6755","title":{"rendered":"Red Hat Enterprise Linux installation at 7.3 Nginx"},"content":{"rendered":"<p><strong>Red Hat Enterprise Linux installation at 7.3 Nginx<\/strong><\/p>\n<p>I. Introduction<\/p>\n<p>Nginx ( &#8220;engine x&#8221;) is a by Russian designer Igor Sysoev procedures developed high-performance Web server and reverse proxy, also a IMAP \/ POP3 \/ SMTP proxy server. In the case of high concurrent connections, Nginx Apache server is a good substitute.<\/p>\n<p>Second, prepare<\/p>\n<p>1, environment<\/p>\n<p>Platform: Red Hat Enterprise Linux Server Release 7.3 (Maipo)<\/p>\n<p>3.10.0-514.el7.x86_64<\/p>\n<p>2, install build tools and libraries<\/p>\n<p>yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel<\/p>\n<p>3, install pcre<\/p>\n<p>PCRE role is to support Ngnix Rewrite function.<\/p>\n<p>Check whether the installation pcre<\/p>\n<p># pcre-config &#8211;version<\/p>\n<p>bove indicate that you have installed.<\/p>\n<p>If not installed, with reference to the following steps:<\/p>\n<p>1) Download<\/p>\n<p>https:\/\/sourceforge.net\/projects\/pcre\/files\/pcre\/<\/p>\n<p>2) extracting installation package:<br \/>\n# PCRE zxvf the tar-8.35.tar.gz<\/p>\n<p>3) compile and install<br \/>\n# cd pcre-8.35<\/p>\n<p># .\/configure<\/p>\n<p># make &#038;&#038; make install<\/p>\n<p>Third, the installation<\/p>\n<p>1, download the installation package nginx<\/p>\n<p>http:\/\/nginx.org\/download\/<\/p>\n<p>2, extract<\/p>\n<p># tar zxvf nginx-1.10.2.tar.gz<\/p>\n<p>3. Compile<\/p>\n<p># .\/configure &#8211;prefix=\/usr\/local\/nginx &#8211;with-http_stub_status_module &#8211;with-http_ssl_module &#8211;with-pcre<\/p>\n<p>4, installation<\/p>\n<p># make<\/p>\n<p># make install<\/p>\n<p>5, test<\/p>\n<p>View nginx version<\/p>\n<p># \/usr\/local\/nginx\/sbin\/nginx -v<\/p>\n<p>Displays version information, proof has been successfully installed<\/p>\n<p>Fourth, the configuration<\/p>\n<p>1. Create a user<\/p>\n<p>Nginx create run-use user ruready:<br \/>\n# \/ usr \/ sbin \/ groupadd ruready<br \/>\n# \/ usr \/ sbin \/ useradd -g ruready ruready<\/p>\n<p>2???nginx.conf<\/p>\n<p># vi \/usr\/local\/nginx\/conf\/nginx.conf<\/p>\n<p>user  ruready ruready;<br \/>\nworker_processes  2;<\/p>\n<p>error_log  \/usr\/local\/nginx\/logs\/error.log crit; # ?????????<br \/>\npid        \/usr\/local\/nginx\/logs\/nginx.pid;<\/p>\n<p>#Specifies the value for maximum file descriptors that can be opened by this process.<br \/>\nworker_rlimit_nofile 65535;<br \/>\nevents {<br \/>\n    use epoll;<br \/>\n    worker_connections  65535;<br \/>\n}<\/p>\n<p>http {<br \/>\n    include      mime.types;<br \/>\n    default_type  application\/octet-stream;<\/p>\n<p>    log_format  main  &#8216;$remote_addr &#8211; $remote_user [$time_local] &#8220;$request&#8221; &#8216;<br \/>\n                      &#8216;$status $body_bytes_sent &#8220;$http_referer&#8221; &#8216;<br \/>\n                      &#8216;&#8221;$http_user_agent&#8221; &#8220;$http_x_forwarded_for&#8221;&#8216;;<\/p>\n<p>    access_log  \/usr\/local\/nginx\/logs\/access.log  main;<\/p>\n<p>    sendfile        on;<br \/>\n    tcp_nopush    on;<\/p>\n<p>    keepalive_timeout  60;<\/p>\n<p>    gzip  on;<br \/>\n    gzip_min_length 1k;<br \/>\n    gzip_buffers 4 16k;<br \/>\n    gzip_http_version 1.0;<br \/>\n    gzip_comp_level 2;<br \/>\n    gzip_types text\/plain application\/x-javascript text\/css application\/xml;<br \/>\n    gzip_vary on;<\/p>\n<p>    # server<br \/>\n    server {<br \/>\n        listen      80;<br \/>\n        server_name  localhost;<\/p>\n<p>        charset utf-8;<\/p>\n<p>        access_log  \/usr\/local\/nginx\/logs\/host.access.log  main;<\/p>\n<p>        location \/ {<br \/>\n            root  html;<br \/>\n            index  index.html index.htm;<br \/>\n        }<\/p>\n<p>        error_page  404              \/404.html;<\/p>\n<p>        # redirect server error pages to the static page \/50x.html<\/p>\n<p>        error_page  500 502 503 504  \/50x.html;<br \/>\n        location = \/50x.html {<br \/>\n            root  html;<br \/>\n        }<\/p>\n<p>        # proxy the PHP scripts to Apache listening on 127.0.0.1:80<\/p>\n<p>        #location ~ \\.php$ {<br \/>\n        #    proxy_pass  http:\/\/127.0.0.1;<br \/>\n        #}<\/p>\n<p>        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<\/p>\n<p>        location ~ \\.php$ {<br \/>\n            root          html;<br \/>\n            fastcgi_pass  127.0.0.1:9000;<br \/>\n            fastcgi_index  index.php;<br \/>\n            fastcgi_param  SCRIPT_FILENAME  \/scripts$fastcgi_script_name;<br \/>\n            include        fastcgi_params;<br \/>\n        }<\/p>\n<p>        # deny access to .htaccess files, if Apache&#8217;s document root<br \/>\n        # concurs with nginx&#8217;s one<br \/>\n        #<br \/>\n        #location ~ \/\\.ht {<br \/>\n        #    deny  all;<br \/>\n        #}<br \/>\n    }<\/p>\n<p>    # another virtual host using mix of IP-, name-, and port-based configuration<br \/>\n    #<br \/>\n    #server {<br \/>\n    #    listen      8000;<br \/>\n    #    listen      somename:8080;<br \/>\n    #    server_name  somename  alias  another.alias;<\/p>\n<p>    #    location \/ {<br \/>\n    #        root  html;<br \/>\n    #        index  index.html index.htm;<br \/>\n    #    }<br \/>\n    #}<\/p>\n<p>    # HTTPS server<br \/>\n    #<br \/>\n    #server {<br \/>\n    #    listen      443 ssl;<br \/>\n    #    server_name  localhost;<\/p>\n<p>    #    ssl_certificate      cert.pem;<br \/>\n    #    ssl_certificate_key  cert.key;<\/p>\n<p>    #    ssl_session_cache    shared:SSL:1m;<br \/>\n    #    ssl_session_timeout  5m;<\/p>\n<p>    #    ssl_ciphers  HIGH:!aNULL:!MD5;<br \/>\n    #    ssl_prefer_server_ciphers  on;<\/p>\n<p>    #    location \/ {<br \/>\n    #        root  html;<br \/>\n    #        index  index.html index.htm;<br \/>\n    #    }<br \/>\n    #}<\/p>\n<p>}<\/p>\n<p>3, check the correctness of the configuration file ngnix.conf<\/p>\n<p># \/usr\/local\/nginx\/sbin\/nginx -t<\/p>\n<p>Fifth, start<\/p>\n<p>1, the start command<\/p>\n<p># \/usr\/local\/nginx\/sbin\/nginx<\/p>\n<p>3, can be tested through command links<\/p>\n<p>links 127.0.0.1:8080<\/p>\n<p>Six commonly used commands<\/p>\n<p>\/usr\/local\/nginx\/sbin\/nginx -c \/usr\/local\/nginx\/sbin\/nginx\/nginx.conf # ??????????<\/p>\n<p>\/ Usr \/ local \/ nginx \/ sbin \/ nginx -s reload # reload the configuration file<\/p>\n<p>\/usr\/local\/nginx\/sbin\/nginx -s reopen # ?? Nginx<\/p>\n<p>\/usr\/local\/nginx\/sbin\/nginx -s stop # ?? Nginx<\/p>\n<p>Seven other<\/p>\n<p>1, set the boot<\/p>\n<p>echo &#8220;\/usr\/local\/nginx\/sbin\/nginx -c \/usr\/local\/nginx\/conf\/nginx.conf&#8221; >> \/etc\/rc.local <\/p>\n<p>2, added to the service Service<\/p>\n<p>touch \/etc\/init.d\/nginx<\/p>\n<p>chmod 755 nginx \/\/ modify the script file permissions nginx<\/p>\n<p>chkconfig &#8211;add nginx \/\/ The script file is added in chkconfig<\/p>\n<p>chkconfig &#8211;level 35 nginx on \/\/ set nginx at startup in level 3 and 5 <\/p>\n<p>nginx document reads as follows:<\/p>\n<p>#!\/bin\/sh<br \/>\n#<br \/>\n# nginx &#8211; this script starts and stops the nginx daemon<br \/>\n#<br \/>\n# chkconfig: &#8211; 85 15<br \/>\n# description: Nginx is an HTTP(S) server, HTTP(S) reverse \\<br \/>\n#  proxy and IMAP\/POP3 proxy server<br \/>\n# processname: nginx<br \/>\n# config: \/etc\/nginx\/nginx.conf<br \/>\n# config: \/etc\/sysconfig\/nginx<br \/>\n# pidfile: \/var\/run\/nginx.pid<br \/>\n# Source function library.<br \/>\n. \/etc\/rc.d\/init.d\/functions<br \/>\n# Source networking configuration.<br \/>\n. \/etc\/sysconfig\/network<br \/>\n# Check that networking is up.<br \/>\n[ &#8220;$NETWORKING&#8221; = &#8220;no&#8221; ] &#038;&#038; exit 0<br \/>\n    nginx=&#8221;\/usr\/local\/nginx\/sbin\/nginx&#8221;<br \/>\n    prog=$(basename $nginx)<br \/>\n    NGINX_CONF_FILE=&#8221;\/usr\/local\/nginx\/conf\/nginx.conf&#8221;<br \/>\n[ -f \/etc\/sysconfig\/nginx ] &#038;&#038; . \/etc\/sysconfig\/nginx<br \/>\n    lockfile=\/var\/lock\/subsys\/nginx <\/p>\n<p>start() {<br \/>\n    [ -x $nginx ] || exit 5<br \/>\n    [ -f $NGINX_CONF_FILE ] || exit 6<br \/>\n    echo -n $&#8221;Starting $prog: &#8221;<br \/>\n    daemon $nginx -c $NGINX_CONF_FILE<br \/>\n    retval=$?<br \/>\n    echo<br \/>\n[ $retval -eq 0 ] &#038;&#038; touch $lockfile<br \/>\n    return $retval<br \/>\n} <\/p>\n<p>stop() {<br \/>\n    echo -n $&#8221;Stopping $prog: &#8221;<br \/>\n    killproc $prog -QUIT<br \/>\n    retval=$?<br \/>\n    echo<br \/>\n[ $retval -eq 0 ] &#038;&#038; rm -f $lockfile<br \/>\n    return $retval<br \/>\n    killall -9 nginx<br \/>\n} <\/p>\n<p>restart() {<br \/>\n    configtest || return $?<br \/>\n    stop<br \/>\n    sleep 1<br \/>\n    start<br \/>\n} <\/p>\n<p>reload() {<br \/>\n    configtest || return $?<br \/>\n    echo -n $&#8221;Reloading $prog: &#8221;<br \/>\n    killproc $nginx -HUP<br \/>\n    RETVAL=$?<br \/>\n    echo<br \/>\n} <\/p>\n<p>force_reload() {<br \/>\n    restart<br \/>\n} <\/p>\n<p>configtest() {<br \/>\n    $nginx -t -c $NGINX_CONF_FILE<br \/>\n} <\/p>\n<p>rh_status() {<br \/>\n    status $prog<br \/>\n} <\/p>\n<p>rh_status_q() {<br \/>\n    rh_status >\/dev\/null 2>&#038;1<br \/>\n} <\/p>\n<p>case &#8220;$1&#8243; in<br \/>\n    start)<br \/>\n        rh_status_q &#038;&#038; exit 0<br \/>\n        $1<br \/>\n    ;;<br \/>\n    stop)<br \/>\n        rh_status_q || exit 0<br \/>\n        $1<br \/>\n    ;;<br \/>\n    restart|configtest)<br \/>\n        $1<br \/>\n    ;;<br \/>\n    reload)<br \/>\n        rh_status_q || exit 7<br \/>\n        $1<br \/>\n    ;;<br \/>\n    force-reload)<br \/>\n        force_reload<br \/>\n    ;;<br \/>\n    status)<br \/>\n        rh_status<br \/>\n    ;;<br \/>\n    condrestart|try-restart)<br \/>\n        rh_status_q || exit 0<br \/>\n    ;;<br \/>\n    *)<br \/>\n        echo $&#8221;Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}&#8221;<br \/>\n        exit 2<br \/>\nesac<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Red Hat Enterprise Linux installation at 7.3 Nginx<\/p>\n<p>I. Introduction<\/p>\n<p>Nginx ( &#8220;engine x&#8221;) is a by Russian designer Igor Sysoev procedures developed high-performance Web server and reverse proxy, also a IMAP \/ POP3 \/ SMTP proxy server. In the case of high concurrent connections, Nginx Apache server is a good substitute.<\/p>\n<p>Second, prepare<\/p>\n<p>1, [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6755"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6755"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6755\/revisions"}],"predecessor-version":[{"id":6756,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6755\/revisions\/6756"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}