{"id":3845,"date":"2017-07-01T11:42:14","date_gmt":"2017-07-01T03:42:14","guid":{"rendered":"http:\/\/blog.hoyo.idv.tw\/?p=3845"},"modified":"2021-06-29T15:52:28","modified_gmt":"2021-06-29T07:52:28","slug":"centos-7-systemd-%e6%9c%8d%e5%8b%99%e5%8f%8a%e6%aa%94%e6%a1%88%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/blog.hoyo.idv.tw\/?p=3845","title":{"rendered":"CentOS 7 Systemd \u670d\u52d9\u53ca\u6a94\u6848\u7ba1\u7406"},"content":{"rendered":"<p>\u53c3\u8003<\/p>\n<ul>\n<li><a href=\"https:\/\/ssorc.tw\/6064\" target=\"_blank\" rel=\"noopener noreferrer\">CentOS7 \u5df2\u7528 systemd \u53d6\u4ee3\u670d\u52d9\u7684\u555f\u52d5\u3001\u505c\u6b62<\/a><\/li>\n<li><a href=\"https:\/\/kukunotes.wordpress.com\/2014\/11\/09\/centos-7-systemd-temp-files\/\" target=\"_blank\" rel=\"noopener noreferrer\">Centos 7 systemd temp files<\/a><\/li>\n<li><a href=\"https:\/\/access.redhat.com\/documentation\/en-US\/Red_Hat_Enterprise_Linux\/7\/html\/System_Administrators_Guide\/sect-Managing_Services_with_systemd-Unit_Files.html\">9.6. Creating and Modifying systemd Unit Files<\/a><\/li>\n<li><a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-use-systemctl-to-manage-systemd-services-and-units\" target=\"_blank\" rel=\"noopener noreferrer\">How To Use Systemctl to Manage Systemd Services and Units<\/a><\/li>\n<\/ul>\n<p>CentOS 7 \u548c CentOS6 \u6709\u660e\u986f\u5dee\u5225\uff0c\u53ea\u8981\u662f\u56e0\u70ba\u4f7f\u7528\u4e86 Systemd\uff0c\u9664\u4e86\u7ba1\u7406\u670d\u52d9\u7684\u5dee\u7570\u4e4b\u5916\uff0c\u5c0d\u65bc\u4f7f\u7528 PHP \u7684\u6211\u4f86\u8aaa\u9084\u6709\u5176\u4ed6\u7684\u5dee\u5225<\/p>\n<p>--<\/p>\n<pre class=\"lang:default decode:true \">systemctl restart httpd<\/pre>\n<p>--<\/p>\n<h2>Systemd \u5c0d\u65bc PHP \u7684\u5f71\u97ff<\/h2>\n<p>\u8ab0\u7528\u8ab0\u77e5\u9053\uff0c\u99ac\u4e0a\u5c31\u77e5\u9053\u660e\u660e php \u5df2\u7d93\u8a2d\u5b9a\u4e0a\u50b3 tmp path \u70ba \/tmp \uff0c\u53ef\u4e0a\u50b3\u4e2d\u548c\u4e0a\u50b3\u5b8c\u6210\u5f8c\u5728 \/tmp \u5c31\u662f\u770b\u4e0d\u5230\u6a94\u6848\uff0c\u5f9e php \u7a0b\u5f0f\u57f7\u884c\u6642\u5230\u662f\u795e\u5947\u7684\u53ef\u4ee5\u8b80\u53d6\u5230\u6a94\u6848<\/p>\n<p>\u9019\u662f\u56e0\u70ba Systemd \u628a \/tmp \u96b1\u85cf\u8d77\u4f86\u4e86<\/p>\n<p><strong>findmnt<\/strong> - find a filesystem<\/p>\n<pre class=\"lang:default decode:true\">findmnt -N 1787\r\n\r\n\r\nTARGET                                SOURCE            FSTYPE     OPTIONS\r\n\/                                     \/dev\/mapper\/cl-root                                                                                     xfs        rw,relatime,attr2,inode64,noquota\r\n\u251c\u2500\/dev                                devtmpfs          devtmpfs   rw,nosuid,size=1874032k,nr_inodes=468508,mode=755\r\n\u2502 \u251c\u2500\/dev\/shm                          tmpfs             tmpfs      rw,nosuid,nodev\r\n\u2502 \u251c\u2500\/dev\/pts                          devpts            devpts     rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000\r\n\u2502 \u251c\u2500\/dev\/mqueue                       mqueue            mqueue     rw,relatime\r\n\u2502 \u2514\u2500\/dev\/hugepages                    hugetlbfs         hugetlbfs  rw,relatime\r\n\u251c\u2500\/proc                               proc              proc       rw,nosuid,nodev,noexec,relatime\r\n\u2502 \u2514\u2500\/proc\/sys\/fs\/binfmt_misc          systemd-1         autofs     rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct\r\n\u251c\u2500\/sys                                sysfs             sysfs      rw,nosuid,nodev,noexec,relatime\r\n\u2502 \u251c\u2500\/sys\/kernel\/security              securityfs        securityfs rw,nosuid,nodev,noexec,relatime\r\n\u2502 \u251c\u2500\/sys\/fs\/cgroup                    tmpfs             tmpfs      ro,nosuid,nodev,noexec,mode=755\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/systemd          cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,xattr,release_agent=\/usr\/lib\/systemd\/systemd-cgroups-agent,name=systemd\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/hugetlb          cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,hugetlb\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/devices          cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,devices\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/net_cls,net_prio cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,net_prio,net_cls\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/perf_event       cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,perf_event\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/cpu,cpuacct      cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,cpuacct,cpu\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/cpuset           cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,cpuset\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/blkio            cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,blkio\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/pids             cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,pids\r\n\u2502 \u2502 \u251c\u2500\/sys\/fs\/cgroup\/memory           cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,memory\r\n\u2502 \u2502 \u2514\u2500\/sys\/fs\/cgroup\/freezer          cgroup            cgroup     rw,nosuid,nodev,noexec,relatime,freezer\r\n\u2502 \u251c\u2500\/sys\/fs\/pstore                    pstore            pstore     rw,nosuid,nodev,noexec,relatime\r\n\u2502 \u251c\u2500\/sys\/kernel\/config                configfs          configfs   rw,relatime\r\n\u2502 \u2514\u2500\/sys\/kernel\/debug                 debugfs           debugfs    rw,relatime\r\n\u251c\u2500\/run                                tmpfs             tmpfs      rw,nosuid,nodev,mode=755\r\n\u2502 \u2514\u2500\/run\/user\/0                       tmpfs             tmpfs      rw,nosuid,nodev,relatime,size=377048k,mode=700\r\n\u251c\u2500\/boot                               \/dev\/sda1         xfs        rw,relatime,attr2,inode64,noquota\r\n\u251c\u2500\/tmp                                \/dev\/mapper\/cl-root[\/tmp\/systemd-private-30f32c8dfa034e4eaf0d875cfa01b72d-httpd.service-Pp0l24\/tmp]     xfs        rw,relatime,attr2,inode64,noquota\r\n\u2514\u2500\/var\/tmp                            \/dev\/mapper\/cl-root[\/var\/tmp\/systemd-private-30f32c8dfa034e4eaf0d875cfa01b72d-httpd.service-Im15ui\/tmp] xfs        rw,relatime,attr2,inode64,noquota\r\n<\/pre>\n<p>--<\/p>\n<h2>Systemd<\/h2>\n<pre class=\"lang:default decode:true\">cd \/usr\/lib\/systemd\/system\r\ncat httpd.service\r\n\r\n\r\n[Unit]\r\nDescription=The Apache HTTP Server\r\nAfter=network.target remote-fs.target nss-lookup.target\r\nDocumentation=man:httpd(8)\r\nDocumentation=man:apachectl(8)\r\n\r\n[Service]\r\nType=notify\r\nEnvironmentFile=\/etc\/sysconfig\/httpd\r\nExecStart=\/usr\/sbin\/httpd $OPTIONS -DFOREGROUND\r\nExecReload=\/usr\/sbin\/httpd $OPTIONS -k graceful\r\nExecStop=\/bin\/kill -WINCH ${MAINPID}\r\n# We want systemd to give httpd some time to finish gracefully, but still want\r\n# it to kill httpd after TimeoutStopSec if something went wrong during the\r\n# graceful stop. Normally, Systemd sends SIGTERM signal right after the\r\n# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give\r\n# httpd time to finish.\r\nKillSignal=SIGCONT\r\nPrivateTmp=true\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\u00a0PrivateTmp \u9810\u8a2d\u70ba true<\/p>\n<p>--<\/p>\n<h2>\u5c07 HTTPD PrivateTmp \u95dc\u9589<\/h2>\n<pre class=\"lang:default decode:true\"># systemctl edit httpd.service<\/pre>\n<pre class=\"lang:default decode:true\">[Service]\r\nPrivateTmp=false<\/pre>\n<p>\u91cd\u65b0\u555f\u52d5 systemd \u548c httpd<\/p>\n<pre class=\"lang:default decode:true\">systemctl daemon-reload\r\nsystemctl restart httpd<\/pre>\n<p>--<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"3845\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;4,986&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u53c3\u8003 CentOS7 \u5df2\u7528 s...<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"3845\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;4,986&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[285],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3845"}],"collection":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3845"}],"version-history":[{"count":4,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3845\/revisions"}],"predecessor-version":[{"id":8478,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3845\/revisions\/8478"}],"wp:attachment":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}