1

我正在尝试使用从 PHP 调用的 bash 文件编辑 /etc/httpd/conf.d/ssl.conf exec

 #comment those lines in ssl.conf
    sed -i 's/^SSLCertificateFile/#SSLCertificateFile/g' /etc/httpd/conf.d/ssl.conf
    sed -i 's/^SSLCertificateKeyFile/#SSLCertificateKeyFile/g' /etc/httpd/conf.d/ssl.conf

 #uncomment those lines in ssl.conf
     sed -i 's/^#SSLCertificateFile/SSLCertificateFile/g' /etc/httpd/conf.d/ssl.conf
     sed -i 's/^#SSLCertificateKeyFile/SSLCertificateKeyFile/g' /etc/httpd/conf.d/ssl.conf

但我收到此错误:

   sed: couldn't open temporary file /etc/httpd/conf.d/sed3nRibG: Permission denied
   sed: couldn't open temporary file /etc/httpd/conf.d/sed2ASgeG: Permission denied

我将文件的所有者apache和权限更改a+xw为,ssl.conf但没有帮助。
任何想法 ?

4

2 回答 2

0

我将主机放在一个单独的文件夹中,并更改了整个文件夹的所有者:

chown apache:apache /etc/https/conf.d
chown apache:apache /etc/https/conf.d/*

以及 bash 中的那些行:

  #comment those lines in vhosts.conf
    sed -i 's/^SSLCertificateFile/#SSLCertificateFile/g' /etc/httpd/conf.d/vhosts.conf
    sed -i 's/^SSLCertificateKeyFile/#SSLCertificateKeyFile/g' /etc/httpd/conf.d/vhosts.conf

  #uncomment those lines in vhosts.conf
    sed -i 's/^#SSLCertificateFile/SSLCertificateFile/g' /etc/httpd/conf.d/vhosts.conf
    sed -i 's/^#SSLCertificateKeyFile/SSLCertificateKeyFile/g' /etc/httpd/conf.d/vhosts.conf
于 2013-09-08T07:51:09.037 回答
0

sed 尝试创建一个临时文件...查看错误...并且无权写入目录(/​​etc/httpd/conf.d

请参阅sed 命令为可能的其他解决方案创建随机命名的文件

于 2013-08-28T12:52:18.807 回答