服务器安装Nginx

 1、解压

1 tar -zxvf nginx-1.13.7.tar.gz ---解压nginx安装包 

2、cd nginx-1.13.7,然后执行下面命令

./configure --- 用来检测安装平台的目标特征
make --- 用来编译( 从Makefile中读取指令,然后编译)
make install --- 用来安装( 从Makefile中读取指令,安装到指定的位置)

备注:如果执行 ./configure时报错,可以用下面命令解决

yum -y install gcc gcc-c++ autoconf automake make

3、编辑启动端口(图片的端口是经过修改的,默认是80端口)

cd /usr/local/nginx/conf
vim nginx.conf
编辑好之后,按esc退出编辑模式,然后 :wq 进行保存退出

4、然后修改下请求端口和地址即可

 

 5、启动

cd /usr/local/nginx/sbin
./nginx

(重启nginx    ./nginx -s reload

查看是否启动成功命令:ps -ef | grep nginx

 

 

访问

 

 



注意:如果你是在阿里云服务器部署(有的人在自己的vmwar虚拟机里面部署),
那么就要登陆阿里云服务器,上防火墙一列开放你的nginx启动端口,否则访问不了!!!

  

 

 1 #user  nobody;
 2 worker_processes  1;
 3 #pid        logs/nginx.pid;
 4 
 5 
 6 events {
 7     worker_connections  1024;
 8 }
 9 
10 
11 http {
12     include       mime.types;
13     default_type  application/octet-stream;
14 
15     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
16     #                  '$status $body_bytes_sent "$http_referer" '
17     #                  '"$http_user_agent" "$http_x_forwarded_for"';
18 
19     #access_log  logs/access.log  main;
20 
21     sendfile        on;
22     #tcp_nopush     on;
23 
24     #keepalive_timeout  0;
25     keepalive_timeout  65;
26 
27     #gzip  on;
28 
29     #这里是要转发的地址
30     upstream vueServer{
31             server 10.10.10.10:8080;
32         }
33 
34     #这里是nginx自己的端口和地址
35     server {
36         listen       8082;
37         server_name  localhost;
38 
39         #charset koi8-r;
40             proxy_pass http://vueServer;
41             root   html;
42             index  index.html index.htm;
43         }
44         #
45         error_page   500 502 503 504  /50x.html;
46         location = /50x.html {
47             root   html;
48         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
49         #    include        fastcgi_params;
50         #}
51 
52         # deny access to .htaccess files, if Apache's document root
53         # concurs with nginx's one
54         #
55         #location ~ /\.ht {
56         #    deny  all;
57         #}
58     }
59 
60 
61     # another virtual host using mix of IP-, name-, and port-based configuration
62     #
63     #server {
64     #    listen       8000;
65     #    listen       somename:8080;
66     #    server_name  somename  alias  another.alias;
67 
68     #    location / {
69     #        root   html;
70     #        index  index.html index.htm;
71     #    }
72     #}
73 
74 
75     # HTTPS server
76     #
77     #server {
78     #    listen       443 ssl;
79     #    server_name  localhost;
80 
81     #    ssl_certificate      cert.pem;
82     #    ssl_certificate_key  cert.key;
83 
84     #    ssl_session_cache    shared:SSL:1m;
85     #    ssl_session_timeout  5m;
86 
87     #    ssl_ciphers  HIGH:!aNULL:!MD5;
88     #    ssl_prefer_server_ciphers  on;
89 
90     #    location / {
91     #        root   html;
92     #        index  index.html index.htm;
93     #    }
94     #}
95 
96 }

 

posted @ 2022-08-28 18:09  勤快的懒羊羊  阅读(434)  评论(0编辑  收藏  举报