Nginx的安装(一)

如果在运行下面命令出现 wget commond not found 需要先安装wget,命令 # yum -y install wget

安装必要的库 gzip 模块需要 zlib 库 rewrite 模块需要 pcre,ssl, openssl 库

安装 gcc gcc-c++(如新环境,未安装请先安装)

yum install -y gcc gcc-c++

安装 PCRE 库

cd /usr/local/

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz

tar -zxvf pcre-8.33.tar.gz

cd pcre-8.33

./configure

make && make install

如报错:configure: error: You need a C++ compiler for C++ support

解决:yum install -y gcc gcc-c++

安装SSL 库

cd /usr/local/

wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz

tar -zxvf openssl-1.0.1j.tar.gz

cd openssl-1.0.1j

./config

 make && make install

安装zlib 库

cd /usr/local/

wget http://zlib.net/zlib-1.2.11.tar.gz

tar -zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

./configure

 make && make install

安 装nginx

cd /usr/local/

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

tar -zxvf nginx-1.8.0.tar.gz

cd  nginx-1.8.0
./configure

 make && make install
 
./configure --user=nobody

./configure	--group=nobody

 ./configure --prefix=/usr/local/nginx
 
 ./configure  --with-http_stub_status_module
 
./configure  --with-http_gzip_static_module

./configure  --with-http_realip_module

./configure  --with-http_sub_module

./configure  --with-http_ssl_module

如果启动提示 make: *** No rule to make target build', needed bydefault’. Stop. 或者 make: *** 没有规则可以创建“default”需要的目标“build”表示需要安装依赖包
安装依赖包命令
yum install pcre-devel zlib zlib-devel openssl openssl-develke。。。。

启动,重启,停止,测试配置文件是否正常,强制关闭

/usr/local/nginx/sbin/nginx 

/usr/local/nginx/sbin/nginx –s reload 

/usr/local/nginx/sbin/nginx –s stop

/usr/local/nginx/sbin/nginx –t

pkill nginx

启动成功业务无提示,后默认端口为 80 通过浏览器直接访问就可以看到页面了。

linux下启动和关闭nginx命令

  • 进入到安装的目录里面

whereis nginx

在这里插入图片描述

  • 进入该路径:cd /usr/local/nginx/sbin

cd   /usr/local/nginx/sbin

在这里插入图片描述

  • 启动nginx 命令:

 ./nginx 

出现下面启动成功
在这里插入图片描述

  • 查看nginx 的状态

 ps -ef | grep nginx 

出现master 则启动成功
在这里插入图片描述

  • 关闭nginx 命令

  • kill -9 28848(进程号 上面的) 则关闭nginx
    在这里插入图片描述
  • 停止 nginx 命令:

./nginx -s stop 
  • 重启nginx命令:

./nginx -s reload
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值