安装配置nginx

最新:

https://www.cnblogs.com/liaolongjun/p/5664005.html

 

阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定

1、安装nginx

    yum -y install nginx

2、启动nginx

    service nginx start

3、访问(nginx默认是80端口)

    curl 127.0.0.1

4、域名子绑定

    编辑文件/etc/nginx/conf.d/default.conf,在底部加入下面代码,完成前几章所述4个端口的子域名绑定

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

server{

        listen    80;

        server_name    tomcat.bingzhenmifan.com;

            location /

            {

                proxy_set_header Host $host;

                proxy_set_header X-Real-Ip $remote_addr;

                proxy_set_header X-Forwarded-For $remote_addr;

                proxy_pass http://127.0.0.1:14802;

            }

}

 

server{

        listen    80;

        server_name    jetty.bingzhenmifan.com;

            location /

            {

                proxy_set_header Host $host;

                proxy_set_header X-Real-Ip $remote_addr;

                proxy_set_header X-Forwarded-For $remote_addr;

                proxy_pass http://127.0.0.1:14808;

            }

}

 

server{

        listen    80;

        server_name    resin8080.bingzhenmifan.com;

            location /

            {

                proxy_set_header Host $host;

                proxy_set_header X-Real-Ip $remote_addr;

                proxy_set_header X-Forwarded-For $remote_addr;

                proxy_pass http://127.0.0.1:8080;

            }

}

 

server{

        listen    80;

        server_name    resin14805.bingzhenmifan.com;

            location /

            {

                proxy_set_header Host $host;

                proxy_set_header X-Real-Ip $remote_addr;

                proxy_set_header X-Forwarded-For $remote_addr;

                proxy_pass http://127.0.0.1:14805;

            }

}

5、重启nginx

    service nginx restart

6、访问测试

    依次访问上面4个域名:tomcat.bingzhenmifan.com、jetty.bingzhenmifan.com、resin8080.bingzhenmifan.com、resin14805.bingzhenmifan.com

    注意:如果域名没有备案的话,在本地是打不开网站的,可以在云服务器上使用curl命令访问

7、域名备案

    登录阿里云,点击右上角【备案】,按步骤完成备案即可

 

 

 

 

安装配置nginx

方法一:安装最新版的nginx

1、下载nginx1.7.4

注:下载地址:http://nginx.org/download/nginx-1.7.4.tar.gz
wget -c http://nginx.org/download/nginx-1.7.4.tar.gz  
2、安装

注:默认安装到/usr/local/nginx
tar -zxvf nginx-1.7.4.tar.gz   
cd nginx-1.7.4   
./configure    
make && make install #注:会出来一堆东西  
3、运行

/usr/local/nginx/sbin/nginx

查看nginx是否正常
[root@aaa nginx-1.2.4]# /usr/local/nginx/sbin/nginx -t  
出现如下代码: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful 安装成功!

 

//报错的话

wget http://nginx.org/download/nginx-0.8.33.tar.gz
tar -zxvf nginx-0.8.33.tar.gz 
cd nginx-0.8.33
./configure --prefix=/usr/local/nginx

 

安装Nginx时报错

./configure: error: the HTTP rewrite module requires the PCRE library.

安装pcre-devel解决问题
yum -y install pcre-devel

 

错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

解决办法:

yum -y install openssl openssl-devel

 

总结:

yum -y install pcre-devel openssl openssl-devel

./configure --prefix=/usr/local/nginx

make

make install

一切搞定

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值