Use a configuration management system to deploy these changes, and include a trigger to automatically restart services whose config files have changed.
It's very much worth getting into the habit of using CM now while you're learning, as it'll be much harder to un-learn bad habits later on in your career.
To get you started, here's a simple ansible playbook that will deploy an nginx config file to your server and then restart nginx if anything changed:
---
- hosts: web
sudo: yes
tasks:
- name: Install packages
apt: state=installed install_recommends=no name={{ item }}
with_items:
- nginx
- name: Deploy nginx config file
copy: src=nginx.conf dest=/etc/nginx/nginx.conf
notify: restart nginx
handlers:
- name: restart nginx
service: name=nginx state=restarted
Save that text into a file like foo.yml
. You'll also need an inventory file to tell ansible what host(s) to run these commands on. Create a hosts
file with contents like:
[web]
servername.example.com
Save your playbook, the inventory file, and your nginx.conf in the same directory.
Then you can apply the playbook:
$ ansible-playbook foo.yml -i hosts -K
After issuing that command, you'll be asked for your sudo password. Provide it, and then the playbook will run.