您的位置:首页 > 运维架构 > Nginx

CentOS 7 搭建nginx

2016-07-22 21:09 567 查看

nginx依赖

nginx依赖以下模块:

gzip模块依赖 zlib 库

地址http://www.zlib.net/

我下载的最新版zlib-1.2.8tar.gz,解压,进入目录执行./configure

make

make install

rewrite模块依赖 pcre 库

地址http://www.pcre.org/

【注意】安装pcre库的时候走了个小弯路,现在pcre已经有了pcre2版本、因为我以为2版本也可以、所以先下载的pcre2-10.20.tat.gz版本,结果在安装nginx时提示大概是找不到pcre库,马上又载了个pcre-8.37.tar.gz

跟上面一样,解压 ,进入目录 ./configure

make

make install

ssl 功能依赖openssl的crypto库

地址http://www.openssl.org/source/

openssl我下载的openssl-1.1.0-pre5,默认安装的话libcrypto.so.1.1在/usr/local/lib64/,但是nginx寻找依赖在/lib64/目录下,会导致提示找不到libcrypto.so.1.1,用命令ldd $(which /usr/local/nginx/sbin/nginx)没有libcrypto.so.1.1,所以直接把libcrypto.so.1.1复制到/lib64/目录下,找不到库目录的话安装后可以用 openssl version -a现在安装路径

解压,进入目录执行./configure

make

make install

安装nginx

http://nginx.org/en/download.html上可以下载当前最新的版本。

我下载的nginx-1.10.1.tar.gz,目前是最新的

解压,进入目录,执行./configure

make

make install

1.10.1的执行文件在/usr/local/nginx/sbin/nginx跟旧版有所不同

安装完就可以直接在浏览器访问localhost,就会看到

Welcome to nginx!

If you see this page, the nginx web server is successfully installed >and working. Further configuration is required.

For online documentation and support please refer to nginx.org.

Commercial support is available at nginx.com.

Thank you for using nginx.

配置nginx

配置文件在/usr/local/nginx/conf/nginx.conf,基本配置比较简单

listen 80;默认监听80端口

server_name localhost;服务器地址
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos nginx