Centos7安装Nginx
1.安装nginx
#pm -ivh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.2-1.el7.ngx.x86_64.rpm
备注:其实根据上面这个网址(http://nginx.org/packages/)可以进去其nginx官方的的包管理列表,选择合适的系统和包
2.启动nginx
# systemctl start nginx
// 验证是否启动成功
# curl http://127.0.0.1:80 // 正常会返回html代码
或者可以使用
#ps -ef | grep nginx //正常会返回多个nginx相关的信息,没启动则返回一个
启动了:
[root@localhost ~]# ps -ef | grep nginx
root 955 1 0 18:55 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 959 955 0 18:55 ? 00:00:00 nginx: worker process
root 2115 2053 0 18:56 pts/0 00:00:00 grep --color=auto nginx
没启动:
[root@localhost ~]# ps -ef | grep nginx
root 2128 2053 0 18:56 pts/0 00:00:00 grep --color=auto nginx
3.设置nginx开机启动
# systemctl enable nginx
4.nginx常用操作
// 服务状态
# systemctl status nginx
// 服务启动
# systemctl start nginx
// 服务停止
# systemctl stop nginx
// 服务重启
# systemctl restart nginx
5.相关路径
//nginx路径
/usr/sbin/nginx
//nginx配置文件路径
/etc/nginx/conf.d/default.conf