Linux CentOs安装nginx

首先要安装 PCRE

PCRE 作用是让 Nginx 支持 Rewrite 功能。

1、下载 PCRE 安装包,下载地址:

http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

[root@bogon src]# cd /usr/local
[root@bogon src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

2、解压安装包:

[root@bogon src]# tar zxvf pcre-8.35.tar.gz
3、进入安装包目录

[root@bogon src]# cd pcre-8.35
4、编译安装 

[root@bogon pcre-8.35]# ./configure
[root@bogon pcre-8.35]# make && make install
5、查看pcre版本

[root@bogon pcre-8.35]# pcre-config --version

安装Nginx

1:安装wget,用来下载nginx安装包

cd /
yum install wget -y

2:因为Nginx以来与gcc的编译环境,所以,在mini centos中需要安装编译环境来使Nginx能够编译起来

yum install gcc-c++

3:Nginx的http模块需要使用pcre来解析正则表达式

yum -y install pcre pcre-devel

4:依赖的解压包

yum -y install zlib zlib-devel

5:openssl安装

yum install -y openssl openssl-devel

解压

tar -zxvf nginx-1.14.2.tar.gz

移动

mv nginx-1.14.2 /usr/local/nginx

进入

cd /usr/local/nginx

配置

#./configure --prefix=/usr/local/nginx

./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.35 --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module
./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.43 --with-http_v2_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --with-stream

make

make
make install

测试是否安装成功

cd到刚才配置的安装目录

/usr/loca/nginx/
./sbin/nginx -t

错误信息:

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2016/09/13 19:08:56 [emerg] 6996#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)

原因分析:nginx/目录下没有logs文件夹

解决方法:

mkdir logs
chmod 700 logs

正常情况的信息输出:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

启动nginx

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

在浏览器中输入服务器的ip地址,如:192.168.1.12Nginx

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值