1. 程式人生 > 實用技巧 >Python encode()、decode()方法詳解

Python encode()、decode()方法詳解

下載

官網下載地址:http://nginx.org/en/download.html
Mainline version 開發版
Stable version 穩定版
Legacy versions 歷史版

滑鼠移動到你要選擇的版本超連結上點右鍵 複製連結地址

下載:wget https://nginx.org/download/nginx-1.16.0.tar.gz

安裝

移走:mv ./nginx-1.16.0.tar.gz /usr/local/

解壓:tar -zxvf nginx-1.16.0.tar.gz

進去:cd nginx-1.16.0

配置:./configure --with-http_stub_status_module --with-http_ssl_module

安裝:make && make install

配置

開啟配置檔案:vim /usr/local/nginx/conf/nginx.conf

一個監聽是一個server{....}段落,裡面預設的server程式碼塊可以刪掉。

當你在你的域名控制檯(阿里雲或騰訊雲或百度雲等等)中設定域名解析成當前伺服器IP時,你就可以在這裡配置域名監聽。

比如下面這段:

    server {
        listen       80;
        server_name  www.abc.com abc.com;
        root /www/abc;
        location 
/ { index.html; } }

當瀏覽器訪問 www.abc.com時,由於域名解析指向當前伺服器,所以網路請求會發往當前伺服器的80埠,nginx監聽到請求後,會去找到root指定的地址 也就是/www/abc目錄,將目錄中的index.html返回給請求方,此時瀏覽器收到返回,解析標籤,展示在頁面上。

命令

編寫服務指令碼:vim /etc/init.d/nginx

貼上以下程式碼:

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: 
- 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /usr/local/nginx/logs/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/usr/local/nginx/logs/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid } # reload nginx service functions. reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL

PS:經常貼上前兩行貼不全,小心檢查。

設定許可權:chmod 755 /etc/init.d/nginx

自啟配置:vim /etc/rc.local

在檔案末尾新增一行:/usr/local/nginx/sbin/nginx

服務命令啟動:/etc/init.d/nginx start

開機自啟:chkconfig nginx on

可使用的命令:

systemctl status nginx
systemctl start nginx
systemctl stop nginx
systemctl reload nginx
systemctl restart nginx