linux部署nginx的经验

Linux系统安装nginx的配置经验

1.首先需要安装nginx服务

首先在Linux系统下载nginx压缩包

wget http://nginx.org/download/nginx-1.7.8.tar.gz

2.安装c++依赖包

yum install gcc gcc-c++

3.解压编译安装

tar -axvf nginx-1.7.8.tar.gz

进入nginx目录

cd nginx-1.7.8

执行./configure 将文件编译

安装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= options.

解决办法:

yum -y install openssl openssl-devel

总结:

yum -y install pcre-devel openssl openssl-devel

./configure 此文件 --prefix=/usr/local/nginx

Make

make install

一切搞定

4.启动nginx

开启nginx

/usr/local/nginx/sbin/nginx   

重启nginx

/usr/local/nginx/sbin/nginx -s reload

停止nginx

/usr/local/nginx/sbin/nginx -s stop

5.关闭防火墙就可以测试了

在谷歌浏览器上将自己的IP地址加上nginx端口就能运行出来了,如:x.x.x.x:80
出现该图片算是安装成功了出现该界面就算是安装成功了!

6.配置nginx的配置文件

这是nginx目录下的配置文件

cd /usr/local/nginx/conf/
vi nginx.conf 编辑配置文件
vim nginx.conf 命令也行,熟悉哪个用哪个,效果同vi

接下来就会进入该图里的页面,下图是修改过后的结果。
在这里插入图片描述

在这里插入图片描述

7.修改tomcat的配置文件

以上命令都操作完之后进行tomcat配置文件的修改
cd /opt/tomcat1/webapps/ROOT
vi index.html 编辑index文件,使用vi就会自动创建

在index.html文件里面添加以下语句去进行测试
在这里插入图片描述
然后使用cd命令返回tomcat的bin目录

cd ../bin   跳转到bin目录

使用./startup.sh命令开启tomcat

8.去修改windows系统修改hosts文件

去c盘进入Windows-System32-drivers-etc-hosts文件
在这里插入图片描述
然后进入linux系统去重启nginx服务,再去谷歌使用hosts里增加的域名去测试就行了。

要记住关闭防火墙,和启动tomcat,每次修改配置文件都要重启一下nginx服务。

菜鸟制作,勿喷。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值