Editing Apache & NGINX Config files
List all open files on port 80
lsof -i tcp:80 -Pn
Apache
SSH into your server and go to
cd ../etc/apache2/sites-available/
This depends on how your VHOST is configured.
Edit the httpd.conf file, or in my case the httpd.conf is called yourdomain.com
vim yourdomain.com
Make your changes and save
Test Apache before reloading the config file
apachectl -t
Assuming there are now issues, reload the config file
/etc/init.d/apache2 reload
NGINX
Navigate to the config file
cd ../etc/nginx/sites-available or cd ../etc/nginx/conf.d
Edit your .conf file as before and save
EG: Redirect a page to a new URL removing any query strings in the process by adding a trailing ? to the new url
rewrite ^/old-page\.html$ https://newsite.com? permanent;
Test NGINX before reloading
/etc/init.d/nginx configtest
Assuming there are now issues, reload the config file
/etc/init.d/nginx reload
Depending on the OS version, you may need to use systemctl as init has been mostly deprecated.
nginx -t systemctl reload nginx systemctl status nginx systemctl status nginx systemctl restart nginx