mod_mono on windows - asp.net

I am trying mod_mono on apache 2.2.x running on a win7 box – followed the steps described here.
The module loads Ok, but I can't run my ASP.net application (404). Does anybody have any suggestions or an example configuration that works? Thanks.

My working config:
<VirtualHost *:80>
ServerAlias localhost
DocumentRoot "c:\web\mysite"
MonoServerPath mysite "c:\mono\usr\bin\mod-mono-server2.exe"
MonoApplications mysite "/:c:\web\mysite"
<Directory "c:\web\mysite">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
MonoSetServerAlias mysite
SetHandler mono
DirectoryIndex default.aspx index.html
</Directory>
</VirtualHost>

I found a good tutorial for you.
Example mono configuration:
MonoServerPath default /usr/bin/mod-mono_server2
Alias [D] “[P]”
AddMonoApplications default “[D]:[P]”
<Location [D]>
SetHandler mono
</Location>
Another example:
MonoServerPath default /usr/bin/mod-mono_server2
Alias /MySite “/srv/www/htdocs/MySite”
AddMonoApplications default “/MySite:/srv/www/htdocs/MySite”
<Location /MySite>
SetHandler mono
</Location>

Related

wordpress site working locally but not from the domain

My wordpress site is working locally in my wamp server, this is hosted on an ec2 instance and domain is maintained in Route 53\cloudfare. The domain is working when i checked it using mxtoolbox. The site was working and live till the time i changed my host file in the server. I removed the host file entries accidentally thinking it is a dev site, however i restored it but still the site is not working and i am getting only the "TOO MANY REDIRECTS" error. The following is the current windows host file details
#
127.0.0.1 localhost
::1 localhost
127.0.0.1 mydomain.com
::1 mydomain.com
I restarted the server and WAMP multiple times but it is not working.
The following is my virtualhost configuration
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "c:/wamp/www/sitefolder"
<Directory "c:/wamp/www/sitefolder/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.mydomain.com
DocumentRoot "c:/wamp/www/sitefolder"
<Directory "c:/wamp/www/sitefolder/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>`
Clean your cache and browser history first, then try doing it below:
Open your wordpress admin panel --> Settings--> General --> Make sure it points to the correct domain. --> Save
Or go to the wp-config.php file (Try this if the first method fails / can't be accessed)
add:
define('WP_HOME','http://YourDomain.com');
define('WP_SITEURL','http://YourDomain.com');
or
Try to remove or rename default .htaccess
or
Try to disable the plugin (renaming the plugin folder in the "wp-content/plugin/plugin-folder-name" will non-active that plugin. This might solve the problem if the constraints are due to the plugin)
That's a number of ways when I resolve the ERR_TOO_MANY_REDIRECTS problem. Goodluck

Apache configuration to serve 2 website and APIs under the same domain

I would like to configure Apache in order to have under the same domain:
a static website (it is a Single Page Application created with
create-react-app) deployed in /var/www/html/ui
a WordPress instance deployed in /var/www/wordpress/Commdev
some Node.js APIs running on http://localhost:3000/api
I would like to have the following URL mapping:
mydomain.com/ -> to the static website
mydomain.com/admin -> to the WordPress instance (mydomain.com/admin/wp-admin to the Admin Panel of WordPress )
mydomain.com/api -> proxy the Node.js APIs
This is my initial configuration
ServerName 127.0.0.1:80
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /api>
ProxyPass http://localhost:3000/api
ProxyPassReverse http://localhost:3000/api
</Location>
Alias /admin /var/www/wordpress/Commdev
<Directory /var/www/wordpress/Commdev>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Alias / /var/www/html/ui
<Directory /var/www/html/ui>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
How would you address the situation?
Many thanks in advance
This is the final configuration:
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot /var/www/html/ui
ProxyRequests Off
ProxyPreserveHost On
# ProxyVia Full
<Location /api>
ProxyPass http://localhost:3000/api
ProxyPassReverse http://localhost:3000/api
</Location>
<Location />
Options Indexes FollowSymLinks
#AllowOverride None
Order Allow,Deny
Allow from all
</Location>
Alias /admin /var/www/wordpress/Commdev
<Location /admin>
Options Indexes FollowSymLinks
#AllowOverride All
Order Allow,Deny
Allow from all
</Location>
</VirtualHost>

How to point URL path to a wordpress folder

I currently have two sites, hosted on the same server using Apache virtual hosts.
http://www.example.com -> /var/www/sites/mysite (path to main website)
http://blog.example.com -> /var/www/sites/blog (path to wordpress folder)
I need my blog to be accessible from www.example.com/blog
I cannot move the wordpress installation into a 'blog' subdirectory of the mysite folder.
Using the Apache Alias directive, I can do the following in the configuration for www.example.com:
Alias /blog /var/www/sites/blog
and access the blog via www.example.com/blog
However the following fails to work with a 404
www.example.com/blog/a-permalink-post-title
I have also tried using the following but the 404 still persists.
AliasMatch /blog/(.*)$ /var/www/sites/blog/$1
The current virtual host configuration looks like this:
<VirtualHost *:80>
ServerName www.example.com
Alias /blog /var/www/sites/blog
DocumentRoot /var/www/sites/mysite
<Directory /var/www/sites/mysite>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
and for blog.example.com
<VirtualHost *:80>
ServerName blog.example.com
DocumentRoot /var/www/sites/blog
<Directory /var/www/sites/blog>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Would greatly appreciate any help with this.

Setting up ModMono With Apache2

I ended up attempting to setup ASP with ModMono on Apache2, via following this guide.
It's not working, however: when I click a .aspx file, I end up just downloading it on my localhost.
Here's my asp.webapp file /etc/mono-server2
<apps>
<web-application>
<name>asp</asp>
<vpath>/asp</vpath>
<path>/var/www/asp/</path>
<vhost>127.0.0.1</vhost>
</web-application>
</apps>
and my asp file in /etc/apache2/sites-available/
<Virtualhost 127.0.1.1:80>
ServerName asp
DocumentRoot /var/www/asp/
<Directory /var/www/asp/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
SetHandler mono
DirectoryIndex index.aspx index.html
</Directory>
</VirtualHost>
Is there anything which I'm doing wrong here? The only issue I can think of is that I'm trying to reference a directory, rather than a specific page or file.
If you have installed mod_mono and it is configured correctly to work with apache2 then all you will need to do is change your site configuration in /etc/apache2/sites-available/ to something like this:
<Virtualhost 127.0.1.1:80>
ServerName asp
DirectoryIndex index.html index.aspx
DocumentRoot /var/www/asp/
AddMonoApplications asp "/:/var/www/asp"
MonoServerPath asp "/usr/bin/mod-mono-server2"
<Directory /var/www/asp/>
MonoSetServerAlias asp
SetHandler mono
AddHandler mod_mono .aspx .ascx .asax .ashx .config .cs .asmx
<FilesMatch "\.(gif|jp?g|png|css|ico|xsl|wmv|zip)$">
SetHandler None
</FilesMatch>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
SetHandler mono
DirectoryIndex index.aspx
</Directory>

Running 2 websites with mono

I have 2 websites: myDomain1.example & myDomain2.example
Both run on the same Apache server with Mono. However my issue is that I cannot get them working at the same time. When I go to myDomain2.example it shows the aspx content of myDomain1.example. Occassiononly this is inversed. So that myDomain1.example shows the content for myDomain2.example. I think this happens when I restart Apache. Anythoughts on what might be happening here?
my Config. ( The config for myDomain2.example is exactly the same except all the relevant properties are called myDomain2.example )
<VirtualHost *:8014>
ServerAdmin webmaster#myisp.com
DocumentRoot /home/advanced/myUserName/public_html/myDomain1.example
ServerName myDomain1.example
ServerAlias www.myDomain1.example devel.myDomain1.example
CustomLog logs/myDomain1.com-access.log combined
ScriptAlias /cgi-bin/ /home/advanced/myUserName/public_html/myDomain1.example/cgi-bin/
## Mono (ASP.NET)
MonoUnixSocket myDomain1.example /home/advanced/myUserName/tmp/mod_mono.sock
MonoWapidir myDomain1.example "/home/advanced/myUserName/tmp/"
MonoApplications myDomain1.example "/:/home/advanced/myUserName/public_html/myDomain1.example/"
AddMonoApplications myDomain1.example "/:/home/advanced/myUserName/public_html/myDomain1.example/"
<Location /myDomain1.example>
AddHandler mono .aspx .ashx .asmx .ascx .asax .config .ascx
MonoSetServerAlias myDomain1.example
</Location>
</VirtualHost>
<Directory /home/advanced/myUserName/public_html/myDomain1.example/cgi-bin/>
SetHandler cgi-script
</Directory>
Since your config file contains a lot of stuff I wouldn't necessarily use, I would suggest starting from the basics and adding stuff until it breaks again.
I'm successfully running multiple sites on my Mono server, and my config is done as follows:
Create a file in your Apache2 sites-enabled folder for each of the domains and add the following:
<VirtualHost *:80>
ServerName www.example.com
ServerAdmin webmaster#example.com
DocumentRoot /var/www/domain1
DirectoryIndex index.html index.aspx
AddMonoApplications blogsite "/:/var/www/domain1"
MonoServerPath blogsite "/usr/local/bin/mod-mono-server2"
<Directory /var/www/domain1>
MonoSetServerAlias domain1
SetHandler mono
AddHandler mod_mono .aspx .ascx .asax .ashx .config .cs .asmx
<FilesMatch "\.(gif|jp?g|png|css|ico|xsl|wmv|zip)$">
SetHandler None
</FilesMatch>
DirectoryIndex index.aspx
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
You will obviously have to change all the paths and domains to ones that match your server configuration.

Resources