I know how to find and replace a section in a config file like this:
sudo sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 3M/" /etc/php5/cgi/php.ini
But how do I add a whole new section to the end of the config file within the bash script?
server {
listen xx.xx.xx.xx:80; # your server's public IP address
server_name myapp.com; # your domain name
root /usr/share/nginx/www/myapp/; # absolute path to your WordPress installation
}
I tried this within the terminal echo "server { ... }" >> nginx.conf but I get a
-bash: nginx.conf: Permission denied
Not sure if this would be ok within the bash script or I would get a permission denied again…
You are using the right syntax.
Just make sure you have the correct write permissions for ‘ngix.conf’.
This indicates that you have no write privileges.
You can also write the section in an single file like ‘new_section.txt’ and late add it with:
However I would not advise to add configurations to ngix in this way.
You can use the ‘include’ statement.
This way you can group the configuration and have some small config files and not one huge file. Then you can also name your file in a way that helps you find the right one.