centos java nginx_CentOS7配置Nginx服务

目标

创建用户

sudo useradd --system --home /var/nginx --shell /sbin/nologin --comment "nginx user" --user-group nginx

授权文件夹

chown -R nginx /var/nginx

chgrp -R nginx /var/nginx

systemd

vim /usr/lib/systemd/system/nginx.service

[Service]

User=nginx

Group=nginx

Type=forking

ExecStartPre=/var/nginx/sbin/nginx -t -c /var/nginx/conf/nginx.conf

ExecStart=/var/nginx/sbin/nginx -c /var/nginx/conf/nginx.conf

ExecReload=/var/nginx/sbin/nginx -s reload

ExecStop=/var/nginx/sbin/nginx -s stop

ExecQuit=/var/nginx/sbin/nginx -s quit

[Install]

WantedBy=multi-user.target

firewall

firewall-cmd --zone=public --add-port=8081/tcp --permanent

firewall-cmd --reload

验证

systemctl daemon-reload

systemctl start nginx.service

[root@zyl nginx]# systemctl status nginx.service

● nginx.service - nginx - high performance web server

Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)

Active: active (running) since 日 2018-12-23 14:29:48 CST; 9min ago

Docs: https://nginx.org/en/docs/

Process: 62130 ExecStart=/var/nginx/sbin/nginx -c /var/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)

Process: 62126 ExecStartPre=/var/nginx/sbin/nginx -t -c /var/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)

Main PID: 62132 (nginx)

Tasks: 2

CGroup: /system.slice/nginx.service

├─62132 nginx: master process /var/nginx/sbin/nginx -c /var/nginx/conf/nginx.conf

└─62133 nginx: worker process

12月 23 14:29:48 BPC systemd[1]: Starting nginx - high performance web server...

12月 23 14:29:48 BPC nginx[62126]: nginx: the configuration file /var/nginx/conf/nginx.conf syntax is ok

12月 23 14:29:48 BPC nginx[62126]: nginx: configuration file /var/nginx/conf/nginx.conf test is successful

12月 23 14:29:48 BPC systemd[1]: Started nginx - high performance web server.

浏览器效果:

b75be16a7ee571baee30fc9d3cfe9fdc.png

参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值