I'm trying to write a little shell script to go through the steps needed to enable apache and php on a new install of Mountain Lion. The step I'm stuck on is going into /etc/apache2/httpd.conf
and uncommenting this line: #LoadModule php5_module libexec/apache2/libphp5.so
From googling around so far I think sed is the way this would be done, but I can't get the syntax right. I tried this:
cd /etc/apache2
sudo sed -i '/s/#LoadModule php5_module libexec\/apache2\/libphp5.so/LoadModule php5_module libexec\/apache2\/libphp5.so' httpd.conf
which I thought would replace the commented line (escaping the slashes) with the uncommented line. But when I run that, I just get the following message back, and no result in the file:
sed: 1: "httpd.conf": extra characters at the end of h command
I'm out of my depth here with this type of scripting, how do I accomplish this task?
You can use comma.
sed -i 's,#LoadModule php5_module libexec/apache2/libphp5.so,LoadModule php5_module libexec/apache2/libphp5.so,g'
or
sed -i 's,#\(LoadModule php5_module libexec/apache2/libphp5.so\),\1,g' foo.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With