center os 7 安装nginx

安装配置nginx

1、下载安装包nginx1.10.3

1.2---解压到/usr/local

1.3---进入目录 执行./configure

# ./configure,

报错:

 

出现这个错误,是因为gcc包没有安装

# yum -y install gcc

# whereis gcc

 

安装gcc之后,运行./configure,

报错:

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using --with-pcre=<path> option.

 

安装pcre-devle 解决问题 

# yum -y install pcre-devel  

(这里我顺便安装了openssl  # yum -y install pcre-devel openssl openssl-devel )

执行 ./configure

 

如果报错:

...Require the zlib library

...

则执行安装

# yum install zlib-devel -y

 

1.4 -- opensslsha1

如果你想使用openssl功能 sha1功能 那么需要安装opensslsha1

# yum install openssl openssl-devel

开启ssl模块 :

# ./configure --with-http_ssl_module

 

 

启用”server_status”页

# ./configure --with-http_stub_status_module

 

上述两条命令同时启用 可以使用如下命令:

# ./configure --with-http_stub_status_module --with-http_ssl_modile

 

1.5--##编译 安装

上面configure就通过了

执行make make install 命令 ##编译 安装

# make   

# make install

至此,nginx执行成功了。

 

1.6--配置环境变量

# whereis nginx

nginx:/usr/local/nginx

 

/etc/profile 中加入配置

# vim /etc/profile

在配置文件中加入:

#nginx configure

export NGINX_HOME=/usr/local/nginx

export PATH=$PATH:$NGINX_HOME/sbin

编译完保存退出

 

# source /etc/profile

使配置生效 

整个过程,就安装成功了

 

修改nginx,conf

2.1 启动nginx

# cd /usr/local/nginx

# nginx -c conf/nginx.conf

启动成功后,将在浏览器打开 ip加端口号  默认端口号是80

用浏览器打开看到带有welcome to nginx 的页面

 

posted @ 2018-05-11 11:38  hanyj  阅读(2595)  评论(0编辑  收藏  举报