WAMP virtual host error log location not working? - wamp

Haven't used WAMP in years, but decided to try it again today for a project I am going to work on. I have everything setup and working, but for some reason the error log locations I am defining in my virtual host file are not working - all log entries still go to the default files at c:\wamp64\logs\ rather than the custom ones I specified below.
My vhost file is :
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName site.local
ServerAlias site.local
DocumentRoot "C:/Users/Support/Documents/My Web Sites/BS4/site.com"
<Directory "C:/Users/Support/Documents/My Web Sites/BS4/site.com">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
ErrorLog "logs/site.local-error.log"
CustomLog "logs/site.local-access.log" common
</VirtualHost>
Am I missing something here? I want to have different logs for each 'project' I am working on (only one defined for now), but having them separate makes more sense.

Change your definition of the log files to include the full path.
You might also like to add a seperate log file for the PHP error log.
ErrorLog "C:/wamp/logs/localhost-error.log"
CustomLog "C:/wamp/logs/localhost-access.log" common
php_value error_log "C:/wamp/logs/localhost.php.error.log"
and
ErrorLog "C:/wamp/logs/site.local-error.log"
CustomLog "C:/wamp/logs/site.local-access.log" common
php_value error_log "C:/wamp/logs/site.php.error.log"

Related

Host both PHP/JS and Django applications with Apache on Windows

I have a WAMP Server 3.2 (Apache 2.4.46) installed on Windows 10 (64-bits), it is exposed to the local company network. I use it to host ordinary php/js applications. My httpd-vhosts.conf is used to look like this:
<VirtualHost *:80>
ServerName RealNameOfTheServer
DocumentRoot "d:/projects"
<Directory "d:/projects/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Now I got a Django app which preferably needs to be hosted with the same server (since I don't have any other) along with other php applications. I tried to follow the example to configure my virtual hosts, but it uses daemon process which is not available on Windows.
My httpd-vhosts.conf after applied changes makes Django app work correctly but dumps php/js apps.
<VirtualHost *:80>
ServerName RealNameOfTheServer
DocumentRoot "d:/projects"
<Directory "d:/projects/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
WSGIPassAuthorization On
ErrorLog "logs/dashboard.error.log"
CustomLog "logs/dashboard.access.log" combined
WSGIScriptAlias / "d:\projects\dashboard\dashboard\wsgi_windows.py"
WSGIApplicationGroup %{GLOBAL}
<Directory "d:\projects\dashboard\dashboard">
<Files wsgi_windows.py>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Files>
</Directory>
Alias /static "d:/projects/dashboard/static"
<Directory "d:/projects/dashboard/static">
Require all granted
</Directory>
</VirtualHost>
Is there any way to run both php and Django apps on Windows?
WSGIScriptAlias / "d:\projects\dashboard\dashboard\wsgi_windows.py"
will also catch calls to "d:/projects" - so if you want to avoid that, you need to change to something like
WSGIScriptAlias /my_wsgi_app/ "d:\projects\dashboard\dashboard\wsgi_windows.py"
If you want to avoid that the user can see that, you can use a rewrite rule for certain paths.

Host multiple web sites on port 80

So I may be missing a bit of a fundamental understanding on what's going on here, but I cannot get this to work. I have two django websites, and I want to be able to host them both on the same box, both on port 80. Is there some magic to get this to work properly? Here's what my sites-available/default file looks like:
<VirtualHost *:80>
WSGIScriptAlias / /path/to/proj/apache/django.wsgi
AliasMatch ^/([^/]*\.css) /path/to/proj/static/
Alias /media /path/to/proj/static/
Alias /static/ /path/to/proj/static/
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
WSGIScriptAlias / /path/to/otherproj/apache/django.wsgi
ErrorLog ${APACHE_LOG_DIR}/error2.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Obviously this doesn't work since navigating to the site hits the first one and it never goes to the second one. So my question is, how do I set this up so I can host 2 web sites on port 80. Perhaps I could do like localhost/site1 and localhost/site2 and figure it out that way, but no matter what I try I can't seem to get that to work.
I have played with the ServerName property, but I don't really understand how that can work, setting it doesn't seem to change that hitting the ip of that machine only shows the first website, and I don't know where using the ServerName affects anything.
Any suggestions, or let me know if I need to give more information.
Also note they both work if I change the second one to port 8080, but when doing that I can't seem to put a domain name on top of myip:8080.
I don't think there is anything to explain here. You just need to actually specify the name of each virtual domain.
Note:NameVirtualHost is deprecated
<VirtualHost *:80>
ServerName site1.ltd
WSGIScriptAlias / /path/to/proj/apache/django.wsgi
AliasMatch ^/([^/]*\.css) /path/to/proj/static/
Alias /media /path/to/proj/static/
Alias /static/ /path/to/proj/static/
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName site2.ltd
WSGIScriptAlias / /path/to/otherproj/apache/django.wsgi
ErrorLog ${APACHE_LOG_DIR}/error2.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

when configuring mod_wsgi for django 1.4 apache fails to start on mac osx after adding WSGIPythonPath to the virtual host config

