I'm not posting on serverfault because the application is under development and I need to test it in Mono, but it could be suitable there too...
I would like not to ask if it's possible to deploy an ASP.NET MVC website on Apache2 VirtualHost, because it is, but rather if it's possible without interfering with PHP configuration.
The long question
Apache's default PHP configuration looks like this
<IfModule mod_php5.c>
AddHandler application/x-httpd-php .php4
AddHandler application/x-httpd-php .php5
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .php4s
AddHandler application/x-httpd-php-source .php5s
AddHandler application/x-httpd-php-source .phps
DirectoryIndex index.php4
DirectoryIndex index.php5
DirectoryIndex index.php
</IfModule>
And this tells Apache that .php files are PHP scripts.
OK...
Now if I enable mod_mono on server, it maps .aspx files to Mono. And that's OK.
But when I enable the test host VirtualHost with a barebone configuration that is perfect for PHP (it's based on mod_macro if you mind the dollars)
<VirtualHost *:80>
ServerName www.$name
ServerAlias $name
<IfModule mpm_itk_module>
AssignUserID $user $user
</IfModule>
ErrorLog /path/tp/$name/logs/error_log
CustomLog /path/to/$name/logs/access_log combined
DocumentRoot /path/to/$name/htdocs
ServerAdmin email#email
</VirtualHost>
Then I get a 404 error for the default controller.
I know I can, on my own test server, simply say SetHandler mono and voilĂ . But the question affects general-purpose hosting. Also, I could have the answer by myself: since there is no .aspx file in Razor-MVC (or better paths are mapped to controllers via routers) then I obviously get a 404 error for everything that Apache doesn't recognize as a file.
If I want to deploy this Mono application on a server run by a generalistic hosting provider that supports Mono, or vice versa if I would like to offer (on a production server) hosting for PHP and Mono too without having to change configuration according to customer's demands, could I use an Apache configuration that both satisfies Mono and runs PHP?
The shortened question
How can I configure Apache2 once in order to run both PHP and Mono MVC on the same VirtualHost without changing the configuration according to language the application is written in?
go to this configurator
http://go-mono.com/config-mod-mono/
it provide auto make config for Apache2, based on virtualHost.
Now i'm using mod_mono and mod_php5 jointly.
Related
Im trying to finish the set up of roundcube by adding a virtualhost so every subscription on server will use the webmail.servername.com to access it.
I have uploaded this roundcube.conf file with the code:
<VirtualHost ip-one:7080 \ ip-two:7080 \ local-ip:7080>
ServerName roundcube.webmail
ServerAlias roundcube.webmail.*
ServerAdmin "fdmatte#gmail.com"
DocumentRoot "/var/www/roundcube/"
<Directory "/var/www/roundcube/">
Options +FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
</IfModule>
# This is needed to parse /var/lib/roundcube/.htaccess. See its
# content before setting AllowOverride to None.
AllowOverride All
order allow,deny
allow from all
</Directory>
The issues im having are the following:
Using this file when i access my a website like http://www.mywebiste.com it gets routed to http://mywebsite.com
When i access webmail.mywebsite.com roundcube gets loaded but it cant find included files like css and js
It only works correctly if i access the ip-one:7080, then it works fine load up all css and js and i can login, check and send emails.
Is there something wrong with my settings?
Im using a plesk 11.5.30
Redirect http://www.mywebiste.com -> http://mywebsite.com can be switched off in Domain's hosting setting it's "Preferred domain" dropdown
Second issue can appears if you have wildcard subdomain *.mywebiste.com, this is well know plesk 11.5 bug so you can just ask Paralles support for solution. (You can workaround it by youself via customizing virtual hosting templates, but you should know how all this plesk backend works).
It's works for ip-one:7080 because Plesk 11.5 don't configure nginx webmail's config for every domain, just for wildcard webmail.*. So, nginx choose "wrong" virtual server and point it to virtual server of this wildcard subdomain which has location "/internal-nginx-static-location/" where static files will be looking by nginx(he know that is is static files because Plesk apache module mod_aclr2 provide such info for him ), but this location point to vhost folder of subdomain.
It's maybe something else, but I can't say more accurate just by your description.
I've problem to run redmine with vhost_dbd_module from apache. Redmine was installed under /var/www/redmine/ directory. My apache config look:
<VirtualHost *:80>
ServerName HOSTNAME
DocumentRoot "/var/www/" # THIS IS NOT WORKING
# DocumentRoot "/var/www/redmine/public" # THIS WORKS WITH REDMINE
<Directory />
Options FollowSymLinks -MultiViews -Indexes
AllowOverride All
</Directory>
DBDriver mysql
DBDParams host=localhost,user=test,pass=test,dbname=test
DBDocRoot "SELECT document_root FROM vhosts WHERE server_name = %s" HOSTNAME
</VirtualHost>
Field document_root from database return '/var/www/redmain/public' - so it should works. It works for php projects where index file is under '/var/www/project/public'. Besides the page return 404 because in /var/www/redmain/public there is no index file. I want universal config
Any suggestions?
Best regards, Peter
Not havng a index.html is ok :) Check your config/routes.rb.
If rails service is running then your redmine rails check your routes.rb and deliver the default page there (view).
Passenger as an apache module is not compatible with about all modules used to define "dynamic" document roots (including mod_vhost_dbd). For passenger, you have to statically configure your apps in the Apache configuration.
Generally, you will have a hard time emulating your PHP setup with any Ruby app server, as they expect to be started once and run continuously, unlike PHP "apps" which act as scripts resolved and started new for each request. You should rethink your setup for persistent application server processes.
I created .htaccess with content below and it working :)
RailsBaseURI /
PassengerAppRoot /var/www/redmine
Ok I had to move my web to a new host. However new one is running Win 7 ultimate instead of 2008 R2.
To make sure i wont forget something moved over the existing WAMP Apache/PHP versions (bin folders).
It all works fine, except that virtualhosts simply wont redirect to the new documentroot.
it includes the virtualhosts conf file.
NameVirtualHost 88.159.116.217:90 should redirect to
C:/wamp/www/update/ but instead still directs to C:/wamp/www/
This setup worked fine on the 2008 R2. But now its simply ignoring everything defined in the included vhost.conf.
No errors (except that if my software connects to 88.159.116.217:90 - the files are not found since its root folder instead of update).
Code:
ServerAdmin hidden
ServerName hidden
DocumentRoot "C:/wamp/www/update/"
CustomLog logs/rfpatch.log combined
ErrorLog logs/rfpatch_err.log
<Directory "C:/wamp/www/update/">
Options -Indexes MultiViews FollowSymLinks IncludesNoExec
AllowOverride None
AddOutputFilter Includes html
Order allow,deny
Allow from all
AddType application/zip .tmp
AddType application/zip .cab
<Files update.dll>
AddType application/x-httpd-php .dll
</Files>
</Directory>
I don't need a hosts file - I'm not using domains.
There is no admin access problem (uac is also disabled).
the included vhost conf file is loaded - but vhost definitions are ignored.
The Apache version is the same as it was in the 2008 R2 server.
I can only think of two things...
You've not restarted Apache. It needs to be restarted for configuration changes to take effect.
Your Browser is caching the old page... Close all browser windows and tabs, then open the page and press CTRL-F5 to do a hard refresh. Also try clearing the browser cache data, it sometime "remembers" redirects and uses them over and over.
So, I added the following to my http.conf file:
Listen443
NameVirtualHost *:443
<VirtualHost *:443>
DocumentRoot /PATH_TO/www
ServerName www.domain.com
SSLEngine on
SSLCertificateFile /PATH_TO/domain.crt
SSLCertificateKeyFile /PATH_TO/domain.key
SSLCertificateChainFile /PATH_TO/intermediate.crt
</VirtualHost>
https://www.domain.com works now, but it displays the PHP source code? What could be the reason for this?
"Server configuration error" is the reason ;-)
It is choosing to serve PHP files as "plain content" instead of handing them to a PHP engine for processing. This doesn't have anything to do with SSL (it will just as happily send the "plain content" over a secure connection).
From PHP: Installation:
AddModule mod_php.c
LoadModule php_module modules/mod_php.so
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
And from PHP pages won't load:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
See a pattern? :-) In any case, read the fine installation instructions for the particular platform/server.
Happy coding.
It could also be that your php.ini configuration is set to not parse code between short php tags.
In centos this can happen because of php-module missing, to fix that issue we have to install
sudo yum install php-mysql php-devel php-gd php-pecl-memcache
php-pspell php-snmp php-xmlrpc php-xml
Just type LOCALHOST in your browser. then it will open the http://localhost/htdocs/ location. then navigate to your php file. It will open accordingly.
My local development PC is set up to use PHP5 by default, my client's host (1and1.co.uk) is set up to use PHP4 by default.
To enable PHP5 on a 1and1 account, you must add the following line to your .htaccess file:
AddType x-mapp-php5 .php
If I add this line to my local .htaccess file, it breaks my PHP.
How do I add this line conditionally based on the domain (or some other parameter?) so it is only executed by the live site and not my dev site?
I'd like to be able to just upload (FTP) my entire source tree without worrying about having to remember to edit the .htaccess on the server ever time.
e.g.
<IfDomain www.example.com>
AddType x-mapp-php5 .php
</IfDomain>
... rest of .htaccess
Is this possible?
I don't have access to the server config file, only .htaccess
Thanks in advance.
To others looking at this, and using a local server with virtualhost directives: took me a while, and none of the methods found online worked (probably because my MAMP apache version is not 2.4 yet or something), but this one did.
Forget about adding 'conditional' lines to your .htaccess file: you can define which .htaccess file to use in your virtualhost setting!
So just create a file .htaccess_dev, and add this line to your virtualhost definition on your local / dev machine:
AccessFileName .htaccess_dev
So it becomes something like this:
<virtualhost>
ServerName www.example.local
DirectoryRoot /var/www/www.example.local
AccessFileName .htaccess_dev
</virtualhost>
Try this. I have no idea whether it'll work. The terminology used in the documentation suggests that it should, but since no one ever does what you're trying to do, it's a little up in the air.
<Location http://www.example.com/>
AddType x-mapp-php5 .php
</Location>
I know that you can do server-specific commands in httpd.conf using the VirtualHost tag. (http://httpd.apache.org/docs/1.3/vhosts/ip-based.html)
While I'm not 100% sure that you can use this in a .htaccess file, I would suggest trying the following:
<VirtualHost www.example.com>
AddType x-mapp-php5 .php
</VirtualHost>
You can use the VirtualHost directive to accomplish this. I just did the same when I wanted django with mod_python to run only at a subdomain
<VirtualHost *:80>
DocumentRoot /www/docs/path
ServerName www.example.com
....
AddType x-mapp-php5 .php
</VirtualHost>