美文网首页
centos7 nginx配置

centos7 nginx配置

作者: 花开半時偏妍 | 来源:发表于2020-07-06 11:24 被阅读0次

1.下载必备组件

1.1 gcc编译器
检查安装:yum list installed | grep gcc
执行安装:yum install gcc -y
1.2 openssl库
检查安装:yum list installed | grep openssl
执行安装:yum install openssl openssl-devel -y
1.3 pcre库
检查安装:yum list installed | grep pcre
执行安装:yum install pcre pcre-devel -y
1.4 zlib库
检查安装:yum list installed | grep zlib
执行安装:yum install zlib zlib-devel -y
1.5 一次性安装所有组件
一次性安装: yum install gcc openssl openssl-devel pcre pcre-devel zlib zlib-devel -y

2.下载nginx安装包

(可自行官网下载解压包或wget下载等)

wget -c https://nginx.org/download/nginx-1.12.0.tar.gz
2.1 解压
tar -zxvf nginx-1.12.0.tar.gz
2.2 进入目录
cd nginx-1.12.0
2.3 配置

可使用 -prefix 指定目录(默认/usr/local/nginx)

./configure
2.4 编译
make
2.5 安装
make install
2.6 查找安装路径
whereis nginx

3. 启动关闭重启等

./nginx --启动
./nginx -s stop --停止
./nginx -s quit
./nginx -s reload

4.修改80端口映射到8080端口请求

找到nginx.conf文件

cd /usr/local/nginx/conf
vi nginx.conf

增加映射路径

server {
    listen       80;
     server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}
 
    location / {
    proxy_pass http://127.0.0.1:8080;
        }

配置完成!其余需要了解的参数自行百度~

相关文章

网友评论

      本文标题:centos7 nginx配置

      本文链接:https://www.haomeiwen.com/subject/otrwqktx.html