Reduce server response time - apache2 on debian 7 [closed] - apache

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I have pretty well-optimized website, PageSpeed Insights tool shows good results, but Google keeps saying reduce server response time which is 0.46 seconds. And it must not be greater than 200ms.
I have tried to delete all my htaccess content, then replace index.php with an empty index.html file, but server response remained the same. I am using a virtual private server with Debian 7and storing 2 websites with SSL on different IP addresses. The second site responds perfectly in 144 ms.
So, I can't find the reason why one site loads under 200ms and other in 460ms. I'm pretty sure that server has enough resources.
I would be grateful for the ideas.

You could try some tweaks on your apache server. Can't guarantee that you'll get the desired result but it's an easy job and I think you have nothing to lose if you try it! So edit your apache2.conf file and adjust your actual settings to match the ones bellow (these are good settings in terms of web server security as well).
TraceEnable Off
ServerSignature Off
ServerTokens Prod
FileETag None
HostnameLookups Off # this is important since your apache server won't try to translate your ip address into a dns name or host when you access your website
ExtendedStatus On # you can enable it afterwards, if you need it
Timeout 10
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
You could also disable apache modules (modules that you do not need or use). By default apache loads a big list of modules and I am pretty sure that you won't be needing them all. I can't provide you a list with what to keep enabled or what to disable but you can do a little Google research and based on your website you could decide what to disable and what to keep.
I am actually using all these settings on my CentOS 6.8 linux box and all the settings are in httpd.conf. On Debian you should edit /etc/apache2/apache2.conf and maybe some other files!

Related

