栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

nginx安装部署

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

nginx安装部署

nginx安装部署 1. 首先下载安装包(此次安装使用的是1.18版本)

nginx-1.18.0.tar.gz

2. 解压缩nginx

tar -zxvf nginx-1.18.0.tar.gz

3. 进入nginx-1.18目录进行编译

cd nginx-1.18
./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= option.
(需要安装依赖的pcre、openssl、zlib库)

4. 安装pcre、openssl、zlib库(有yum的可以直接使用yum安装)

yum -y install pcre
yum -y install openssl
yum -y install zlib
(无法使用yum的情况,需要下载安装包)
pcre-8.44.tar.gz
tar zxvf pcre-8.44.tar.gz
tar zxvf openssl-1.1.1l.tar.gz
tar zxvf zlib-1.2.11.tar.gz

5. 编译nginx安装软件(制定安装目录和依赖包位置)

cd nginx-1.18
./configure --prefix=/nginx/nginx --with-openssl=/nginx/openssl-1.1.1l --with-pcre=/nginx/pcre-8.44 --with-zlib=/nginx/zlib-1.2.11
make && make install
*报错:configure: error: Invalid C++ compiler or C++ compiler flags
这是因为系统缺失 gcc-c++ 库,需要使用root安装gcc-c++环境:
yum -y install gcc-c++
yum install -y gcc
完成后再次执行make就可以了

6.启动nginx

cd /nginx/nginx/sbin
./nginx
报错:nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
以非root权限启动时,会出现 nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) 错误,将 /usr/local/nginx/conf/nginx.conf 文件中的80端口改为1024以上(8080)

7. 测试nginx网页访问是否正常

curl http://ip:8080




Welcome to nginx!



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.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/885671.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号