centos7 yum 安装 nginx
1. 添加 Nginx 到 YUM 源
添加 CentOS 7 Nginx yum 资源库, 打开终端, 使用以下命令:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2. 安装 Nginx
在你的 CentOS 7 服务器中使用 yum 命令从 Nginx 源服务器中获取来安装 Nginx:
yum install -y nginx
Nginx 将完成安装在你的 CentOS 7 服务器中.
3. 启动 Nginx
刚安装的 Nginx 不会自行启动. 运行 Nginx:
systemctl start nginx.service
如果一切进展顺利的话, 现在你可以通过你的域名或 IP 来访问你的 web 页面来预览一下 Nginx 的默认页面;
nginx_default
如果看到这个页面, 那么说明你的 CentOS 7 中 web 服务器已经正确安装.
CentOS 7 开机启动 Nginx
sudo systemctl enable nginx.service
更多 systemctl 命令可查看systemctl 命令用法
Nginx 配置信息
网站文件存放默认目录
/usr/share/nginx/html
网站默认站点配置
/etc/nginx/conf.d/default.conf
自定义 Nginx 站点配置文件存放目录
/etc/nginx/conf.d/
Nginx 全局配置
/etc/nginx/nginx.conf
Nginx 启动
nginx -c nginx.conf
在这里你可以改变设置用户运行 Nginx 守护程序进程一样, 和工作进程的数量得到了 Nginx 正在运行, 等等.
来源: http://www.bubuko.com/infodetail-2732459.html