centos7 安装 nginx
Posted 巫小诗
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 安装 nginx相关的知识,希望对你有一定的参考价值。
nginx
环境依赖
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
下载压缩包
wget https://nginx.org/download/nginx-1.14.0.tar.gz
解压
tar zxvf nginx-1.14.0.tar.gz
configure
./configuare
编译和编译安装
make && make install
服务启动
./nginx
查看是否启动
- 查进程
ps aux | grep nginx
- 输入地址看效果
- 查进程
平滑启动
./nginx -s reload
nginx的配置文件
/usr/local/nginx/config/nginx.conf
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; # 后端给前端提供数据的时候,是否将数据进行压缩。 server { listen 80; server_name localhost; location / { root /home; index index.html index.htm; } } include vhost/*.conf; # 以后将server可以写在这个目录里 }
# api.conf server { listen 80; server_name localhost; location / { root /home; index index.html index.htm; } }
以上是关于centos7 安装 nginx的主要内容,如果未能解决你的问题,请参考以下文章