I have recently built a website using MapServer for an academic course. The course is finished, but I wanted to continue developing it. The website is using Apache/2.4.53 (Debian), running on Debian 11, set up as a Virtual Host.
I have recently installed https using Let's Encrypt.
The website works when using either http (http://kina3.net/) or https (https://kina3.net/), so I know that https is working.
I can serve up a example file through MapServer when using: http://kina3.net/cgi-bin/mapserv?map=bluemarble&mode=map
However when I try using https://kina3.net/cgi-bin/mapserv?map=bluemarble&mode=map it generates the following error:
msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation failed.
My research (MS_DEFAULT_MAPFILE_PATTERN validation failed) suggests that problem is because "The map location is missing or wrongly formatted".
However in the apache2 VirtualHosts config file both references point to the same mapfile. See extract from site configuration file below:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName kina3.net
ServerAlias www.kina3.net
# Redirect permanent / https://kina3.net
DocumentRoot /var/www/kina3.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv bluemarble "/var/www/map/bluemarble.map"
</VirtualHost>
### ERROR LOGS IN /var/log/apache2/access.log ###
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName kina3.net
ServerAlias www.kina3.net
DocumentRoot /var/www/kina3.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /****
SSLCertificateKeyFile /****
Include /****
SetEnv bluemarble "/var/www/map/bluemarble.map"
</VirtualHost>
What am i missing?
I managed to fix this problem ... and it's not glorious. Turns out that I had two VirtualHosts files running, with the other one taking precedence. So whatever changes I made in the VH example above would have no effect as the other took precedence.
So if you find yourself with a similar problem to me, try running:
sudo apachectl -S
and see what the VirtualHost configuration: is pointing to.
Also, once you post a link to your own website on StackOverflow, expect regular visits from web scrapers plus various shady IP addresses.
Related
On my Windows 7 PC, I'm using XAMPP => Apache to run a testing webserver. But for a certain website I don't want the regular "C:\xampp\htdocs", but a custom path - which when I work on Ubuntu I usually setup in VirtualHost just as a DocumentRoot and it works.
On this PC the target path is similar to: "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
However on this PC when I do
<VirtualHost test2020.test:443>
DocumentRoot "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
ServerName test2020.test
ServerAlias www.test2020.test
</VirtualHost>
The DocumentRoot directive is completely ignored - it still seems to target files in the default C:\xampp\htdocs
I've also tried moving the files around the system and changing forward/backward slashes with no success:
DocumentRoot "C:/Users/X/Disk External/DIRWITHDIÁCRÍCÍCS/WEBS/some path/path"
DocumentRoot C:\xampp\htdocs\testdocumentroot
DocumentRoot "C:\Users\X\www"
Also I've tried swapping order of DocumentRoot and ServerName with no success.
I've checked C:\xampp\apache\conf\httpd.conf - the line Include conf/extra/httpd-vhosts.conf IS uncommented.
And the file C:\xampp\apache\conf\extra\httpd-vhosts.conf seems to affect apache start-up when set-up wrongly.
EDIT: also I did restart apache between each try :)
What am I missing?
So it's just my idiotism, I've tried to overdomain everything, but the directive attribute inside the VirtualHost tag is for network incoming limitation. For regular cases * is just fine there, also then I had a problem with Directory tag directive because aparently there's a new directive for Apache 2.4+
<VirtualHost test2020.test:443> => <VirtualHost *:443>
Working final code:
# (or *:80 for http:// , 443 is for https://)
<VirtualHost *:443>
DocumentRoot "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
ServerName test2020.test
ServerAlias www.test2020.test
<Directory "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path">
# NEW&SIMPLE FROM APACHE 2.4+ !
Require all granted
</Directory>
</VirtualHost>
The out-of-the-box welcome.php works well giving me the home page, yet internal links such as login or register return a 404.
I do not get any apache error in the log.
I've read many questions here that relate to my issue with no avail.
From googling this issue, I'm assuming it has to do with the conf file, but maybe im wrong, so feel free to ask for more info.
conf:
<VirtualHost *:80>
ServerAdmin webmaster#test
DocumentRoot /var/www/testing/public_html/public
serverName www.example.com
serverAlias example.com
<Directory /var/www/testing/public_html/public>
AllowOverride All
allow from all
options +Indexes
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
If I'm not getting any errors, how can I debug this? I would be happy to learn in the process.
The answer was that I had to execute sudo a2enmod rewrite.
We are developing multiple subdomain based namespaces in our app so we want to have a local domain to be able to use a subdomain in our development.
I am doing the following configuration in the apache available sites but not able to serve the app in the browser.
<VirtualHost *:80>
ServerAlias skreem.test
DocumentRoot /home/admini/Desktop/skreemProduct/public/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
have added the entry to the host file as well.
I am trying to add Virtual Hosts with SSL certificates to Apache on a Windows 10 environment.
It is my first time using Apache (total newb!), and have done my basic setup using online tutorials and blogs. My Apache service is running, and I am able to get the correct response when typing localhost in the browser. However, when I add my new Virtual Host, and try to restart the Apache service, it fails (Error 1067: The process terminated unexpectedly).
The problem seems to be with my SSL certificates in the setup. When I delete the certificate lines in the code below, the Apache service restarts with no problem. However the new Virtual Host does not open/resolve. I think this is due to the required certificates(?).
Here is my code:
In my httpd-vhosts.conf
<VirtualHost *:443>
ServerAdmin name#domain.co.za
ServerName odyssey.rain.network
ServerAlias odyssey.rain.network
DocumentRoot c:/Apache24/htdocs/odyssey.rain.network
SSLEngine on
SSLCertificateFile c:/Apache24/ssl/network/server.crt
SSLCertificateKeyFile c:/Apache24/ssl/network/rain.key
SSLCertificateChainFile c:/Apache24/ssl/network/ca.crt
ErrorLog logs/odyssey.rain.network-error.log
CustomLog logs/odyssey.rain.network-access.log combined
<Directory c:/Apache24/htdocs/odyssey.rain.network>
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin name#domain.co.za
ServerName odyssey.rain.network
Redirect / https://odyssey.rain.network
</VirtualHost>
I have also updated my hosts file with: 127.0.0.1 odyssey.rain.network
Thank you in advance!
I'm trying to get my wordpress site as well as my reviewboard site working under the same domain name.
Ex:
www.mysite.com (this is where i host my wordpress site)
www.mysite.com/reviewboard (this is where I want to host my reviewboard site)
I can get one or the other to work depending on my httpd-vhosts.conf file. However, I cannot get both to work(this is where I need your help!).
This is how I host my wordpress site:
<VirtualHost *:80>
ServerAdmin myemail#gmail.com
DocumentRoot "/opt/local/apache2/htdocs/mysite"
ServerName www.mysite.com
ErrorLog "/opt/local/apache2/logs/mysite.com-error_log"
CustomLog "/opt/local/apache2/logs/mysite.com-access_log" common
</VirtualHost>
This is how I host my reviewboard site(which then breaks my wordpress site):
<VirtualHost *:80>
ServerName www.mysite.com
DocumentRoot "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs"
# Error handlers
ErrorDocument 500 /errordocs/500.html
WSGIPassAuthorization On
WSGIScriptAlias "/reviewboard" "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/reviewboard.wsgi/reviewboard"
<Directory "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs">
AllowOverride All
Options -Indexes +FollowSymLinks
Allow from all
</Directory>
# Alias static media requests to filesystem
Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
So, now I want to be able to figure out how to combine these somehow so I can have reviewboard hosted at the path specified above without breaking my wordpress site. I tried using the Alias command as mentioned here: http://stackoverflow.com/questions/1553165/multiple-django-sites-with-apache-mod-wsgi
and here
https://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines
However I can't get it to work. Here's my WIP. If you can be very specific as what I need to do in order to change this so it works that would be great since I'm new to this kind of stuff. Thanks!
<VirtualHost *:80>
ServerName www.mysite.com
DocumentRoot "/opt/local/apache2/htdocs/mysite"
# Error handlers
#hmm not sure where to put this since my document root is different??????
#ErrorDocument 500 /errordocs/500.html
WSGIPassAuthorization On
Alias /reviewboard/ /opt/local/apache2/htdocs/mysite/reviewboard/htdocs/
<Directory "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs">
Options ExecCGI
SetHandler wsgi-script
AllowOverride All
Options -Indexes +FollowSymLinks
Allow from all
</Directory>
# Alias static media requests to filesystem
# Since I added the alias command above these are complaining about
#overlapping an earlier alias when I restart my apache server????
Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
If you're using the same domain for both, you can't use different VirtualHost sections for both. So first off, you have to merge both configurations into a single VirtualHost section. I'd start with the WordPress config, then add a few bits for ReviewBoard:
<VirtualHost *:80>
ServerAdmin myemail#gmail.com
DocumentRoot "/opt/local/apache2/htdocs/mysite"
ServerName www.mysite.com
ErrorLog "/opt/local/apache2/logs/mysite.com-error_log"
CustomLog "/opt/local/apache2/logs/mysite.com-access_log" common
WSGIPassAuthorization On
WSGIScriptAlias /reviewboard /opt/local/apache2/htdocs/mysite/reviewboard/rb.wsgi
<Directory /opt/local/apache2/htdocs/mysite/reviewboard>
Order deny,allow
Allow from all
</Directory>
Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
You need to create a WSGI script (but you should already have that). You might want to put it in a different path than what I put in the config here, so your permissions are more secure.
Using a combination of what djc wrote and some of my tinkering here's the working version so that:
www.mysite.com (wordpress site loads correctly)(mod_php)
www.mysite.com/reviewboard (reviewboard site loads correctly)(mod_wsgi)
Important make sure you clear your browser cache every time you restart your apache server as I kept falling into the trap of it showing incorrect data since I forgot to do that.
Important2 Make sure the "/reviewboard" follows the "reviewboard.wsgi" to become "reviewboard.wsgi/reviewboard" otherwise it will not work and gives a 404 error!
Here's the working version:
<VirtualHost *:80>
ServerAdmin myemail#gmail.com
ServerName www.mysite.com
DocumentRoot "/opt/local/apache2/htdocs/mysite"
ErrorLog "/opt/local/apache2/logs/mysite-error_log"
CustomLog "/opt/local/apache2/logs/mysite-access_log" common
WSGIPassAuthorization On
WSGIScriptAlias /reviewboard /opt/local/apache2/htdocs/mysite/reviewboard/htdocs/reviewboard.wsgi/reviewboard
<Directory /opt/local/apache2/htdocs/mysite/reviewboard>
Allow from all
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
# Alias static media requests to filesystem
Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>