信息展示网站系统,游戏开发代码,网站排名优化怎么样,怎么做服务器网站下载链接正常是两种安装方式
一种是使用系统的包管理软件#xff0c;比如centos的yum -y install nginx命令#xff08;简单但不推荐#xff0c;配置文件分散不易管理#xff0c;且需要配置第三方源yum -y install epel-release等#xff0c;如果是简单使用#xff0c;配置文件什…
正常是两种安装方式
一种是使用系统的包管理软件比如centos的yum -y install nginx命令简单但不推荐配置文件分散不易管理且需要配置第三方源yum -y install epel-release等如果是简单使用配置文件什么的都不改做一些测试使用之类的任务还是比较方便的总的来说看自己需求第二种是通过源码编译安装的方式推荐可以自定义配置文件存放位置自主选择安装版本等。 前往nginx官网 文章目录 1. 包管理软件安装1.1 redhat系列1.2 debian系列 2. 源码安装2.1 选择需要的版本2.2 编译安装2.2.1获取源码2.2.2编译安装 2.3 创建软链接2.3.1 四个目录 2.4 设置自启动2.4.1新建nginx服务2.4.2验证自启动2.4.3启动失败2.4.3.1查看状态2.4.3.2检查端口占用2.4.3.3重启2.4.3.4检查状态 3.常用命令3.1启动3.2停止3.3检查文件3.4重载配置文件3.5开启、停止、重启服务 4. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)4.1查看状态4.2检查端口占用4.3重启4.4检查状态 补充再不行就关掉防火墙不推荐 1. 包管理软件安装 1.1 redhat系列
# 安装第三方源
yum -y install epel-release
# 安装nginx(安装源内最新版不一定是官网最新版)
yum -y install nginx1.2 debian系列
# 安装nginx(安装源内最新版不一定是官网最新版)
apt -y install nginx2. 源码安装
各Linux发行版本通用
2.1 选择需要的版本
nginx历史版本 选择一个版本比如1.8.0在legacy versions中选中nginx-1.18.0右键选择复制链接地址
2.2 编译安装
2.2.1获取源码
# 下载到本地wget [复制的地址链接] -P [存放地址]
wget http://nginx.org/download/nginx-1.18.0.tar.gz -P /usr/local/src/
cd /usr/local/src
tar xzvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
# 查看帮助
./configure --help2.2.2编译安装
# 下载环境依赖
yum -y install gcc pcre-devel openssl-devel zlib-develuseradd -r -s /sbin/nologin nginx# 下面一块是一个整体复制进终端当前目录在/usr/local/src/nginx-1.18.0
./configure --prefix/apps/nginx \
--usernginx \
--groupnginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module# 编译安装
make -j 2 make install
chown -R nginx.nginx /apps/nginx2.3 创建软链接
ln -s /apps/nginx/sbin/nginx /usr/bin/
# 查看版本信息
nginx -v2.3.1 四个目录
/apps/nginx ├── conf ├── html ├── logs └── sbin
conf 配置文件html web文件logs 日志信息sbin 可执行脚本
2.4 设置自启动
2.4.1新建nginx服务
vim /usr/lib/systemd/system/nginx.service# 复制下面到/usr/lib/systemd/system/nginx.service中
[Unit]
DescriptionThe nginx HTTP and reverse proxy server
Documentationhttp://nginx.org/en/docs/
Afternetwork.target remote-fs.target nss-lookup.target
Wantsnetwork-online.target
[Service]
Typeforking
PIDFile/apps/nginx/run/nginx.pid
ExecStart/apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf
ExecReload/bin/kill -s HUP $MAINPID
ExecStop/bin/kill -s TERM $MAINPID
[Install]
WantedBymulti-user.targetmkdir /apps/nginx/run/
vim /apps/nginx/conf/nginx.conf# 复制下面到/apps/nginx/conf/nginx.conf中可以解开注释并修改或者直接复制进去
pid /apps/nginx/run/nginx.pid;2.4.2验证自启动
systemctl daemon-reload
systemctl enable nginx
ll /apps/nginx/run
# 存在pid文件2.4.3启动失败
2.4.3.1查看状态 2.4.3.2检查端口占用 2.4.3.3重启 2.4.3.4检查状态 3.常用命令
nginx官方文档
3.1启动
# 直接nginx
nginx3.2停止
nginx -s stop3.3检查文件
验证文件是否正确
nginx -t3.4重载配置文件
nginx -s reload3.5开启、停止、重启服务
systemctl start nginx
systemctl stop nginx
systemctl restart nginx4. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
出现的可能性比较大单独拎出来和上文内容一样
4.1查看状态 4.2检查端口占用 4.3重启 4.4检查状态 补充再不行就关掉防火墙不推荐
systemctl stop firewalld