Run Python under Apache already running PHP using mod_wsgi - mod-wsgi

I am running PHP at the server using apache web-server.
My website is running nice.
Now i need to run python on my web-server without affecting PHP in anyway.
I used the following link to configure mod_wsgi in httpd.conf under apche after installing mode_wsgi.
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
The configuration I updated is as follows:
<VirtualHost *:80>
ServerName www.quipmate.com
ServerAlias quipmate.com
ServerAdmin webmaster#quipmate.com
DocumentRoot /usr/local/www/documents
Alias /robots.txt /usr/local/www/documents/robots.txt
Alias /favicon.ico /usr/local/www/documents/favicon.ico
Alias /media/ /usr/local/www/documents/media/
<Directory /usr/local/www/documents>
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess quipmate.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup quipmate.com
WSGIScriptAlias / /usr/local/www/wsgi-scripts/myapp.wsgi
<Directory /usr/local/www/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After updating and restarting apache, I got 404 error on my index.php file in my web document root. Also it did not helped me any way with the python script which was outputed directly on the browser. Please help.

WHich is exactly what one would expect as you used WSGIScriptAlias to mount the WSGI application at the root of the web site, thus hiding everything else on the web site.
You may want to use the AddHandler and mod_rewrite solution described in the end of the section:
http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive
This will allow PHP files to take precedence and only fall through to the WSGI application if the request is not satisified.

Related

Apache VHost not working but seems to be configured correctly: Mac Os Ventura

The Problem
I've been trying to setup apache on my mac. I installed apache using brew and everything seems to work except when I actually try to navigate the url with my browser.
Anytime I navigate to http://parenting.localhost/ I just get a 404 error. To make things even more odd, if I just go to http://localhost/ (not using the vhost) it still writes the logs to the vhost log files. Clearly something is wrong, I just can't figure it out. Any help would be appreciated.
My Environment
My /usr/local/etc/httpd/extra/httpd-vhosts.conf:
<VirtualHost *:80>
ServerName parenting.localhost
ServerAlias parenting.localhost.com
DocumentRoot "/Users/joshteam/PhpstormProjects/parenting/public"
<Directory /Users/joshteam/PhpstormProjects/parenting/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /Users/joshteam/PhpstormProjects/parenting/storage/logs/error.log
CustomLog /Users/joshteam/PhpstormProjects/parenting/storage/logs/access.log combined
</VirtualHost>
My /etc/hosts:
127.0.0.1 parenting.localhost
127.0.0.1 parenting.localhost.com
I ensure the VHOST is enabled currently:
$ httpd -t -D DUMP_VHOSTS
VirtualHost configuration:
*:80 parenting.localhost (/usr/local/etc/httpd/extra/httpd-vhosts.conf:24)
What I'm Trying To Do
To navigate to http://parenting.localhost/ and for apache to execute the appropriate index.php within the vhost configuration. Instead I get a 404.

Got "The requested URL was not found on this server." error when I hosted my Symfony4 project in AWS EC2

I created a project using Symfony 4 and it works fine in my local environment. Then I hosted my project in AWS EC2 and project installed perfectly. Then I access the root, index.php file works fine and it shows symfony 4 welcome page.
But when I try to go to different URL, it gives me below 404 error.
The requested URL was not found on this server.
Apache/2.4.18 (Ubuntu) Server at 52.221.55.155 Port 80
I can't goto any routes which are defined in the routes.yaml file. But thease routes work fine in my local environment.
Below is the .conf file I used.
<VirtualHost *:80>
ServerName 52.221.55.155
DocumentRoot /var/www/html/oenele-dev-team-server-side/public/
ErrorLog ${APACHE_LOG_DIR}/oenele-dev-team-server-side-error.log
CustomLog ${APACHE_LOG_DIR}/oenele-dev-team-server-side-access.log combined
<Directory "/webhost/public/index.php">
allow from all
</Directory>
</VirtualHost>
Please help me to figure this out.
I found the issue here. Issue was in my .conf file. I change it like below and it works fine now.
<VirtualHost *:80>
ServerName 52.221.55.155
DocumentRoot /var/www/html/oenele-dev-team-server-side/public/
ErrorLog ${APACHE_LOG_DIR}/oenele-dev-team-server-side-error.log
CustomLog ${APACHE_LOG_DIR}/oenele-dev-team-server-side-access.log combined
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
<Directory /var/www/html/oenele-dev-team-server-side/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Directory 'static' gives 404 error

