Acache: wsgi and alias incompatibility - apache

I am trying to setup Apache so that:
if the user goes to /temp then the file /home/temp/public_html/index.html is served
if the user goes to /temp/app then my mod-wsgi /home/temp/app/start.wsgi is executed
I currently have this:
<VirtualHost *:80>
WSGIDaemonProcess temp user=temp group=temp home=/home/temp/app
WSGIScriptAlias /temp/app /home/temp/app/start.wsgi
Alias /temp /home/temp/public_html
<Directory /home/temp/app>
WSGIProcessGroup temp
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost *:80>
But oddly enough Alias seems to take predence over WSGIScriptAlias and /temp/app does not work...

You got closer in your own answer, but not quite. Use something like:
<VirtualHost *:80>
WSGIDaemonProcess temp user=temp group=temp home=/home/temp/app
Alias /temp/app /home/temp/app/start.wsgi
Alias /temp /home/temp/public_html
<Directory /home/temp/app>
WSGIProcessGroup temp
WSGIApplicationGroup %{GLOBAL}
Require all granted
Options ExecCGI
AddHandler wsgi-script .wsgi
</Directory>
</VirtualHost>

Not particularly pretty, but I have (at least for the time being) solved it this way:
<VirtualHost *:80>
WSGIDaemonProcess temp user=temp group=temp home=/home/temp/app
<Directory /home/temp/app>
WSGIProcessGroup temp
WSGIApplicationGroup %{GLOBAL}
Options ExecCGI MultiViews
MultiviewsMatch Handlers
AddHandler cgi-script .cgi
AddHandler wsgi-script .wsgi
Require all granted
</Directory>
Alias /temp /home/temp/app
</VirtualHost>
Instead of using WSGIScriptAlias, I define it to automatically run .wsgi files. The MultiViews option matches file to file.wsgi.
Furthermore, to hide the extension from my own script, in each .wsgi I have to redefine the script filename:
from server_public import app as _application # my flask app
# get rid of the .wsgi extension
def application(environ, start_response):
if environ['SCRIPT_NAME'].endswith('.wsgi'):
environ['SCRIPT_NAME'] = environ['SCRIPT_NAME'][:-5]
return _application(environ, start_response)
I also had to move my public_html/index.html to app/index.html.
I would prefer a simpler solutions where I served index.html for /temp, and a script alias for /temp/app... But not sure that is possible...

Related

Apache The Requested URL has not been found on this server

So, I'm trying to get Codiad on my VPS so that me and a friend can work on a project together, and when I try to index localhost/codiad it gives me this error:
The requested URL /codiad was not found on this server.
however, indexing localhost works perfectly fine, it leads me to the normal apache screen. Here are the contents of my default.conf file, if that helps at all:
<VirtualHost *:80>
ServerName www.dsept.cf
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /codiad /home/Tide/Codiad
<Directory "/home/Tide/Codiad">
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
I'm also following this guide if that helps too: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-codiad-a-web-based-ide-on-an-ubuntu-vps, the directory of default.conf is /etc/apache2/sites-available/default.conf
1) are you sure there should be:
localhost/codiad
or :
localhost/Codiad
2) have you ever changed that .conf? If so, you may have to edit that .conf and add codiad alias/path correctly. Is everything accurate there?

Redmine duplicate URL access / & /redmine

I managed to get my Redmine reachable at a example.org/redmine URL.
But actually, it's still reachable at example.org/
I can't manage to make it work only on the /redmine alias.
Here is my configuration
<VirtualHost *:80>
LoadModule passenger_module /usr/local/share/gems/gems/passenger-5.0.11/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/share/gems/gems/passenger-5.0.11
PassengerDefaultRuby /usr/bin/ruby
PassengerUser apache
</IfModule>
DocumentRoot /var/www
PassengerAppRoot /var/www/redmine
RailsBaseURI /redmine
Alias /redmine /var/www/redmine/public
TransferLog "logs/redmine_acess_log"
ErrorLog "logs/redmine_error_log"
</VirtualHost>
When I enter example.org/zriogjqoerqgj I'd like to have the default ErrorDocument, not something hooked up by Redmine.
Add the Directory directive, for example:
<Directory /var/www/redmine>
Order allow,deny
Allow from all
Require all granted
</Directory>
And another one
<Directory /var/www>
Order deny,allow
Deny from all
</Directory>
Your Virtual Host shoud looks like this:
<VirtualHost *:80>
ServerName example.org
DocumentRoot /var/www
ErrorLog logs/redmine_error_log
<Directory "/var/www/">
Allow from all
Options -MultiViews
</Directory>
Alias /redmine /var/www/redmine/public/
<Location /redmine>
PassengerBaseURI /redmine
PassengerAppRoot /var/www/redmine
</Location>
<Directory /var/www/redmine/public/ >
Options Indexes ExecCGI FollowSymLinks -MultiViews
Order allow,deny
Allow from all
AllowOverride all
</Directory>
</VirtualHost>
I did this solution following the Passenger documentation

