-
安裝依賴
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[linux]安裝nginx阿里CentOSLinuxNginx
- 阿里雲伺服器Nginx的安裝與部署阿里伺服器Nginx
- centos7雲伺服器安裝nginx記錄CentOS伺服器Nginx
- 阿里雲centos 7.4 安裝pptp阿里CentOSpptp
- 阿里雲 Centos7安裝ssh+nginx+mysql 傻瓜式教程阿里CentOSNginxMySql
- CentOS 7伺服器下Nginx安裝配置CentOS伺服器Nginx
- 阿里雲centos安裝圖形化介面阿里CentOS
- Centos 7 安裝NginxCentOSNginx
- CentOS 7 - 安裝NginxCentOSNginx
- CentOS 上安裝 NginxCentOSNginx
- centos 7.6 安裝 nginxCentOSNginx
- 阿里雲伺服器安裝jdk阿里伺服器JDK
- 阿里雲 centos7.6 安裝 mysql8阿里CentOSMySql
- 阿里雲 centos7.6 安裝 php7.3阿里CentOSPHP
- 阿里雲 centos7.6 安裝shadowsocks-go阿里CentOSGo
- CentOS7 安裝NginxCentOSNginx
- CentOS7-安裝NginxCentOSNginx
- Centos 7 yum 安裝nginxCentOSNginx
- CentOS 7 yum 安裝 NGINXCentOSNginx
- CentOS容器中安裝NginxCentOSNginx
- centos安裝nginx1.17.9CentOSNginx
- centos7安裝nginxCentOSNginx
- Centos7 安裝 NginxCentOSNginx
- CentOS系統安裝NginxCentOSNginx
- CentOS離線安裝NginxCentOSNginx
- centos 下 安裝 node,nginx, mysqlCentOSNginxMySql
- CentOS7.X安裝NginxCentOSNginx
- CentOS 7 安裝 nginx-rtmpCentOSNginx
- CentOS 下編譯安裝 NginxCentOS編譯Nginx
- 雲伺服器linux centos安裝圖形介面伺服器LinuxCentOS
- 阿里雲centos7伺服器nginx配置及常見問題解答阿里CentOS伺服器Nginx
- 阿里雲伺服器ecs配置之安裝mysql阿里伺服器MySql
- RabbitMQ入門 -- 阿里雲伺服器安裝RabbitMQMQ阿里伺服器
- CentOS7原始碼安裝NginxCentOS原始碼Nginx
- 如何在 CentOS 7 上安裝 NginxCentOSNginx
- centos7中使用yum安裝NGINX安裝CentOSNginx
- centos雲伺服器安裝Python3記錄CentOS伺服器Python
- linux伺服器安裝nginxLinux伺服器Nginx