nginx安装方法

1.先验证是否有gcc

输入:gcc -v
gcc
或者使用: rpm -qa gcc
gcc
没有显示的时候需要安装

输入:	yum install gcc-c++

2.查看prce

输入: rpm -qa pcre
prce
没有显示的时候

输入 : yum install -y pcre pcre-devel

3.查看zlib

输入:rpm -qa zlib
zlib
没有显示的时候输入:

yum install -y zlib zlib-devel

4.查看OpenSSL

输入:rpm -qa|grep -i openssl
openssl
没有的时候输入:

yum install -y openssl openssl-devel

5.获取nginx

进入需要安装nginx的路径:
获取nginx
输入命令:

wget -c https://nginx.org/download/nginx-1.14.0.tar.gz

wget
等待下载完成
然后使用命令:

tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0

!此时开始配置niginx:
输入命令:
./configure --prefix=/usr/local/nginx --user=nobody --group=nobody --with-select_module --with-poll_module --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_sub_module --with-http_stub_status_module --with-http_perl_module --with-http_mp4_module --with-http_flv_module

其中 –prefix 指定nginx的目录 –user=nobody --group=nobody 指定用户 –with-http_mp4_module --with-http_flv_module 如没有视频文件可以不选择

等待运行完成后输入命令:

make&& make install

等待命令运行完成

6.配置niginx.conf

输入:whereis nginx
whereis nginx
获取到nginx路径后

输入命令: cd + {niginx路径} :如: cd /usr/local/nginx

然后输入命令: cd conf/

进入conf文件夹后输入命令:vi nginx.conf

进入文本编辑器

nginx.conf
在http里面的server类里面增加如图所示两个配置
(没有MP4模块的可以跳过)mp4
修改完文件以后按 Esc 键退出 输入命令(冒号是命令要输进去)

:wq

退出以后输入命令:

  cd ../
  cd sbin/

输入 : ./nginx
启动 nginx后查看nginx的状态

./nginx
如果不用yum命令的话就需要一个一个的把需要的环境用rpm包安装进去了,步骤是一样的,只是要安装的应用需要自己逐一去找了。

猜你喜欢

转载自blog.csdn.net/weixin_40577289/article/details/88389768
今日推荐