{"id":89,"date":"2019-11-25T10:55:59","date_gmt":"2019-11-25T10:55:59","guid":{"rendered":"http:\/\/tiruppurwebhosting.com\/blog\/?p=89"},"modified":"2019-11-28T11:21:59","modified_gmt":"2019-11-28T11:21:59","slug":"how-to-fix-common-issues-in-apache-web-server","status":"publish","type":"post","link":"https:\/\/tiruppurwebhosting.com\/blog\/how-to-fix-common-issues-in-apache-web-server\/","title":{"rendered":"how to fix common issues in apache web server"},"content":{"rendered":"<p>This post will \u00a0provides troubleshooting guidelines for the Apache web server. Apache is a highly customize able tool for serving HTTP traffic. Because it allows for so many different configurations and settings in so many different places, sometimes Apache configuration can befuddle even advanced users.<\/p>\n<p>In this guide, you\u2019ll start with some basic troubleshooting steps and then proceed to more advanced techniques that can help you untangle conflicting directives. We recommend starting at the beginning of this guide and going through it in order. By the time you\u2019re done, you should be able to debug your Apache installation.<\/p>\n<h3>Is Apache Running?<\/h3>\n<p>First, \u00a0we want to check whether Apache is running.\u00a0If it isn\u2019t, go ahead and restart Apache,You may also want to investigate the possibility of \u00a0memory issues\u00a0if Apache is stopping unexpectedly.<\/p>\n<h3 class=\"western\">Restarting Apache<\/h3>\n<p>Even if Apache is running, it can be useful to restart the server. This will let you read the Apache start-up message. If you get an error, you can use the text of the error in an online search to help you find more details and solutions. Restarting the server may produce several seconds of downtime.<\/p>\n<p>Debian and Ubuntu:<\/p>\n<p class=\"western\">sudo service apache2 restart<\/p>\n<p>Fedora and CentOS:<\/p>\n<p class=\"western\">sudo service httpd restart<b><\/b><\/p>\n<p>You can use one of the following three commands instead, depending on your Linux distribution:<\/p>\n<p>etc\/init.d\/httpd restart<\/p>\n<p class=\"western\">\/etc\/init.d\/apache2 restart<\/p>\n<p class=\"western\">\/etc\/rc.d\/httpd restart<\/p>\n<h3>Reloading Apache<\/h3>\n<p>Restarting or reloading Apache is also useful if you\u2019ve recently made changes to your server, but they don\u2019t seem to be taking effect. This is true for changes made directly in the Apache configuration files, as well as for changes you\u2019ve made to the configuration for a dynamic language like \u00a0mod_python, mod_rails\u00a0(for example, Phusion Passenger, or mod_rack)\u00a0mod_ruby,\u00a0etc. These interfaces cache code internally, and do not reread scripts on new requests.<\/p>\n<p>Reloading makes Apache reread its configuration files and incorporate the changes without a full restart, which avoids web server downtime. To reload Apache\u2019s configuration, run the following command:<\/p>\n<p>Debian and Ubuntu:<\/p>\n<p>\/etc\/init.d\/apache2 reload<\/p>\n<p>Fedora and CentOS:<\/p>\n<p>\/etc\/init.d\/httpd reload<\/p>\n<h3>Checking the Logs<\/h3>\n<p>The best place to check for Apache errors is the Apache error logs. To view the error logs, we recommend using the tail command with the-f flag, which shows you the most recent part of the log live as it\u2019s updated. Example:<\/p>\n<p>tail -f \/var\/log\/apache2\/error.log<\/p>\n<p>The default error log locations are: Type\u00a0CTRL-C\u00a0to exit the live log.<\/p>\n<p>Debian and Ubuntu:<\/p>\n<p>\/var\/log\/apache2\/error.log<\/p>\n<p>Fedora and CentOS:<\/p>\n<p>\/var\/log\/httpd\/error_log<\/p>\n<p>The access logs can also help you find specific information about visitors to your server. The default access log locations are:<\/p>\n<p>Debian and Ubuntu:<\/p>\n<p>\/var\/log\/apache2\/access.log<\/p>\n<p>Fedora and CentOS:<\/p>\n<p>\/var\/log\/httpd\/access_log<\/p>\n<h3>Enabling Verbose Logs<\/h3>\n<p>Sometimes it can be helpful to see extra information from Apache. You can increase the amount of detail shown in the logs by changing the log level.<\/p>\n<p>Open your Apache configuration file for editing. The Fedora and CentOS configuration file should be located at \/etc\/httpd\/httpd.conf. This example shows the location of the Debian and Ubuntu configuration file:<\/p>\n<p>sudo nano \/etc\/apache2\/apache2.conf<\/p>\n<p>Remember to set the Log Level back to warn when you\u2019re done troubleshooting, or your server may fill up with logs.Locate the\u00a0Log Level variable, and update it from the default warn to info or debug. Debug will produce the greatest amount of output.<\/p>\n<p>\/etc\/apache2\/apache2.conf<\/p>\n<p># LogLevel: Control the number of messages logged to the error_log.<\/p>\n<p># Possible values include: debug, info, notice, warn, error, crit,<\/p>\n<p># alert, emerg.<\/p>\n<p># LogLevel debug<\/p>\n<h3>Restart Apache:<\/h3>\n<p>sudo service apache2 restart<\/p>\n<p>Perform the operation that was giving you trouble, then check the logs for more detailed information and errors.<\/p>\n<h3>Checking Syntax<\/h3>\n<p>Apache includes a nice little syntax checking tool. Use it to make sure you aren\u2019t missing any brackets in your configuration files (and similar problems).<\/p>\n<p>Debian and Ubuntu:<\/p>\n<p>apache2ctl -t<\/p>\n<p>Fedora and CentOS:<\/p>\n<p>httpd -t<\/p>\n<h3>Checking Virtual Host Definitions<\/h3>\n<p>Another helpful Apache tool lets you see all the virtual hosts on the server, their options, and the file names and line numbers of where they are defined. This will help you inventory all the<\/p>\n<p>domains that are configured on your host. It will also help you locate the correct file where you should update the configuration details for a domain, if you\u2019re not quite sure where you originally put them.<\/p>\n<p>Debian and Ubuntu:<\/p>\n<p>apache2ctl -S<\/p>\n<p>Fedora and CentOS:<\/p>\n<p>httpd -S<\/p>\n<p>Make sure all your\u00a0&lt;VirtualHost&gt; directives use IP addresses and port numbers that match the ones defined in the NameVirtualHost directives.<\/p>\n<p>For example, if you have set NameVirtualHosts *:80, then the virtual host configuration should begin with &lt;VirtualHost *:80&gt;.<\/p>\n<p>If you\u2019ve set NameVirtualHosts 123.234.123.234:80, then the virtual host configuration should begin with &lt;VirtualHost 123.234.123.234:80&gt;.<\/p>\n<p>If you\u2019ve set NameVirtualHosts , then the virtual host configuration should begin with &lt;VirtualHost*&gt;\u00a0You can have multiple NameVirtualHost values, which is what you\u2019ll need to do if you\u2019re running sites on multiple IPs and ports. Just make sure the &lt;VirtualHost&gt; configurations correspond to the configured NameVirtualHostdirectives.<\/p>\n<h3>Troubleshooting Conflicting Directives<\/h3>\n<p>If you\u2019ve modified a configuration option, and you\u2019re still not seeing it take effect even after reloading the server configuration, it\u2019s possible that the new option may have been overridden by a conflicting directive. The main point to remember is that later directives override conflicting earlier ones. So, the directive that is read the latest will always be the one that takes effect.<\/p>\n<p>These points should help clarify the order in which directives are read:<\/p>\n<ul>\n<li>Remember that included files are read at the point of their inclusion, before the rest of the original file is read.<\/li>\n<li>&lt;Directory&gt; settings are read whenever the server starts or is reloaded..htaccess files, on the other hand, are read before resources are served. As a result,.htaccess files can override directory configurations. To test whether this is occurring, temporarily disable .htaccess files.<\/li>\n<li>&lt;Location&gt; directives are read after &lt;Directory&gt; and &lt;Files&gt; sections, so settings here might override other earlier settings.<\/li>\n<li>Configuration files are read serially. For example, an option set in the beginning of the apache2.conf or httpd.conf file could be overridden by a setting in the conf.d\/ file or a virtual host file.<\/li>\n<li>When an entire directory is included, the files from that directory are included sequentially (alphabetically) based on name.<\/li>\n<li>Debian and Ubuntu systems have a file called\/etc\/apache2\/ports.conf, where the NameVirtualHost and Listen directives are set. These values determine the IP address or addresses to which Apache binds, and on which port(s) the web server listens for HTTP requests. This can sometimes conflict with settings in other files.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This post will \u00a0provides troubleshooting guidelines for the Apache web server. Apache is a highly customize able tool for serving HTTP traffic. Because it allows for so many different configurations and settings in so many different places, sometimes Apache configuration can befuddle even advanced users. In this guide, you\u2019ll start with some basic troubleshooting steps<\/p>\n","protected":false},"author":1,"featured_media":92,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,1,3],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basics","category-home","category-linux-tutorials"],"_links":{"self":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=89"}],"version-history":[{"count":0,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/media\/92"}],"wp:attachment":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}