Nginx安装、配置

一、linux 安装环境
1、 需要安装 gcc 的环境。 yum install gcc-c++
2、 第三方的开发包。
PCRE
PCRE(Perl Compatible Regular Expressions) 是一个 Perl 库,包括 perl 兼容的正则表达式库。 nginx http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库。
yum install -y pcre pcre-devel
注: pcre-devel 是使用 pcre 开发的一个二次开发库。 nginx 也需要此库。
zlib
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib http 包的内容进行 gzip ,所以需要在 linux 上安装 zlib 库。
yum install -y zlib zlib-devel
openssl
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https (即在 ssl 协议上传输 http ),所以需要在 linux 安装 openssl 库。
yum install -y openssl openssl-devel
 
二、 安装步骤
 
第一步:把 nginx 的源码包上传到 linux 系统
第二步:解压缩
[root@localhost ~]# tar zxf nginx-1.8.0.tar.gz
第三步:使用 configure 命令创建一 makeFile 文件。
prefix指定安装路径
./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
注意:启动 nginx 之前,上边将临时文件目录指定为 /var/temp/nginx ,需要在 /var 下创建 temp nginx 目录
[root@localhost sbin]# mkdir /var/temp/nginx/client -p
第四步: make
第五步: make install
 

 
三、 启动 nginx
sbin 目录下执行 ./nginx 即可启动
[root@localhost sbin]# ./nginx
启动后,通过 ps aux | grep nginx 命令需要查看到两个进程 master 和 worker。

 
关闭 nginx
[root@localhost sbin]# ./nginx -s stop
推荐使用:
[root@localhost sbin]# ./nginx -s quit
 
重启 nginx
1、 先关闭后启动。
2、 刷新配置文件:
[root@localhost sbin]# ./nginx -s reload
Nginx 的配置文件路径:
/nginx/conf/nginx.conf
 
四、 访问 nginx


 
默认是 80 端口。
注意:是否关闭防火墙。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值