On a Windows machine running XAMPP I have a folder in my web root called 'static'. It and everything in it return a 404 error even though the folder is there.
If I change the name of the folder, e.g. 'statics', all is well. I have other servers (Ubuntu) running Apache and I do not have this problem.
The site is a copy of one of the sites on one of our Linux servers. What can I do or change to allow the directory to work as named?
EDIT vhosts.conf
<VirtualHost *:8080>
ServerAdmin jablanchard#foo.com
DocumentRoot "C:/xampp/htdocs/home/app/gateway"
ServerName localhost
ServerAlias 127.0.0.*
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
</VirtualHost>
<Directory C:/xampp/htdocs/home/app/gateway/>
# allow .htaccess overrides to work
AllowOverride All
DirectoryIndex login.html index.html index.php
</Directory>
# this matches a link to any project directory to the physical webui directory
AliasMatch ^/projects/([-\w]*)/(.*)$ /home/src/gateway/webui/$2
<Directory /home/src/gateway/webui>
DirectoryIndex home.html
Options All
AllowOverride All
Require all granted
</Directory>
I was getting ready to re-install XAMPP but made one last pass through the config files for Apache. I found the problem was this bit of code in the httpd.conf file -
Alias "/static" "C:/xampp/htdocs/static"
<Directory "C:/xampp/htdocs/static">
AllowOverride All
Require all granted
</Directory>
I am not sure if this is part of the XAMPP install as all of the edits I have made to this installation are in the vhosts file. Once commented out the static directory, as I have defined it, works properly now.

Trying to forward domain.com/abcd to some different local subfolder

In the apache server installation I have a .conf file which forwards all requests from www.domain.com to c:\www\domain. Now, i'm trying to forward www.domain.com/abcd to a different subfolder locally (say c:\www\abcd). i tried adding another .conf which looked like this.
<VirtualHost *:80>
ServerName www.domain.com/abcd
DocumentRoot "c:/www/abcd"
ErrorDocument 404 /404.php
ErrorLog "C:/logs/error.log"
CustomLog "d:/logs/access.log" common
<Directory "c:/www/abcd">
RewriteEngine on
AllowOverride All
</Directory>
<Location />
Order deny,allow
Deny from all
Allow from all
</Location>
</VirtualHost>
This doesn't work as intended. When i go to www.domain.com/abcd , I guess its trying to access c:\www\domain\abcd and showing not found error. Is there anyway to solve this issue without making DNS entries and without making changes to your local hosts file?
One possible solution would be to make a symbolic link
mklink /D C:\www\domain\abcd C:\www\abcd

Apache configuration for installing Redmine in URL subdirectory

I have a problem about configuring apache for my installed Redmine.
I've installed Redmine (v 1.2.1) in /usr/local/lib/ directory successfully and it works. I want to configure apache so that Redmine would be accessible through http://myhost/redmine while I've installed a wordpress-based website in /var/www binded to http://myhost/. What should I do?
Here my current apache configuration (/etc/apache2/sites-enabled/001-redmine):
<VirtualHost *:80>
ServerName myhost
DocumentRoot /usr/local/lib/redmine-1.2.1/public
ServerSignature off
<Directory />
Order Deny,Allow
Deny from all
</Directory>
<Directory /usr/local/lib/redmine-1.2.1/public>
AllowOverride None
Order allow,deny
Allow from all
Options Indexes ExecCGI FollowSymLinks
Options -MultiViews
</Directory>
ErrorLog /var/log/apache2/redmine-error.log
CustomLog /var/log/apache2/redmine-access.log combined
</VirtualHost>
Thanks.
You can also follow the FAQ from the Redmine site: http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI
I used Phusion Passenger for the Ruby plugin. I then symlinked the public folder to /var/www/redmine.
My Apache config has:
RailsBaseURI /redmine
<Directory /var/www/redmine>
Options -MultiViews
</Directory>
I had the same problem a while ago and kept some notes. According to what I figured out then, hiding the Redmine Mongrel behind the myhost/redmine dir is not entirely possible. True, Apache can act as a gateway by setting it up the following way:
ProxyPass /redmine/ http://myhost:4000/
ProxyPassReverse /redmine http://myhost:4000
ProxyPreserveHost on
But this would only work if the HTML returned by Redmine contained relative paths and not a single absolute path. Suppose a Redmine page /dir1/whatever.html references a CSS file /resources/styles.css. The client sees the HTML page as /redmine/dir1/whatever.html. If the CSS reference is relative, the client requests /redmine/css/styles.css, and Apache will forward it to the proxy as /css/styles.css. If the reference is absolute, though, the client asks for /css/styles.css, and Apache will not actas a proxy for that one. End of story.
NB: There is a third party module mod_proxy_html which parses the HTML and rewrites the references. But it will not be present on most servers.
The solution, it seemed, was to 301-redirect any requests within the /redmine dir explicitly to the Mongrel at http://myhost:4000 (should be possible with mod_rewrite).