Here is my current vhost:
<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/public
<Directory /var/www/%0/public>
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php index.html
AllowOverride All
Order allow,deny
Allow from all
</Directory
</VirtualHost>
How can I get a access.log for each %0 vhost?
FYI.. If it matters, this is a debian install.
You can add the TransferLog in your VirtualHost definition. Don't forget to restart your Apache service when changing configuration.
<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/public
ErrorLog/var/logs/%0/error.log
TransferLog /var/logs/%0/access.log
<Directory /var/www/%0/public>
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php index.html
AllowOverride All
Order allow,deny
Allow from all
</Director>
</VirtualHost>
Related
I have two virtual hosts setup on my Ubuntu 20.04 Apache2 webserver.
example2.domain.com.conf
DocumentRoot /var/www/Dev
ServerName example2.domain.com
ServerAlias example2.domain.com
<Directory /var/www/Dev/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
example.domain.com.conf
<VirtualHost *:80>
DocumentRoot /var/www/example
ServerName example.domain.com
ServerAlias example.domain.com
<Directory /var/www/example/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://example.domain.com/
</VirtualHost>
and finally: example.domain.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot /var/www/example
ServerName example.domain.com
ServerAlias example.domain.com
<Directory /var/www/example/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /etc/letsencrypt/live/example.domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
/etc/hosts
127.0.0.1 localhost
127.0.0.1 example2
Ok, so when I go to example2.domain.com it shows the example2 url but displays the files from example.domain.com. example.domain.com works just fine.
What gives?
I use apache2 and I want to have something like username.mydomain.fr
www.mydomain.fr --> /var/www/web-en-royans that is works fine
username.mydomain.fr --> /home/username/www that does not work
also, www.mydomain.fr/~username --> /home/username/www that is works fine, but I don't care.
I activate user_dir and vhost_alias.
UseCanonicalName Off
<VirtualHost *:80>
ServerName www.web-en-royans.fr
DocumentRoot /var/www/web-en-royans
</VirtualHost>
<VirtualHost *:80>
ServerName *.web-en-royans.fr
VirtualDocumentRoot /home/%-3/www
#VirtualDocumentRoot /home/%1/www
</VirtualHost>
<Directory "/var/www/web-en-royans">
Options Indexes MultiViews FollowSymLinks
Order deny,allow
Allow from all
</Directory>
<Directory "/home/*/www">
Options Indexes MultiViews FollowSymLinks
Order deny,allow
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.web-en-royans.fr.log
CustomLog /var/log/apache2/access.web-en-royans.fr.log combined
I want to work with VirtualDocumentRoot more than rewrite_url
Moreover, username.mydomain.fr go to www.mydomain.fr, and whatever.mydomain.fr go to www.mydomain.fr.
I do not even known how to debug or trace it.
Very simple, just disable the mod-userdir, and add a ServerAlias
<VirtualHost *:80>
ServerName www.web-en-royans.fr
DocumentRoot /var/www/web-en-royans
</VirtualHost>
<VirtualHost *:80>
ServerName *.web-en-royans.fr
ServerAlias *.web-en-royans.fr
VirtualDocumentRoot /home/%1/www
</VirtualHost>
I use ubuntu 12.04 with apache2 and mod_wsgi installed. I want to use bottlepy and php in my local computer.
I know such an issue is already asked by someone else as in Apache mod_wsgi and php in the same domain.
But someone suggest me to make a new question since my problem could be different.
I've change /etc/apache2/sites-available/default into this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot /home/gofrendi/workspace/kokoropy
ServerName oraiso
WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
<Directory /home/gofrendi/workspace/kokoropy>
WSGIProcessGroup kokoropy
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
The first virtual host is for PHP, and the second one is for bottlepy.
I put my bottlepy application in /home/gofrendi/workspace/kokoropy. And I have kokoro.wsgi in the same directory which contains this script:
import os
sys.path = [os.path.dirname(__file__)] + sys.path
from kokoropy import kokoro_init
PWD = os.path.dirname(os.path.abspath(__file__))
APP_DIRECTORY = 'applications'
APPLICATION_PATH = os.path.join(PWD, APP_DIRECTORY)
application = kokoro_init(application_path = APPLICATION_PATH, run = False)
I've do enable the configuration by using
sudo a2ensite default
sudo service apache2 restart
My PHP scripts are still work as expected. But, whenever I don't know how to access my bottlepy script.
I've also try to remove the PHP part of /etc/apache2/sites-available/default, so that it only consists of
<VirtualHost *>
DocumentRoot /home/gofrendi/workspace/kokoropy
ServerName oraiso
WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
<Directory /home/gofrendi/workspace/kokoropy>
WSGIProcessGroup kokoropy
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
But I still can't get bottlepy work. It just simply show 404 not found.
Do anybody has the same experience? How to make it work?
Thanks.
The problem has been solved.
First I change httpd.conf setting (or in my case /etc/apache2/sites-available/default) nto this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
# THIS IS WHERE I START TO EDIT IT:
# It tells apache about wsgi existance
WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
<Directory /home/gofrendi/workspace/kokoropy>
WSGIProcessGroup kokoropy
WSGIApplicationGroup %{GLOBAL}
Options ExecCGI
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
This configuration say that localhost/kokoropy should be handled by the wsgi.
My wsgi script is located at /home/gofrendi/workspace/kokoropy/kokoro.wsgi.
kokoro.wsgi content is as follow:
import os, sys
os.chdir(os.path.dirname(__file__))
sys.path = [os.path.dirname(__file__)] + sys.path
from bottle import default_app
#route('/')
def index():
return 'run with apache'
application = default_app()
If you found internal sever error, when accessing bottlepy, but find no error when accessing php, that is probably some mistake in you wsgi. Just open up the apache log (in my case it is here: /var/log/apache2/error.log)
I made a simple page /home/david/mainSite/index.html. I then added a virtual host in Apache to redirect my IP address to this page.
<VirtualHost *:80>
ServerName 74.181.105.228
DocumentRoot /home/david/mainSite
</VirtualHost>
However, when I go to 74.181.105.228after restarting Apache, I get a page with this text instead of "index.html."
Welcome to mydomain.com!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
Why does Apache redirect to the default page instead of "/home/david/mainSite/index.html"?
Here is how my "/etc/apache2/sites-available/default" file looks like.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I discovered the answer! It was tricky.
In "apache2.conf", I originally had ServerName 74.181.105.228, which makes accessing 74.181.105.228 via a browser load the default page for my server.
Changing this value in "apache2.conf" to ServerName mydomain.com solves the problem since Apache no longer directs 74.181.105.228 to the default page of my server. In turn, I can direct 74.181.105.228 to load a page from a certain directory in my file system.
My virtual host block still remains
<VirtualHost *:80>
ServerName 74.181.105.228
DocumentRoot /home/david/mainSite
</VirtualHost
I just installed a SSL certificate on my website that uses CakePHP and now the site doesn't load anymore files from webroot (images, css files). Any ideas? I think SSL installation affected mod_rewrite, or something like this.
I just ran into this problem. Check your sites configuration for apache2. Make sure:
AllowOverride all
is set to allow .htaccess overrides under ssl. Here is my snippet of my config (on ubuntu).
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>