最新:
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 |
|
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
一切搞定