1. 程式人生 > >Nginx啟動啟動停止重啟

Nginx啟動啟動停止重啟

## Nginx啟動停止重啟 ## ### nginx快捷操作配置      1. 編輯配置檔案     [[email protected] ~]# vim /etc/profile      2. 新增配置          export NGINX_HOME=/usr/local/nginxtest     export PATH=$NGINX_HOME/sbin:$PATH      3.     使配置生效     [[email protected] ~]# source /etc/profile 4. 測試配置是否成功     [[email protected] ~]# nginx -t     nginx: the configuration file /usr/local/nginxtest/conf/nginx.conf syntax is ok     nginx: configuration file /usr/local/nginxtest/conf/nginx.conf test is successful     [

[email protected] ~]# 5. 檢查是否啟動了     方法一:未啟動     [[email protected] ~]# ps aux|grep nginx     root     12818  0.0  0.0 112720   972 pts/0    S+   15:00   0:00 grep --color=auto nginx     方法二:未啟動     [[email protected] ~]# netstat -tunlp|grep nginx     [[email protected] ~]# 6. 啟動nginx     方法一:     [
[email protected]
~]# nginx -c /usr/local/nginxtest/conf/nginx.conf     方法二:在/etc/profile中配置過nginx     [[email protected] ~]# nginx 7. 再次檢查是否啟動     方法一:啟動成功 一個主程序兩個子程序     [[email protected] ~]# ps aux|grep nginx     root     13041  0.0  0.0  20552   616 ?        Ss   15:03   0:00 nginx: master process nginx -c /usr/local/nginxtest/conf/nginx.conf     nginx    13042  0.0  0.0  23088  1384 ?        S    15:03   0:00 nginx: worker process     nginx    13043  0.0  0.0  23088  1384 ?        S    15:03   0:00 nginx: worker process     root     13124  0.0  0.0 112720   972 pts/0    S+   15:04   0:00 grep --color=auto nginx     [
[email protected]
~]#          方法二:啟動成功  埠81處於監聽(LISTEN)狀態     [[email protected] ~]# netstat -tunlp|grep nginx     tcp        0      0 0.0.0.0:81              0.0.0.0:*               LISTEN      13041/nginx: master 8. nginx伺服器停止執行     [[email protected] ~]# nginx -s stop 9. nginx重新載入     [[email protected] ~]# nginx -s reload ### Nginx配置檔案     [[email protected] ~]# cat /usr/local/nginxtest/conf/nginx.conf     #user  nobody;     worker_processes  2;          #error_log  logs/error.log;     #error_log  logs/error.log  notice;     #error_log  logs/error.log  info;          #pid        logs/nginx.pid;               events {         worker_connections  1024;     }               http {         include       mime.types;         default_type  application/octet-stream;              #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '         #                  '$status $body_bytes_sent "$http_referer" '         #                  '"$http_user_agent" "$http_x_forwarded_for"';              #access_log  logs/access.log  main;              sendfile        on;         #tcp_nopush     on;              #keepalive_timeout  0;         keepalive_timeout  65;              #gzip  on;              server {             listen       81;             server_name  localhost;                  #charset koi8-r;                  #access_log  logs/host.access.log  main;                  location / {                 root   html;                 index  index.html index.htm;             }                  #error_page  404              /404.html;                  # redirect server error pages to the static page /50x.html             #             error_page   500 502 503 504  /50x.html;             location = /50x.html {                 root   html;             }                  # proxy the PHP scripts to Apache listening on 127.0.0.1:80             #             #location ~ \.php$ {             #    proxy_pass   http://127.0.0.1;             #}                  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000             #             #location ~ \.php$ {             #    root           html;             #    fastcgi_pass   127.0.0.1:9000;             #    fastcgi_index  index.php;             #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;             #    include        fastcgi_params;             #}                  # deny access to .htaccess files, if Apache's document root             # concurs with nginx's one             #             #location ~ /\.ht {             #    deny  all;             #}         }                   # another virtual host using mix of IP-, name-, and port-based configuration         #         #server {         #    listen       8000;         #    listen       somename:8080;         #    server_name  somename  alias  another.alias;              #    location / {         #        root   html;         #        index  index.html index.htm;         #    }         #}                   # HTTPS server         #         #server {         #    listen       443 ssl;         #    server_name  localhost;              #    ssl_certificate      cert.pem;         #    ssl_certificate_key  cert.key;              #    ssl_session_cache    shared:SSL:1m;         #    ssl_session_timeout  5m;              #    ssl_ciphers  HIGH:!aNULL:!MD5;         #    ssl_prefer_server_ciphers  on;              #    location / {         #        root   html;         #        index  index.html index.htm;         #    }         #}          }     [[email protected] ~]#