首页 > 系统相关 >Nginx 安装

Nginx 安装

时间:2023-09-23 13:57:28浏览次数:46  
标签:nginx -- 安装 zlib Nginx usr local

Nginx 安装

版本区别

常用版本分为四大阵营

安装 Nginx

安装环境

yum install -y gcc
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel

编译安装

./configure --prefix=/usr/local/nginx && make && make install

安装成系统服务

创建服务脚本

vi /usr/lib/systemd/system/nginx.service

服务脚本内容

[Unit]
Description=nginx - web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target

重新加载系统服务

systemctl daemon-reload

启动服务

systemctl start nginx.service

开机启动

systemctl enable nginx.service

启动 Nginx

进入安装好的目录 /usr/local/nginx/sbin

./nginx 启动
./nginx -s stop 快速停止
./nginx -s quit 优雅关闭,在退出前完成已经接受的连接请求
./nginx -s reload 重新加载配置

关于防火墙

关闭防火墙

systemctl stop firewalld.service

禁止防火墙开机启动

systemctl disable firewalld.service

放行端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

重启防火墙

firewall-cmd --reload

如果出现警告或报错

提示

checking for OS
+ Linux 3.10.0-693.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found

安装 gcc

提示

./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.

安装perl库

提示:

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

安装zlib库

标签:nginx,--,安装,zlib,Nginx,usr,local
From: https://www.cnblogs.com/liuzonglin/p/17724299.html

相关文章

  • 安装Keepalived
    安装Keepalived编译安装下载地址KeepalivedforLinux安装依赖yuminstallopenssl-devel使用./configure编译安装如遇报错提示configure:error:!!!OpenSSLisnotproperlyinstalledonyoursystem.!!!!!!CannotincludeOpenSSLheadersfiles.!!!yum......
  • Centos7.9+Oracle11g 单机文件系统安装注意事项
    数据库软件(上传至/root目录)p13390677_112040_Linux-x86-64_1of7p13390677_112040_Linux-x86-64_2of7其他软件包(上传至/root目录)compat-libstdc++-33-3.2.3-72.el7.x86_64.rpmpdksh-5.2.14-37.el5_8.1.x86_64.rpm安装软件包#安装compat包rpm-ivhcompat-libstdc++-33-3.2.3-72.el7......
  • Redis安装
    Redis安装‍我们这里还是使用Windows安装Redis服务器,但是官方指定是安装到Linux服务器上,我们后面学习了Linux之后,再来安装到Linux服务器上。由于官方并没有提供Windows版本的安装包,我们需要另外寻找:官网地址:https://redis.ioGitHubWindows版本维护地址:https://github.com/tp......
  • docker-compose 安装 redis
    docker-compose安装redisversion:"3.5"services:lcloud-redis:image:redis:6.2container_name:lcloud-redisrestart:alwaysports:-6379:6379安装运行#docker-composeup-d--build......
  • Docker 部署 Nginx
    Docker部署Nginxdockerpullnginx:latestDocker来部署一个Nginx服务器dockerrun--restart=always-dp80:80-v./nginx/logs:/var/log/nginx-v/etc/localtime:/etc/localtime--namelcloud-nginxnginx:latest可以看到,Nginx服务器已经成功部署了,但是实际上我们并没......
  • Docker 安装 MongoDB
    Docker安装MongoDB使用Docker-Compose安装MongoDB-MasonLee-博客园(cnblogs.com)[root@localhost~]#dockerpullmongo:latestlatest:Pullingfromlibrary/mongoDigest:sha256:5be752bc5f2ac4182252d0f15d74df080923aba39700905cb26d9f70f39e9702Status:Imagei......
  • docker 安装 nacos
    docker安装nacos拉取镜像dockerpullnacos/nacos-server设置mkdir-p./nacos/{init.d,logs}touch./nacos/init.d/custom.properties运行容器dockerrun-d-p8848:8848-eMODE=standalone-ePREFER_HOST_MODE=hostname-v./nacos/init.d/custom.properties:/ho......
  • Docker 安装可视化工具 Portainer 中文版
    Docker安装可视化工具Portainer中文版参考文档:安装中文版portainer-ce-简书(jianshu.com)(21条消息)Docker可视化工具Portainer的安装和使用_琦彦的博客-CSDN博客安装中文版portainer-ce-简书(jianshu.com)(21条消息)Docker可视化工具Portainer的安装和使用_琦......
  • Docker 安装 Elasticsearch
    Docker安装Elasticsearch1.拉取镜像:sudodockerpullelasticsearch:8.6.22.创建docker容器挂载目录:sudomkdir-pv/home/zonglin/elasticsearch/configsudomkdir-pv/home/zonglin/elasticsearch/datasudomkdir-pv/home/zonglin/elasticsearch/pluginsmkdir......
  • 5-IK分词器安装
    ES的默认分词设置的是standard,会单字拆分进行拆分。POST_analyze{"analyzer":"standard","text":"我是中国人"}概述IKAnalyzer是一个开源的,基于Java语言开发的轻量级的中文分词工具包。下载Ik分词器下载地址:https://github.com/medcl/elasticsearch-anal......