apache AllowOverride /var/www/html but not /var/www/html/temp/

I have a wordpress site, Because wordpress need .htaccess rule, so /var/www/html should be set AllowOverride all. But I have some custom folder /var/www/html/temp/, it has many sub-folder, the max depth could be 9. /var/www/html/temp/images/avatar/username/large/cache/image.jpeg. How to add another rule, so that <directory "/var/www/html/temp"> could be with rule AllowOverride None,thanks.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
<directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>
There's not really a trick here, if you create a 2nd directory section that is conceptually below the first, its changes will be merged in:
<Directory "/var/www/html/temp">
AllowOverride None
</Directory>
For clarity, just put it immediately after the existing Directory section, although for Directory that is not strictly necessary.
You should review the basics of the "configuration sections" topic in the manual.

Apache Config for PHP and Web2Py

I'm setting up a server for home to run all sorts of things. I'll save you the whole story, but I'm trying to get it to run Web2Py through WSGI, but also need to serve PHP files for other web apps I have. I tried the install script for Web2Py, but that "hijacked" the entire Apache system to run the Web2Py system.
The setup currently works for PHP and SSL pages, but I cannot get it to also process requests for the Web2Py site. For the Web2Py url (http://jupiter/web2py), I get an Apache directory listing. Please help.
The directory structure is this:
/var/www --> Apache DocumentRoot
/var/www/scripts --> various PHP scripts
/var/www/web2py --> Web2Py
The /etc/apache2/sites-available/default file is setup as this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin me#yahoo.com
ServerName jupiter.myhome.com
WSGIDaemonProcess web2py user=www-data group=www-data display-name=%{GROUP}
WSGIProcessGroup web2py
WSGIScriptAlias /web2py /var/www/web2py/wsgihandler.py
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>
<Directory /var/www/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(.*) /var/www/web2py/applications/$1/static/$2
<Directory /var/www/web2py/applications/*/static/>
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
#comment
#comment
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
I successfully configured a Joomla (PHP) application + Web2py. Your apache config seems ok. Just make sure you configure your /web2py/routes.py with the correct path_prefix (as per your example it should be 'web2py'):
routers = dict(
BASE = dict(
default_application='<your_default_app>',
path_prefix='web2py',
)
)

Moveable type images not displayed

I installed Moveable type on a ubuntu box.
The admin section works great.
However the front page does not. The images and CSS are not displayed.
This is coming from the apache error log:
Permission denied: exec of '/var/www/mt/example/styles.css' failed
Premature end of script headers: styles.css
I think it's related to my apache config. Since i call the admin section using the localhost, but i use the example.com for the front page, which is the part that doesnt work.
This is my apache config:
NameVirtualHost *
<VirtualHost *>
ServerAdmin chris#example.com
ServerName mt.example.net
DocumentRoot /var/www/mt
Alias /mt-static /var/www/mt/mt-static
<Directory /var/www/mt/mt-static>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias / /var/www/mt/
<Directory /var/www/mt>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerAdmin chris#example.com
ServerName example.com
ServerAlias example.com www. example.com
DocumentRoot /var/www/example
Alias /mt-static /var/www/mt/mt-static
<Directory /var/www/mt/mt-static>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Redirect /mt.cgi http://mt.example.net/mt.cgi
</VirtualHost>
it because the directory where the css file is located (var/www/mt/example/) is a sub-directory of one which is declared to be a script in (/var/www/mt) with Options +ExecCGI
Directories inherit the options of their parents
It sounds like Apache has tried to run the .css file as an executable. The only thing which I can suggest is that you might have a css file which has an executable permission, for some reason, so Apache tries to execute it. Try
chmod a-x
on the CSS file and see if it makes a difference.
Sometimes files copied from Windows have executable set when they shouldn't.