# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
建立nginx的yum倉庫
# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
下載并安裝nginx
# yum install nginx
啟動(dòng)nginx服務(wù)
systemctl start nginx
配置
默認(rèn)的配置文件在 /etc/nginx 路徑下,使用該配置已經(jīng)可以正確地運(yùn)行nginx;如需要自定義,修改其下的 nginx.conf 等文件即可。
測試
在瀏覽器地址欄中輸入部署nginx環(huán)境的機(jī)器的IP,如果一切正常,應(yīng)該能看到如下字樣的內(nèi)容。
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
#include /etc/nginx/conf.d/*.conf;
#設(shè)定負(fù)載均衡服務(wù)器列表
upstream group1{
#后端服務(wù)器訪問規(guī)則
#ip_hash;
#weight參數(shù)表示權(quán)重值,權(quán)值越高被分配到的幾率越大
#PC_Local
server 192.168.187.133:80 weight=5;
#PC_Server
server 192.168.187.134:80 weight=5;
}
server {
listen 81; #設(shè)置對(duì)外端口
server_name 192.168.187.133 ; #設(shè)置識(shí)別請(qǐng)求域名
location / {
#定義服務(wù)器的默認(rèn)網(wǎng)站根目錄位置
#root html;
#定義首頁索引文件的名稱
#index index.html index.htm index.php;
proxy_pass http://group1 ; #分流到group1集群
}
}
}
更多關(guān)于云服務(wù)器,域名注冊(cè),虛擬主機(jī)的問題,請(qǐng)?jiān)L問西部數(shù)碼官網(wǎng):www.ps-sw.cn