centos安装ngix

前端之家收集整理的这篇文章主要介绍了centos安装ngix前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一。安装过程

1》下载

http://tengine.taobao.org/download.html找到下载包并且下载(Tengine-2.2.0.tar.gz

2》解压

tar zxvf Tengine-2.2.0.tar.gz

3》配置检查

进入解压后的目录 ./configure

异常1:
   [root@bogon tengine]# ./configure
checking for OS
 + Linux 3.10.0-327.el7.x86_64 x86_64
checking for C compiler ... not found
 
./configure: error: C compiler cc is not found
也就是c编译器 gcc找不到
  安装gcc  yum -y install gcc
继续检查
异常2:
 checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
 
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
 缺少pcre和pcre-devel 安装 yum -y install pcre pcre-devel
 这里安装好后 可以通过
  Rpm -qa | grep pcre找到所有pcre的包
  Rpm -ql 完整包名  查看安装的路径
 
异常3:
 checking for OpenSSL library ... not found
 缺少openssl和openssl-devel 安装 yum -y install openssl openssl-devel
 
继续检测成功 可以同构日志看到 需要pcre openssl zlib(安装openssl自动安装)的库
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile
 

4》安装

Make && make install 安装完成 安装目录为/usr/local/Nginx

找到 /usr/local/Nginx/sbin/Nginx -V 查看所有加载的模块

[root@bogon sbin]# ./Nginx -V
Tengine version: Tengine/2.2.0 (Nginx/1.8.1)
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
TLS SNI support enabled
configure arguments:
Nginx: loaded modules:
Nginx:     ngx_core_module (static)
Nginx:     ngx_errlog_module (static)
Nginx:     ngx_conf_module (static)
Nginx:     ngx_dso_module (static)
Nginx:     ngx_events_module (static)


5》开机启动Nginx

nigix官网上找到 https://www.Nginx.com/resources/wiki/start/topics/examples/redhatNginxinit/ 查看linux下的启动脚本

进入官网 www.Nginx.com 点击resources-community wiki


进入后 点击 下图 Getting Started按钮进入

点击下界面的Ngix init Scipts

点击 Red hast Nginx init script 即可打开脚本



保存内容到/etc/init.d/Nginx (服务的教程参考http://blog.csdn.net/liaomin416100569/article/details/72876349)

拷贝后 需要修改其中的两个变量Nginx安装目录的配置文件Nginx程序的目录

Nginx="/usr/sbin/Nginx"
prog=$(basename $Nginx)

Nginx_CONF_FILE"/etc/Nginx/Nginx.conf"
修改
"/usr/local/Nginx/sbin/Nginx"
"/usr/local/Nginx/conf/Nginx.conf"

注意 Nginx文件内容是否完整拷贝 有时拷贝 缺少一些字符导致报错

service ngix start 或者 systemctl start Nginx

添加到系统服务 设置开机启动

[root@bogon init.d]# chkconfig --add Nginx
[root@bogon init.d]# chkconfig Nginx on

使用 http://192.168.58.131/访问 看是否出现 欢迎使用tengine的英文

原文链接:https://www.f2er.com/centos/377306.html

猜你在找的CentOS相关文章