Making Apache virtualhosts log to more than one file [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 8 years ago.
Improve this question
At the moment my virtualhosts look somewhat like this:
<VirtualHost 11.111.1.111:80>
ServerName mydomain.com
DocumentRoot /var/html/mydomain.com/public
CustomLog /var/log/http/mydomain.com-access-log combined
</VirtualHost>
This logs all requests for this particular website to its own log file, which I am happy with.
What I would like to do is have all virtualhosts (including this one) also log all of their requests to a shared logfile, in addition to their own logfile. I'd also like to limit the shared logfile to particular filetypes too (for example just HTML pages or just images).
I'm not sure if this is even possible?

Try the following vhost:
<VirtualHost 11.111.1.111:80>
ServerName mydomain.com
DocumentRoot /var/html/mydomain.com/public
#vhost logfile
CustomLog /var/log/http/mydomain.com-access-log combined
#shared logfile of images
setenvIf Request_URI ".(jpg|jpeg|png|gif|ico)$" logimg
CustomLog /var/log/http/images-access.log combined env=logimg
</VirtualHost>
Br,
E-raser

Related

Configure apache vhost for 3-rd level subdomain [closed]

Closed. This question is not about programming or software development. 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 12 hours ago.
Improve this question
I have VDS server without a normal domain. It has only DNS zone vm-4bbd6831.na4u.ru provided by my hosting service NetAngels.
Server has Ubuntu 22.04 with LAMP stack installed.
I should move to this server multiple websites, each website on its subdomain.
For instance:
site1 has address site1.vm-4bbd6831.na4u.ru
site2 has address site2.vm-4bbd6831.na4u.ru
and so on...
I tried configuring vsost like this:
<VirtualHost *:80>
ServerName site1
ServerAlias site1.*
DocumentRoot /var/www/site1
<Directory /var/www/site1/>
Options +ExecCGI -Includes -Indexes
AllowOverride All
</Directory>
I think i tried to change ServerName and ServerAlias with all possible values, but every time I reload apache and try to access http://site1.vm-4bbd6831.na4u.ru/ in web browser, I get only 'Server not found' message.
Give me please a clue, how can i configure vhosts...
I'll be very pleased, if you explain me how to properly use ServerName and ServerAlias
Thanks!!!

Apache Virtual Host doesn't work [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 6 years ago.
Improve this question
I'm trying to get Apache Virtual Host to work but it wont catch the domains and goes out on the internet instead.
I've enabled the Virtual Host in the Config file:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
My httpd-vhosts.conf file looks like this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "//nas/Web Design/Sites"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#fdn.dk
DocumentRoot "//nas/Web Design/Sites/Fdn"
ServerName fdn.dk
ServerAlias www.fdn.dk
ErrorLog "logs/fdn/error.log"
CustomLog "logs/fdn/access.log" common
</VirtualHost>
http://Localhost works fine but when i type fdn.dk or www.fdn.dk the browser tries to find the site on the internet instead of looking at my local folder.
What is wrong...??
I tried to find a solution on the internet but without luck.
Do I need to change something in the host file ???
Kind Regards
Flemming
Yes, you need to add that domain name to /etc/hosts file if you are using an operating system that has it.
Or to C:\WINDOWS\system32\drivers\etc\hosts if you are using Windows.
Example of record:
127.0.0.1 www.fdn.dk

Unexplained redirect using VirtualHosts and ServerAlias [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 9 years ago.
Improve this question
Using a virtual host, and a server alias, I'm getting a strange redirect that I do not understand where it is coming from.
Using stock apache2 on Ubuntu 12.04. Only the following changes to files in /etc/apache2/...
I have added a new virtual host as follows in the file sites-available/foo-com and enabled it with a2ensite
<VirtualHost *:80>
ServerName www.foo.om
ServerAlias foo.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/www.foo.com
<Directory /var/www/www.foo.com/>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I also have a second virtual host for www.bar.com, which is exactly the same as above, but with foo replaced by bar
I have changed the default virtual host to a different document root
DocumentRoot /var/www/default
<Directory /var/www/default/>
.....
When I navigate to http://foo.com, I get a 301 redirect to http://www.foo.com/www.foo.com , which obviously returns a 404. Even more strangely, navigating to http://bar.com returns the relevant site correctly without a redirect.
I've been tearing my hair out trying to understand this strange behaviour. I've verified that there are no redirect's anywhere else in the apache confs. There is no reference to foo.com anywhere except the virtual host above. There is no .htaccess files in the document root.. I created the directory from scratch.
What else could be causing this?
From http://httpd.apache.org/docs/2.2/en/howto/htaccess.html
Further note that httpd must look for .htaccess files in all
higher-level directories, in order to have a full complement of
directives that it must apply. (See section on how directives are
applied.) Thus, if a file is requested out of a directory
/www/htdocs/example, httpd must look for the following files:
/.htaccess
/www/.htaccess
/www/htdocs/.htaccess
/www/htdocs/example/.htaccess
Looking at your rewrite log, it would seem you have a .htaccess file stuck in /var/www . Removing it or, preferably, disabling .htaccess should solve your problem.

Can't link URL with virtual host [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 am really new to servers and apache however I've been struggling for a while now and maybe somebody can help me.
So I have set up an apache server that works (if I use the IP address I can reach the website and it works properly). I have linked the url with the nameservers and my virtual host file looks like (located in /etc/apache2/sites-available/mysite)
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#mysite1.com
ServerName mysite1.com
ServerAlias www.mysite1.com
DocumentRoot /srv/www/mysite1.com/public_html/
ErrorLog /srv/www/mysite1.com/logs/error.log
CustomLog /srv/www/mysite1.com/logs/access.log combined
</VirtualHost>
The weirdest thing is it worked yesterday and in the meantime I only installed an FTP server ... Any ideas of what I might have done wrong?
Thank you
If this is on Debian, you also need to link your config file in /etc/apache2/sites-available to /etc/apache2/sites-enabled, to let the config scripts know that the file is not only available, but also enabled.
Another thing might want to check is NameVirtualHost 12.34.56.78:80 directive somewhere in Apache config (or, optionally NameVirtualHost *:80).

Multiple virtual hosts on localhost for development [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 11 years ago.
Improve this question
I'm using Xampp (Apace 2.2.20) on mac os lion for development. I have a number of CMS projects and i want to access them by going to cms1.localhost, cms2.localhost, cms3.localhost etc
Currently, with the setup I have below, everything goes to whatever is in the first virtual hosts directive ie (/Applications/XAMPP/migration/trunk).
Can anyone please point me in the right direction. I can't think what else to do in terms of debug etc so that help would be useful too. Thanks a lot.
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/migration/trunk"
</Virtualhost>
<VirtualHost *:80>
ServerName rix.localhost
DocumentRoot "/Applications/XAMPP/projects/giving"
</Virtualhost>
In /etc/hosts I have
127.0.0.1 localhost
127.0.0.1 rix.localhost
For troubleshooting purposes, try swapping the VirtualHost declarations, confirm that the file is the correct one, and restart Apache.
They're all simple things, but best to check there first.