您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)nginx怎么安裝的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
0.下載
wget http://nginx.org/download/nginx-1.0.4.tar.gz
2.運(yùn)行
/usr/local/nginx/sbin/nginx #注:nginx默認(rèn)使用80端口,若是80端口被占用,修改/usr/local/nginx/conf/nginx.conf里的 server { listen 80;
3.測(cè)試
echo "test123" > /usr/local/nginx/html/index.html wget http://127.0.0.1
4.基本命令
/usr/local/nginx/sbin/nginx -h #幫助 /usr/local/nginx/sbin/nginx -v #顯示版本 /usr/local/nginx/sbin/nginx -V #顯示版本和配置信息 /usr/local/nginx/sbin/nginx -t #測(cè)試配置 /usr/local/nginx/sbin/nginx -q #測(cè)試配置時(shí),只輸出錯(cuò)誤信息 /usr/local/nginx/sbin/nginx -s stop #停止服務(wù)器 /usr/local/nginx/sbin/nginx -s reload #重新加載配置 /usr/local/nginx/sbin/nginx -s quit #不知道,估計(jì)和stop差不多 /usr/local/nginx/sbin/nginx -s reopen #不知道,估計(jì)和reload類(lèi)似 /usr/local/nginx/sbin/nginx -p /nginx/path #默認(rèn)為/usr/local/nginx(nginx安裝路徑),修改后影響log目錄和html目錄 /usr/local/nginx/sbin/nginx -c /configure/file/path #配置文件路徑,默認(rèn)為conf/nginx.conf,有多個(gè)配置文件時(shí)很有用,用這個(gè)可以啟動(dòng)多個(gè)不同的nginx監(jiān)聽(tīng)不同端口 /usr/local/nginx/sbin/nginx -g #沒(méi)用過(guò)
#user nobody; #nginx啟動(dòng)使用的用戶(hù),配置fastcgi時(shí),需要改為有權(quán)限執(zhí)行fastcgi的用戶(hù) worker_processes 1; #nginx啟動(dòng)的進(jìn)程數(shù),1個(gè)已經(jīng)足夠了 #error_log logs/error.log; #nginx 錯(cuò)誤日志 相對(duì)于/usr/local/nginx/ #error_log logs/error.log notice; #nginx 記錄警告日志 相對(duì)于/usr/local/nginx/ ,可改為 logs/notice.log #error_log logs/error.log info; #nginx 記錄信息日志 相對(duì)于/usr/local/nginx/ ,可改為 logs/info.log #pid logs/nginx.pid; #nginx進(jìn)程文件,最好不要改 events { worker_connections 1024; #nginx最大連接數(shù),最好小于系統(tǒng)的socket最大數(shù)和文件打開(kāi)數(shù) } http { include mime.types; #見(jiàn)同目錄mime.types,用于根據(jù)文件后綴產(chǎn)生http header 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; #訪(fǎng)問(wèn)日志 sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #保持連接時(shí)間,單位:秒 #gzip on; server { listen 80; #監(jiān)聽(tīng)的端口 server_name localhost; #服務(wù)器名 #charset koi8-r; #默認(rèn)字符集 #access_log logs/host.access.log main; #根據(jù)訪(fǎng)問(wèn)域名生成對(duì)應(yīng)的訪(fǎng)問(wèn)日志 location / { root html; #根目錄,相對(duì)于安裝目錄 index index.html index.htm; #默認(rèn)主頁(yè) } #error_page 404 /404.html; #錯(cuò)誤頁(yè) # 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; #轉(zhuǎn)發(fā)到9000端口進(jìn)行處理 # 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; # server_name localhost; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }
5.配置
配置文件在 安裝目錄/conf/nginx.conf
修改完后用 /usr/local/nginx/sbin/nginx -s reload重新加載
1.安裝
默認(rèn)安裝到/usr/local/nginx
tar -zxvf nginx-1.0.4.tar.gz cd nginx-1.0.4 ./configure make;make install
感謝各位的閱讀!關(guān)于“nginx怎么安裝”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。