2013-08-28 54 views
1

我想在bash的文件,我從PHP exec叫編輯/etc/httpd/conf.d/ssl.conf:的sed不能編輯ssl.conf中拒絕 「權限」

#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和權限的ssl.conf文件a+xw,但它並沒有幫助。
有什麼想法?

回答

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