<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                1.下載源碼包,官網找最新穩定版本 ``` wget http://nginx.org//download/nginx-1.16.0.tar.gz ``` 也可以直接官網下載到PC本地 xshell 使用rz命令上傳 或是ftp上傳 2.解壓.通常下載到/usr/local/src ,直接解壓到該目錄,用來專門放置安裝壓縮包和解壓源碼 3.配置參數. ``` ./configure --help #查看可以設置哪些參數 ``` 其中 --prefix=install_path 這個參數是指定 make install的時候 軟件安裝的目錄 4.編譯 ``` make [按照Makefile生成模塊] ``` 5.安裝 ``` make install ``` ###以nginx為例 1.基礎概念和依賴 nginx安裝可以使用yum或源碼安裝,推薦使用源碼,一是yum的版本比較舊,二是使用源碼可以自定義功能,方便業務的上的使用,源碼安裝需要提前準備標準的編譯器,GCC的全稱是(GNU Compiler collection),其有GNU開發,并以GPL即LGPL許可,是自由的類UNIX即蘋果電腦Mac OS X操作系統的標準編譯器,因為GCC原本只能處理C語言,所以原名為GNU C語言編譯器,后來得到快速發展,可以處理C++,Fortran,pascal,objective-C,java以及Ada等其他語言,此外還需要Automake工具,以完成自動創建Makefile的工作,Nginx的一些模塊需要依賴第三方庫,比如pcre(支持rewrite),zlib(支持gzip模塊)和openssl(支持ssl模塊) 官網http://nginx.org/en/download.html下載最新穩定版本到本地 本例子 登錄Xshell連接服務器[阿里云ECS] ``` yum install lrzsz #用來使用rz命令 cd /usr/local/src #進入用戶編譯安裝源碼目錄 rz # rz是代表上傳 會彈出window的選擇文件窗口,找到上面步驟下載的壓縮包,確定后會下載到當前目錄下 yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel # 安裝nginx的編譯依賴 ``` 2.解壓 ``` tar -vxf nginx-1.16.0.tar.gz # 解壓到當前目錄 ll #查看解壓后的當前目錄下的所有文件 # 主要目的看解壓后的文件名,一般為去掉壓縮為后綴的文件名,此處為nginx-1.16.0 cd nginx-1.16.0 ``` 3.配置編譯安裝參數[如果想自己管理自己的軟件安裝,注意配置--prefix=你管理自己編譯安裝軟件的目錄路徑] ``` ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/usr/local/nginx/logs/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --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/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre ``` 4.make [編譯] ``` 我在這里出現兩個問題 . 解決方案應該都在編譯前就執行 >編譯參數指定了用戶和用戶組 如果不存在會報錯 所以要先創建nginx用戶 > adduser nginx > groupadd nginx >編譯參數指定了日志目錄 可能該目錄目錄路徑沒有可寫權限 比如 日志放在 /var/log/nginx/下 但是 /var 目錄不可寫 會導致安裝報錯 ``` 5.make install [安裝] 此文章僅為學習記錄,原文章步驟非常詳細和好理解,見https://www.cnblogs.com/zhang-shijie/p/5294162.html 后續使用 ``` /usr/local/nginx/sbin/nginx #啟動nginx,通常沒有輸出任何信息,且下一步滿足即成功 #遭遇了netstat -ntlp #查看網絡連接進程,看到nginx進程即為成功, # 如果 -bash: netstate: command not found 則 yum install net-tools #在瀏覽器輸入服務器IP或解析過的域名 #會顯示/usr/local/nginx/html/index.html ``` 啟動過程可能會提示/var/run/nginx/nginx.pid 不存在或是不是一個文件之類的提示 建議調整配置文件/usr/local/nginx/conf/nginx.conf里的pid參數,指定/usr/local/nginx/logs/nginx.pid [記得先創建logs目錄] 設置為開機自啟 創建nginx啟動命令腳本 ``` vim /etc/init.d/nginx #內容如下 ``` 插入以下內容, 注意修改PATH和NAME字段, 匹配自己的安裝路徑 (這段是從網上copy的) 不過查看了相關參數,跟我的編譯參數完全匹配 ``` #! /bin/bash # Startup script for the nginx Web Server # chkconfig: - 85 15 # description: nginx is a World Wide Web server. It is used to serve PATH=/usr/local/nginx DESC="nginx daemon" NAME=nginx DAEMON=$PATH/sbin/$NAME CONFIGFILE=$PATH/conf/$NAME.conf PIDFILE=$PATH/logs/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME set -e [ -x "$DAEMON" ] || exit 0 do_start() { $DAEMON -c $CONFIGFILE || echo -n "nginx already running" } do_stop() { $DAEMON -s stop || echo -n "nginx not running" } do_reload() { $DAEMON -s reload || echo -n "nginx can't reload" } case "$1" in start) echo -n "Starting $DESC: $NAME" do_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" do_stop echo "." ;; reload|graceful) echo -n "Reloading $DESC configuration..." do_reload echo "." ;; restart) echo -n "Restarting $DESC: $NAME" do_stop do_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2 exit 3 ;; esac exit 0 ``` 設置執行權限 ``` chmod a+x /etc/init.d/nginx ``` 注冊成服務 ``` chkconfig --add nginx ``` 設置開機啟動 ``` chkconfig nginx on ``` 重啟, 查看驗證nginx服務是否自動啟動 ``` #重啟 reboot #或 shutdown -h 0 -r #查看進程 ps aux | grep nginx #或 netstat -nplt | grep nginx ``` 對nginx服務執行停止/啟動/重新讀取配置文件操作 ``` #啟動nginx服務 systemctl start nginx.service #停止nginx服務 systemctl stop nginx.service #重啟nginx服務 systemctl restart nginx.service #重新讀取nginx配置(這個最常用, 不用停止nginx服務就能使修改的配置生效) systemctl reload nginx.service ``` 成功 &nbsp; # 配置將請求轉發給php-fpm處理 php-fpm的默認端口號是9000 主配置 ``` user www; worker_processes 1; 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下配置 #autoindex on; #autoindex_exact_size off; ##autoindex_exact_size off; #虛擬主機配置 自動加載 include /usr/local/nginx/conf/nginx.conf.vhost/*.conf; server { listen 80; 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; # } #} } ``` 虛擬主機配置 ``` # another virtual host using mix of IP-, name-, and port-based configuration # server { charset utf-8; listen 80; server_name blog.54skyer.cn; set $root /home/www/blog.54skyer.cn/public; root $root; #root /home/www/blog.54skyer.cn/public; index index.php index.html; location /zhanghaotian/ { autoindex on; } location / { # 如果根目錄下匹配不是腳本 默認在根目錄后拼一個index.php 這是為了在url中省略index.php if (!-e $request_filename){ rewrite ^(.*) /index.php/$1 last; break; } } #pathinfo配置 使支持tp5的標準url location ~ .+\.php($|/) { fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name; include fastcgi_params; } # 匹配到php擴展名的url #location ~\.php$ { # include /usr/local/nginx/conf/fastcgi.conf; # fastcgi_intercept_errors on; # #轉發給php-fpm,其端口是9000; # fastcgi_pass 127.0.0.1:9000; #} } # 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; # } #} ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看