从写项目到部署linux服务器全过程-linux下Nginx的安装

linux Nginx的安装和简单使用


前面几篇
1-MyEclipse新建单个Maven web工程
2-MyEclipse创建Maven web项目名后缀会有Maven Webapp
3-My Eclipse创建多模块Maven依赖项目
4-从写项目到部署linux服务器全过程-linux(CentOS 6.5)安装篇
5- 从写项目到部署linux服务器全过程-linux固定IP配置篇
6-从写项目到部署linux服务器全过程-linux下安装JDK篇
7-从写项目到部署linux服务器全过程-linux下tomcat的安装篇
8-从写项目到部署linux服务器全过程-linux下tomcat的集群配置篇
9-从写项目到部署linux服务器全过程-linux防火墙端口配置篇
10-从写项目到部署linux服务器全过程-linux部署web项目篇

从项目到部署服务器的过程,毕竟些写项目是为了发布部署服务器。本篇主要介绍linux Nginx的安装和简单使用,后面几篇文章将会介绍:
——>linux 自动化部署项目Jenkins的安装和简单使用


步骤:

主要以截图为主,复杂的操作,会以文字说明。按照步骤一步一步来操作就可以了。


1. 使用winscp把nginx-1.8.0.tar.gz上传到linux的/usr/local/目录下

这里写图片描述

2. 使用Putty远程登录,输入用户名密码,登录linux。进入目录,解压

cd /usr/local   #进入目录
ls  		#查看
tar -zxvf nginx-1.8.0.tar.gz   	#解压

这里写图片描述

3. 进入解压过的目录nginx-1.8.0目录,运行配置

cd nginx-1.8.0    #进入目录

#配置
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi



#忽略支持https配置
./configure \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module

这里写图片描述

4.如果上一步报错,运行第5步骤,如果没报错,跳转第6步骤

这里写图片描述

5.处理报错信息,是因为有些环境没安装,安装即可

yum install gcc;
yum install pcre-devel;
yum install zlib zlib-devel;
yum install openssl openssl-devel;

[root@localhost nginx-1.7.4]# ./configure
checking for OS
+ Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
出现这个错误。
那么就是gcc 包没有安装。安装gcc 吧,骚年。
yum -y install gcc
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
再次执行./configure
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
yum install pcre-devel
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
再次执行./configure
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
yum install zlib-devel
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
再次执行./configure


Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library

OK,现在可以执行make 了。 如果你想使用openssl 功能,sha1 功能。 那么安装openssl ,sha1 吧,骚年。 安装openssl yum install openssl openssl-devel 安装sha1
yum install perl-Digest-SHA1.x86_64
开启ssl 模块 执行./configure --with-http_ssl_module
启用“server+status"页,执行./configure --with-http_stub_status_module
两个都启动,不用我说了。执行./configure --with-http_stub_status_module --with-http_ssl_module
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
那么configre 就通过了。

6.注意:上边./configure将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录

mkdir /var/temp/nginx -p

这里写图片描述

7.使用make,make install 运行

make    #编译

make  install   #安装

这里写图片描述

这里写图片描述

8.在/usr/local目录下,可以看到Nginx目录,这个就是我们安装好了Nginx,接下来可以测试

cd /usr/local/nginx/sbin/
./nginx    					#启动Nginx

service iptables  stop     #关闭防火墙

这里写图片描述
这里写图片描述

9.http://IP地址测试

http://100.100.100.255(你的ip)
这里写图片描述

  • 4
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值