<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://www.gentoo-zh.org/extern.php?action=feed&amp;tid=604&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / centos7 nginx]]></title>
		<link>https://www.gentoo-zh.org/viewtopic.php?id=604</link>
		<description><![CDATA[centos7 nginx 最近发表的帖子。]]></description>
		<lastBuildDate>Wed, 07 Dec 2022 06:06:23 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[centos7 nginx]]></title>
			<link>https://www.gentoo-zh.org/viewtopic.php?pid=645#p645</link>
			<description><![CDATA[<p>设置nginx开机自启动（centos7.x）</p><p>第一步：进入到/lib/systemd/system/目录</p><p>[root@localhost ~]# cd /lib/systemd/system/</p><p>第二步：创建nginx.service文件，并编辑</p><p># vim nginx.service</p><p>内容如下：</p><p>[Unit]</p><p>Description=nginx service</p><p>After=network.target</p><p> </p><p>[Service]</p><p>Type=forking</p><p>ExecStart=/usr/local/nginx/sbin/nginx</p><p>ExecReload=/usr/local/nginx/sbin/nginx -s reload</p><p>ExecStop=/usr/local/nginx/sbin/nginx -s quit</p><p>PrivateTmp=true</p><p>&#160; &#160;</p><p>[Install]</p><p>WantedBy=multi-user.target</p><p>[Unit]:服务的说明<br />Description:描述服务<br />After:描述服务类别<br />[Service]服务运行参数的设置<br />Type=forking是后台运行的形式<br />ExecStart为服务的具体运行命令<br />ExecReload为重启命令<br />ExecStop为停止命令<br />PrivateTmp=True表示给服务分配独立的临时空间<br />注意：[Service]的启动、重启、停止命令全部要求使用绝对路径<br />[Install]运行级别下服务安装的相关设置，可设置为多用户，即系统运行级别为3</p><p>保存退出。</p><p>第三步：加入开机自启动</p><p># systemctl enable nginx</p><p>如果不想开机自启动了，可以使用下面的命令取消开机自启动</p><p># systemctl disable nginx</p><p>第四步：服务的启动/停止/刷新配置文件/查看状态</p><p># systemctl start nginx.service&#160; &#160; &#160; &#160; &#160; 启动nginx服务<br /># systemctl stop nginx.service&#160; &#160; &#160; &#160; &#160; &#160;停止服务<br /># systemctl restart nginx.service&#160; &#160; &#160; &#160; 重新启动服务<br /># systemctl list-units --type=service&#160; &#160; &#160;查看所有已启动的服务<br /># systemctl status nginx.service&#160; &#160; &#160; &#160; &#160; 查看服务当前状态<br /># systemctl enable nginx.service&#160; &#160; &#160; &#160; &#160; 设置开机自启动<br /># systemctl disable nginx.service&#160; &#160; &#160; &#160; &#160;停止开机自启动</p><p> <br />一个常见的错误<br />Warning: nginx.service changed on disk. Run &#039;systemctl daemon-reload&#039; to reload units.</p><p>直接按照提示执行命令systemctl daemon-reload 即可。</p><p># systemctl daemon-reload</p>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Wed, 07 Dec 2022 06:06:23 +0000</pubDate>
			<guid>https://www.gentoo-zh.org/viewtopic.php?pid=645#p645</guid>
		</item>
	</channel>
</rss>
