This article describes how to create a bash file to restart the apache server.
Open a terminal window and use the following command to create a new bash script file:
nano restart_apache.sh
Enter the following code into the file:
#!/bin/bash
sudo service apache2 restart
Save the file and exit the text editor by pressing Ctrl + X, then Y, and finally Enter.
Make the script executable by running the following command:
chmod +x restart_apache.sh
To run the script, simply execute the following command in the terminal:
./restart_apache.sh
Note: The above code assumes that you’re using the Apache 2 web server on a Debian-based Linux distribution. If you’re using a different distribution, the service name may differ, for example, in CentOS, the service name is “httpd”.
1 thought on “
How to create a bash file in Linux to restart apache web server?
”