nginx笔记.
安裝:
依賴的軟件包:
gcc gcc-c++ autoconf automake zlib zlib-devel openssl opensll-devel pcre pcre-devel到官方網站上下載nginx包:
解壓:
tar -zxf nginx-x.x.tar.gz安裝三步走:./configure------- make------make install
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx \ --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module \ --with-http_gzip_static_module --with-http_ssl_module --http-log-path=/var/log/nginx/access.log \ --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/\--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ [root@localhost ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 啟動nginx查看nginx是否啟動:
[root@localhost ~]# lsof -i:80 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME nginx 7802 root 6u IPv4 22039 TCP *:http (LISTEN) nginx 7803 nginx 6u IPv4 22039 TCP *:http (LISTEN) [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# ps -ef | grep nginx root 7802 1 0 09:36 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf master#主進程 nginx 7803 7802 0 09:36 ? 00:00:00 nginx: worker process #子進程 root 7807 3696 0 09:36 pts/3 00:00:00 grep nginx [root@localhost ~]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf #檢查配置文件的正確性。nginx.conf 配置文件定義:
user www www; #使用的用戶和組 worker_processes 2; #指衍生進程數(一般設置為cpu總核數的兩倍)。events {worker_connections 1024; #允許最大連接數 }http {include mime.types;default_type application/octet-stream;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k; #------------------------------------------------- #設置客戶端能夠上傳的文件大小。client_max_body_size 8m;#-------------------------------------------------sendfile on;tcp_nopush on;keepalive_timeout 65;tcp_nodelay on;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fastcgi_read_timeout 300;fastcgi_buffer_size 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 128k; #---------------------------------------- #開啟gzip壓縮gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_http_version 1.1;gzip_comp_level 2;gzip_types text/plain application/x-javascript text/css application/xml;gzip_vary on; #----------------------------------------server {listen 80;server_name www.nimei.com;index index.html index.htm index.php;root /data0/htdocs;location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires 30d;}location ~ .*\.(js|css)?${expires 1h;}log_format access '$remote_addr - $remote_user [$time_local] "$request"''$status $body_bytes_sent "$http_referer"''"$http_user_agent" $http_x_forwarded_for';access_log /data1/logs/acess.log access;} server {listen 80; #虛擬主機監聽的端口server_name www.nimei1.com;#虛擬主機域名或IPaccess_log /data1/logs/vm1_access.log combined; 日志目錄location /{index index.html index.htm; #默認解析頁面root /data0/htdocs/nimei1; #網站源碼路徑}} }1.從容停止nginx(nginx啟動停止由其pid決定):
kill -QUIT nginx主進程號 kill -QUIT 7802 或者 kill -QUIT `cat /var/run/nginx/nginx.pid`2.快速停止nginx:
kill -TERM ngixID 或者 kill -INT nginxID nginxID-----主進程號 [root@localhost ~]# kill -TERM 7886 [root@localhost ~]# [root@localhost ~]# ps -ef | grep nginx root 7900 3696 0 10:04 pts/3 00:00:00 grep nginx3.強制停止nginx:
pkill -9 nginx4.平滑啟動nginx:
kill -HUP nginxIDNginx信號控制說明:
TERM,INT 快速關閉nginx QUIT 從容關閉; HUP 平滑啟動; USR1 重新打開日志文件(日志切割很有用) USR2 平滑升級可執行程序。 WINCH 從容關閉工作。升級新版本關閉舊版本時用WINCH。檢查nginx配置文件的正確與否:
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf [root@localhost ~]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok configuration file /usr/local/nginx/conf/nginx.conf test is successful [root@localhost ~]#?
?《未完待續》--------
?
轉載于:https://www.cnblogs.com/osxlinux/p/3302454.html
總結
- 上一篇: jQuery操作cookie
- 下一篇: 记一次PLC和脉冲型伺服电机的接线方法_