-
安裝依賴
yum install openssl
yum install zlib
yum install pcre
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm -
安裝Nginx
yum install nginx
-
啟動Nginx/重啟Nginx
service nginx start # 啟動
service nginx restart # 重啟 -
驗證安裝
在安全組設定中,開放伺服器80埠。
瀏覽器訪問http://{伺服器ip},出現歡迎介面表示安裝且啟動成功。
# 配置檔案路徑
/etc/nginx/nginx.conf
# 上面的檔案預設會引用/etc/nginx/conf.d資料夾下的所有結尾為.conf的配置檔案,其中該資料夾預設存在一個default.conf配置檔案。 -
簡單使用
-
轉發
server {
listen 80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
proxy_pass http://127.0.0.1:5000; # 將服務端80埠接收的請求轉發到127.0.0.1:5000
}
#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 /usr/share/nginx/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;
#}
}
-
upstream myserver {
ip_hash; # 負載均衡演算法,有多種可選,可以選擇多種均衡策略
server 127.0.0.1:5000;
server 127.0.0.1:5001;
server 127.0.0.1:5002;
}
server {
listen 80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
proxy_pass http://myserver; # 將伺服器80埠接收的請求轉發到負載均衡組myserver中
# root /usr/share/nginx/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 /usr/share/nginx/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;
#}
}
-
阿里雲Centos伺服器安裝Nginx
相關文章
- 阿里雲伺服器CentOS7.0安裝Nginx 1.12.1阿里伺服器CentOSNginx
- 阿里雲centos7[linux]安裝nginx阿里CentOSLinuxNginx
- CentOS 7伺服器下Nginx安裝配置CentOS伺服器Nginx
- CentOS 上安裝 NginxCentOSNginx
- CentOS 7 - 安裝NginxCentOSNginx
- Centos 7 安裝NginxCentOSNginx
- centos下安裝nginxCentOSNginx
- centos 7.6 安裝 nginxCentOSNginx
- 阿里雲伺服器Nginx的安裝與部署阿里伺服器Nginx
- centos7雲伺服器安裝nginx記錄CentOS伺服器Nginx
- CentOS 7 yum 安裝 NGINXCentOSNginx
- centos安裝nginx1.17.9CentOSNginx
- CentOS離線安裝NginxCentOSNginx
- CentOS系統安裝NginxCentOSNginx
- CentOS7-安裝NginxCentOSNginx
- CentOS7 安裝NginxCentOSNginx
- CentOS容器中安裝NginxCentOSNginx
- centos上nginx的安裝CentOSNginx
- Centos原始碼安裝NginxCentOS原始碼Nginx
- Centos7.2安裝NginxCentOSNginx
- CentOS 6.5安裝Nginx (一)CentOSNginx
- Centos-6.3安裝NginxCentOSNginx
- Centos 7 yum 安裝nginxCentOSNginx
- Centos7 安裝 NginxCentOSNginx
- centos7安裝nginxCentOSNginx
- CentOS 下編譯安裝 NginxCentOS編譯Nginx
- centos 下 安裝 node,nginx, mysqlCentOSNginxMySql
- CentOS7.X安裝NginxCentOSNginx
- gerrit+nginx+centos安裝配置NginxCentOS
- CentOS 7 安裝 nginx-rtmpCentOSNginx
- 阿里雲 Centos7安裝ssh+nginx+mysql 傻瓜式教程阿里CentOSNginxMySql
- 阿里雲centos 7.4 安裝pptp阿里CentOSpptp
- CentOS7原始碼安裝NginxCentOS原始碼Nginx
- 如何在 CentOS 7 上安裝 NginxCentOSNginx
- Centos下安裝FastDFS及Nginx模組CentOSASTNginx
- Centos7安裝Nginx實戰CentOSNginx
- CentOS6.6 安裝 nginx-1.8.0CentOSNginx
- centos/linux下的安裝NginxCentOSLinuxNginx