nginx

作者: 随风飞2019 | 来源:发表于2019-03-22 09:14 被阅读0次

1.在CentOS 7上安装Nginx(最简单方式),自行配置yum源
打开http://nginx.org/en/linux_packages.html#RHEL-CentOS
根据提示安装即可
需要注意的是,需要自己写baseurl,选择到x86_64/这一级即可
[nginx]
name=nginx stable
baseurl=http://nginx.org/packages/centos/7/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

systemd服务文件以.service结尾,开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即:/lib/systemd/system/。
比如现在要建立nginx为开机启动,如果用yum install命令安装的,yum命令会自动创建nginx.service文件,直接用命令systemctl enable nginx.service设置开机启动即可。

设置开机启动systemctl enable nginx.service
启动nginx服务systemctl start nginx.service 
停止开机自启动systemctl disable nginx.service
查看服务当前状态systemctl status nginx.service
重新启动服务systemctl restart nginx.service 
查看所有已启动的服务systemctl list-units --type=service

软件安装完成后,运行rpm -ql nginx查看配置文件位置

yum安装的nginx,执行文件路径 /usr/sbin/nginx
配置文件路径/etc/nginx/nginx.conf
如果修改了配置文件,可以先检测文件格式对不对,有没有语法错误
如:/usr/sbin/nginx -c /etc/nginx/nginx.conf -t
格式:nginx -c nginx.conf -t

nginx极简配置:
server {
listen 80;
server_name api.pingda.net;

location / {
    root   /home/html/api;
    index  index.html index.htm;
}

}

相关文章

网友评论

      本文标题:nginx

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