Question

I'm trying to edit /etc/httpd/conf.d/ssl.conf with bash file I called from PHP 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

but I'm getting this error :

   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

I changed the owner to apache and permission to a+xw of the ssl.conf file but it didn't help .
any idea ?

Was it helpful?

Solution 2

I put hosts in a separate and change owner the whole folder :

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

and those the lines in 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

OTHER TIPS

sed tries to create a temp file... see the errors... and has no permission to write to the directory ( /etc/httpd/conf.d )

see sed command creates randomly named files for possible other solutions

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top