I followed the django docs on how to deploy django 1.4 to apache using mod_wsgi https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ on mac osx lion and when I add the WSGIPythonPath directive apache cant restart .Yet without it my app is non existant in the path . In the log I am getting an error that reads
WSGIPythonPath cannot occur within VirtualHost section
here is what my virtual host config looks like
<VirtualHost *:80>
ServerAdmin jmured#gmail.com
DocumentRoot "/Users/jamo/code/work/projects/bfpd/fapp"
ServerName bfpd.dev
ServerAlias bfpd.dev
ErrorLog "/private/var/log/apache2/bfpd.dev-error_log"
CustomLog "/private/var/log/apache2/bfpd.dev-access_log" common
Alias /static/ /Users/jamo/code/work/projects/bfpd/fapp/fapp/static/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp/static>
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
IndexOptions FancyIndexing
</Directory>
WSGIScriptAlias / /Users/jamo/code/work/projects/bfpd/fapp/fapp/wsgi.py
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp>
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
what am i doing wrong ???
I fixed it.
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/
should be in http.conf
As mentioned in the comment by nemesisfixx, and specified by the error in your original question:
WSGIPythonPath cannot occur within VirtualHost section
Moving WSGIPythonPath outside of VirtualHost resolved Apache crashing on OS X server.
$ cat sites/0000_any_80_mysite.com.conf
WSGIPythonPath /Library/Server/Web/Data/Sites/mysite/django-app:/Users/owen/.virtualenvs/mysite:/Users/owen/.virtualenvs/mysite/lib/python2.7/site-packages
<VirtualHost *:80>
ServerName mysite.com
ServerAdmin admin#example.com
DocumentRoot "/Library/Server/Web/Data/Sites/mysite/site"
...
WSGIScriptAlias /api /Library/Server/Web/Data/Sites/mysite/django-app/mysite/wsgi.wsgi
...
<VirtualHost>
It took a lot of putzing for me to get the paths correct (including full path to site-env, which I initially thought would be included automatically after adding the virtualenv top level).

mod_wsgi problem or?

i have apache2.conf
<VirtualHost 91.218.230.130:8080>
ServerName dopisaka.ru
DocumentRoot /var/www/dopisalki.ru/data/www/dopisaka.ru
SuexecUserGroup dopisalki.ru dopisalki.ru
CustomLog /var/www/httpd-logs/dopisaka.ru.access.log combined
ErrorLog /var/www/httpd-logs/dopisaka.ru.error.log
ServerAlias www.dopisaka.ru
ServerAdmin 911#dopisalki.ru
AddDefaultCharset utf-8
<Directory "/var/www/dopisalki.ru/data/www/dopisaka.ru">
Order allow,deny
Allow from all
</Directory>
Alias /manager/ "/var/www/dopisalki.ru/data/www/dopisaka.ru/manager/"
ScriptAlias /cgi-bin/ /var/www/dopisalki.ru/data/www/dopisaka.ru/cgi-bin/
WSGIScriptAlias / /var/www/dopisalki.ru/data/www/dopisaka.ru/django.wsgi
</VirtualHost>
but http://www.dopisaka.ru/ show just a "Index of".
whats wrong?
You have included an IP address in the VirtualHost directive. Did you provide a compatible NameVirtualHost directive using that IP address along with the port? If you didn't then likely that the VirtualHost configuration isn't being used at all, and instead the default virtual host definition is being used and it is that which is set up to return the index. More often that not using an IP address in VirtualHost is not what you want to do and you should just use '*:8080', still remembering though that you need a matching NameVirtualHost directive.
Try to remove the DocumentRoot directive. Also your wsgi script seem to be under DocumentRoot, you don't want the script under DocumentRoot because that make it readable by everyone.

Apache config to hook SSL into Django

I have a django app that requires some user credentials. I want to send login/register data over HTTPS. I've self-generated a certificate to test out and have also requested an external certificate, though that's pending.
I want to make sure that I don't royally screw up my AWS instance. I've grabbed pieces from different tutorials. For instance, in one tutorial, the SSLCertificateKeyFile was a .pem file but another tutorial had it as a .key file. I could only find a .key file in my dirs, so I just used that. Also, I'm not sure if "IfDefine" conditional is necessary/applicable and I also don't know whether the last line of my SSL virtual host, which seems to be making a change based on sniffing IE, should be included.
My mod-WSGI config normally looks like this:
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /home/dir/
Alias /media/ /home/dir/public_html/media/
<Directory /home/dir/public_html/media>
Options -Indexes
Order deny,allow
Allow from all
</Directory>
Alias /admin_media/ /home/dir/project/admin/
<Directory /home/dir/project/admin >
Order deny,allow
Allow from all
</Directory>
WSGIScriptalias / /home/dir/project/apache/django.wsgi
WSGIScriptalias / /home/dir/project/apache/django.wsgi
<Directory /home/dir/project/apache >
Order deny,allow
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
</VirtualHost>
I've added the following virtual host for https connections:
<IfDefine SSL>
<VirtualHost *:443>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /home/dir/
SSLEngine on
SSLCertificateFile /usr/lib/ssl/www.mysite.com.crt
SSLCertificateKeyFile /usr/lib/ssl/www.mysite.com.key
#SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
</IfDefine>
Does this look about right? Is this sufficient to start requiring https for certain views via a custom decorator? I also want to require https for requests to admin. I've seen the following:
RewriteRule (.*) https://example.com/$1 [L,R=301]
...
I wasn't sure how to make that RewriteRule work without getting rid of Alias-ing. How should I handle that?
Thanks!