{"id":7240,"date":"2023-02-05T18:12:13","date_gmt":"2023-02-05T18:12:13","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=7240"},"modified":"2023-02-05T18:12:13","modified_gmt":"2023-02-05T18:12:13","slug":"how-to-create-a-bash-file-in-linux-to-restart-apache-web-server","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2023\/02\/05\/how-to-create-a-bash-file-in-linux-to-restart-apache-web-server\/","title":{"rendered":"How to create a bash file in Linux to restart apache web server?"},"content":{"rendered":"\n<p>This article describes how to create a bash file to restart the apache server.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Open a terminal window and use the following command to create a new bash script file:<\/p>\n\n\n\n<p><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnano restart_apache.sh\n\n<\/pre><\/div>\n\n\n<p>Enter the following code into the file:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: arduino; title: ; notranslate\" title=\"\">\n#!\/bin\/bash\n\nsudo service apache2 restart\n\n<\/pre><\/div>\n\n\n<p>Save the file and exit the text editor by pressing Ctrl + X, then Y, and finally Enter.<\/p>\n\n\n\n<p>Make the script executable by running the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nchmod +x restart_apache.sh\n\n<\/pre><\/div>\n\n\n<p>To run the script, simply execute the following command in the terminal:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.\/restart_apache.sh\n\n<\/pre><\/div>\n\n\n<p>Note: The above code assumes that you&#8217;re using the Apache 2 web server on a Debian-based Linux distribution. If you&#8217;re using a different distribution, the service name may differ, for example, in CentOS, the service name is &#8220;httpd&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article describes how to create a bash file to restart the apache server.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-7240","post","type-post","status-publish","format-standard","hentry","category-administration"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/7240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=7240"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/7240\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=7240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=7240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=7240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}