How can I prevent apache to log Health Checks in Docker? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a dockerized web application deployed, and everything works just fine, logging every request, including a HUGE number of health checks, which are configured to hit the page /health, a blank page.
I think it's a common problem, and I found this question for a different stack (Elastic Beanstalk).
I'd like to have a solution that is completely automatic and possibly in the Dockerfile
First of all, I need an additional configuration file for Apache, let's call it apacheLogFilter.conf.
The content will be pretty easy, but it could be customized as much as we want, defining custom rules. The trick is defining a custom environment variable that, if present, will stop the logging for that request
SetEnvIf Request_URI "^/health$" dontlog
Once defined this new configuration, we need to plug it into apache directly in the Dockerfile, adding the following rows:
FROM php:7.2-apache
...
# Copy the log-filtering configuration in the right place
COPY apacheLogFilter.conf /etc/apache2/conf-enabled
# Change the standard logging entry of all the available sites to use the variable
RUN sed -ri -e 's!combined!combined env=\!dontlog!g' /etc/apache2/sites-available/*.conf
...
In this way, the configuration file will be loaded by apache at startup, each request will check the rules defined, and in case one of them will trigger, the request will not be logged

Special configuration of the vhost [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I've got some headache trying to configure that for some days so I hope someone can help me.
I've got few sites, each one related to an FTP account. I would like to make them accessible through my man website by the url http://www.mainsite.com/site1. At this point an Alias should do the work.
However I would like to add some features such as specify the log file related to the site1 which would be in the web directory of the FTP account site1. Later, I would like to put them in /var/log and have a script to sync the log file located in the web directory with the one in /var/log so that even if a user delete the log file in the web directory, the original one is still here.
To go back to the main problem, I don't know how to do that, I tried to configure a whole vhost for the site1 but then, as the ServerName would be the same as the main site, the main site would no longer be accessible.
Any suggestions ?
You could try the ancient ServerPath directive, which will cause /site1 to be mapped to one vhost and /site2 to be mapped to another, despite having matching servername and local interface:port.

Access new web site via browser with IP address? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Ive set up a new site with WHM but havent got the DNS set up yet. I want to be able to access the site via a browser so I can set up a CMS. Usually, I can just do this by entering the IP address into the browser, but this time I just get a page saying that Apache is working on the server.
Does anyone know a way round this?
Thanks!
The problem is that the request your browser is sending doesn't include the correct Host: in the HTTP header, so the web server replies with the a default catch-all page.
You can either
setup a private (local) authoritative DNS server with a yoursite.com zone, and set your system's DNS to point to this DNS server, or
temporarily trick the DNS resolution in your local system by registering whatever.yoursite.com with it's corresponding IP address in /etc/hosts file (in unix-like systems). There's an equivalent file in MS Windows systems, look for a file named hosts in C:\Windows\system32\drivers\etc.
I'd try with the latter first, as it's just a matter of adding a single line to a text file:
203.0.113.22 whatever.yoursite.com
You may need to restart your browser.

How can one reference subdomains on a dev server that also correctly resolve on a production server? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've got a LAMP dev server at something like dev.example.com. Eventually this will be replicated to something like www.example.com where we will have root access.
I'd like to have the sys admin set up a few subdomains (e.g., subdomain1.example.com) such that they will work on both the dev server and the production server without the references to those subdomains having to be rewritten.
Can Apache be configured on the dev and production servers such that my code can reference something like subdomain1.localhost? Is there some other way of doing this?
(The servers will run recent versions of CentOS and the AMP stack.)
I finally found the answer in the CDN module. As the name implies, this is intended to be used with content delivery networks but essentially all it does is a rule-based re-writing of the URLs that Drupal outputs. I've used it to re-write URLs so that different file types can be served from unique hostnames (again, to maximize parallel downloads).
reading your question again, I think that you want your code to always return subdomain1.localhost, and you want apache to somehow change this to subdomain1.example.com on your production server.
You could do this with ProxyPassReverse, although you might have to run two copies of Apache if the subdomain1 is on the same machine. (I don't know if Apache will cope with talking to itself here). This is an expensive solution.
Instead, I recommend your parameterize your code.
On rails stacks, the easiest way to do this with the production.rb cp that capistrano recommends, and you might want to investigate similar ways of deploying your PHP code.

Best way to rotate Apache log files [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it.
What software or modules for Apache are available that will make a daily copy of my access file to make it more manageable?
Have you looked at logrotate - this is probably the simplest, most widely available and well understood method of achieving this. It is highly configurable and will probably do 90% of what you need.
I'm a big fan of Cronolog. Just install and pipe your logs through it. For daily log rotation, something like this would work:
ErrorLog "|/usr/bin/cronolog /path/to/logs/%Y-%m-%d/error.log"
CustomLog "|/usr/bin/cronolog /path/to/logs/%Y-%m-%d/access.log" combined
Pretty handy, and once installed, easier (in my experience) than logrotate.
The actual command for Windows, which is quite difficult to find online is:
CustomLog '|" "*Apache-Path/bin/rotatelogs.exe"
"**Apache-Path*/logs/backup/internet_access_%d-%m-%y.log" 86400' combined
Where the "internet_access" bit is the name you choose for your files, the 86400 is the number of seconds in one day. You need to change the Apache-Path to the relevant directory you've installed Apache to.
logrotate
logrotate is probably the best solution. Use the file /etc/logrotate.conf to change the settings for all your logs. You van change weekly to daily so the logs are rotated every day. Also, you might want to add compress so the archives are compressed. If you don't care about the old logs, you can set rotate rotate 4 to something lower.
CustomLog "|bin/rotatelogs /var/logs/logfile 5M" common
This configuration will rotate the logfile whenever it reaches a size of 5 megabytes.
ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"
This Would Be Best Way to Redirect Apache logs. No need to compile mod with httpd.
rotatelog.exe or cronolog.exe on windows os. They are used in pipe command in http.conf
Mod_log_rotate additional module for apache ONLY for access log rotation
Logrotate ONLY for unix os.
I have a module that does this for you without the need for external pipes etc :
http://www.poptart.org/bin/view/Poptart/ModAutorotate
I've tried to add it to the Apache modules collection but that seems to have been broken for a while now.