I had an issue regarding this which I've manage to fix to this stage, but the only issue is finding out how this could be achieved by perl.
This is a current structure of a link:
http://username.mydomain.com/public/name
And this is the current VirtualHost I've got:
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias *.mydomain.com
<Location /public>
DAV svn
SVNParentPath /home/svn/public/{SubdomainHere}
</Location>
ErrorLog /home/svn/log/error.log
CustomLog /home/svn/log/warning.log combined
</VirtualHost>
The above shows the current VirtualHost structure, and where the subdomain pattern is required. I've looked into the mod_perl and enabled it, and also understand now I can just add the tags. However, my perl skills are limited if not none existant.
I've seen the answer here and I believe it's somewhat similar to mine but requiring more mods: https://serverfault.com/questions/85256/using-url-within-vhost-container-with-mod-perl-dynamically
Could someone show me how this could be achieved and/or point me in the right direction?
Many thanks,
Shaun
I overcame this by creating a C++ init script which auto added the config files then reloaded apache2
Related
I have set up a really basic site using the default apache2 config settings, and I can't get an alias directory set up properly.
I've tried following a number of guides and stackexchange posts on setting this up, but there must be something I'm still missing. I've gone through a number of versions of this and tried to simplify as much as possible.
Here's my apache2 default site config
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
Alias /js/ "/usr/share/apache2/js/"
<Directory "/usr/share/apache2/js/">
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The alias from the default configuration in mods-available/alias.conf, Alias /icons/ "/usr/share/apache2/icons" works fine. I can access siteurl.com/icons/a.gif, but siteurl.com/js/a.gif is giving me a 404 error, despite there being a copy of a.gif in that folder.
I've done service apache2 restart. I've tried a2enmod/a2ensite to re-add the config files, but it says they are already loaded. This seems really simple, so I'm not sure what I'm missing here. Thanks.
After restarting the server and clearing the browser cache it is working properly.
I am trying to setup up basic authentication to a folder on my localhost running apache. Currently the app runs fine without authentication. I have setup a virtual host so I can access my application through dev.myapp.com
The code I add to my .htaccess file to force authentication is:
<Directory "/Users/myusername/Sites/dev.myapp.com">
AuthType Basic
AuthName Test
AuthBasicProvider file
AuthUserFile /etc/apache_users
Require valid-user
</Directory>
I have created a user.
When I type dev.myapp.com into the browser I get an internal server error. I am fairly new to apache. A point in the right direction would be appreciated.
Thanks.
First off, using .htaccess is a bit slower and requires that you have set the AllowOverride directive accordingly. It is recommended that you instead use httpd.conf to establish basic authentication. The Apache documentation explains all of this so check out this link http://httpd.apache.org/docs/2.2/howto/auth.html.
Regardless, I think I see the error. Your <Directory> tag looks a little odd. I understand the name of your site is dev.my.app.com but is that the actual name of the folder where the site dev.myapp.com points to on your server? Your httpd.conf file should have an entry like this:
<VirtualHost *>
DocumentRoot "document/root/path"
Other directives here
</VirtualHost>
The DocumentRoot is where Apache directs all incoming web traffic. If you are trying to establish authentication for your entire site, the value of DocumentRoot is most likely what you would want in your Directory tag ... making it <Directory /document/root/path>.
To locate httpd.conf look in in /etc/apache2/. Make sure to restart your server after you change the file (sudo /etc/init.d/apache2 restart). Hope that helps, please update if you haven't already resolved the problem.
I've been running Vagrant successfully for about a week. Last night I ran vagrant reload and now I can no longer access my sites.
VirtualBox version 4.2.16
Vagrant version 1.2.7
My Vagrantfile and bootstrap.sh: https://github.com/kriskd/vagrant-settings
Running on Mac
My files live at /vagrant/Sites. At first my "welcome page" which lives at /vagrant/Sites rendered at
http://localhost:4567/
All my projects are folders under Sites. For example, /vagrant/Sites/test won't render index.html. I get the following
Forbidden
You don't have permission to access / on this server.
Apache/2.4.6 (Ubuntu) Server at localhost Port 4567
The vhost looks like:
<VirtualHost *:80>
DocumentRoot "/vagrant/Sites/test"
ServerName test
<Directory "/vagrant/Sites/test">
AllowOverride All
</Directory>
</VirtualHost>
The vhosts are owned by root. My project files are owned by vagrant and chmod'ed 0777.
After no success, I did a full vagrant destroy followed by vagrant up and then the localhost host welcome page stopped rendering as well with the forbidden error.
My hunch is that this is not a vagrant issue at all but solely an Apache configuration glitch. There are a few things I can think to check.
First, obviously, is to confirm that the user that apache is running under has read and execute permissions for the DocumentRoot folder.
Since you mentioned Apache 2.4, there have been changes in the configs from 2.2. Make sure your Allow from all statements now read Require all granted. (If you were still on 2.2, you'd want to make sure they said Allow from all instead of Deny from all.) In either case, you can set this in each <VirtualHost> individually, or set a default in your <Directory /> block of the main httpd.conf file.
Getting more obscure, you could check for selinux, although I'm pretty sure this isn't present in Ubuntu by default. (It is in CentOS, for example.)
This is solved and in the end came down to some very simple things.
Use "Require All granted" instead of "Allow from All"
Put each websites' content at the same level namely /vagrant/Sites/default, /vagrant/Sites/test, /vagrant/Sites/real-site
Add .conf extension to vhost names such as test.conf and real-site.conf
Add AllowOverride All to vhosts to respect sites' .htaccess file (I realize that was in my original post, it got lost as I tried to solve this)
All very basic things that eluded me for a better part of a week. I hope this can help someone else.
I had the same problem when changing the DocumentRoot.
Since you've changed your DocumentRoot to "/any/path/foo/bar", make sure you have the permissions set on "apache2.conf" for this path.
Search for:
<Directory /any/path/foo/bar>
in apache2.conf
And add a new block like this:
<Directory /any/path/foo/bar>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
And my guess is that everything is gonna be fine!
cd /etc/apache2/sites-available
for file in `ls *`; do sed 's/\(.*<\/Directory.*>\)/Require\ all\ granted\n\1/' $file > $file.new;mv $file.new $file ; done;
because it worked before, I would not waste time on fix file by file
I'm installing Reviewboard on linux, I have copied the config provided by the install package to httpd.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/usr/www/reviewboard/htdocs"
# Error handlers
ErrorDocument 500 /errordocs/500.html
WSGIPassAuthorization On
WSGIScriptAlias "/reviewboard" "/usr/www/reviewboard/htdocs/reviewboard.wsgi/reviewboard"
<Directory "/usr/www/reviewboard/htdocs">
AllowOverride All
Options -Indexes FollowSymLinks
Allow from all
</Directory>
# Alias static media requests to filesystem
Alias /reviewboard/media "/usr/www/reviewboard/htdocs/media"
Alias /reviewboard/errordocs "/usr/www/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/usr/www/reviewboard/htdocs/media/rbcommons/images/favicon.png"
</VirtualHost>
However, when I access "http://SITE/reviewboard/htdocs/reviewboard.wsgi", it just gives me the file in plain text instead of running the script
I have checked the mod_wsgi is running on apache2 by "apache2ctl -t -D DUMP_MODULES"
Did I miss any other configuration?
You should be using the URL:
http://SITE/reviewboard
and the WSGIScriptAlias directive should be:
WSGIScriptAlias "/reviewboard" "/usr/www/reviewboard/htdocs/reviewboard.wsgi"
Do be aware though that it is bad practice to be putting your whole Django site under DocumentRoot. That you are seeing the source code for the WSGI script file highlights why it is bad. That is, have an issue with your Apache configuration and you could expose all your source code for people to download. Especially bad if settings.py is in there and it contains database passwords.
Now, address those issues and update question with what you then have and what next problem is as I don't expect that to completely solve the problem because with those mistakes you should have got a different problem than what you describe, so suspect that your configuration is not even being used.
I've got an apache web server (without mod_perl) that's been running just fine for a long time.
It has been suggested that we use mod_perl to improve the performance of some scripts.
I want to go ahead and install mod_perl on the server, which seems to be a relatively straightforward process, but I'm confused by some of the stuff coming up on Google searches.
If I install mod_perl (through the debian repositories), will all of my existing CGIs suddenly start "using mod_perl" and exhibiting potentially wonky behavior?
Or is there some configuration in apache that needs to be done for an old CGI to "start using mod_perl"?
Apologies if this is a straightforward answer but I am confused by the terminology being used in multiple ways in the documentation.
mod_perl has to be configured in your httpd.conf to be enabled. So not every script on your server will start to use mod_perl automatically.
Usually, you enable mod_perl per VHost. A usual configuration of mod_perl for a vhost looks like this:
<VirtualHost some.funny-domain.com>
ServerName some.funny-domain.com
ServerAdmin admin#funny-domain.com
DocumentRoot /data/path/to/root/
Perlrequire /data/path/to/startup.pl
PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlModule Apache2::RequestRec
ScriptAlias /cgi-bin/ "/data/path/to/root/cgi-bin/"
<Location /cgi-bin/>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
PerlOptions +SetupEnv
Options +ExecCGI
</Location>
CustomLog logs/access.log combined
ErrorLog logs/error.log
</VirtualHost>
Be carefull with the automated install-process! It may enable mod_perl on the wrong host for some reason! BackUp your config and apache-installation first to be able to "roll back" easily.
Comment: The line "Perlrequire /data/path/to/startup.pl" is not required. It is optional and sets some environment variables for the running scripts under the mod_perl env.