Apache and mod_mono not playing well together - apache

I'm trying to get Mono to work on CentOS 5, however haven't had much success so far. This is what I did:
> yum install mono-web
> yum install xsp
> yum install mod_mono
> echo ":CLR:M::MZ::/usr/bin/mono:" > /proc/sys/fs/binfmt_misc/register
Ensured that the following line is present in /etc/httpd/conf/httpd.conf:
Include conf.d/*.conf
Ensured that /etc/httpd/conf.d/mod_mono.conf exists and looks like this:
<IfModule !mod_mono.c>
LoadModule mono_module /usr/lib/httpd/modules/mod_mono.so
AddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex default.aspx
DirectoryIndex Default.aspx
<Location /mono-ctrl>
SetHandler mono-ctrl
</Location>
</IfModule>
Created /etc/httpd/conf.d/mono-vhost.conf and inserted the following:
<VirtualHost *>
DocumentRoot /var/www/html
Alias /demo /usr/local/lib/xsp/test
MonoApplications "/demo:/usr/local/lib/xsp/test"
MonoServerPath /usr/bin/mod-mono-server2
<Location /demo>
SetHandler mono
</Location>
</VirtualHost>
And finally:
> apachectl restart
Then I browsed to http://my.server.ip.address/demo/index.aspx, expecting to see an ASPx page; instead my browser prompted me to download that file. There is nothing in the Apache error log.
I've got other websites running on this box via PHP and they work perfectly, so I'm pretty sure it's just mod_mono that's weird, but for the life of me I can't figure out what the problem is. If anyone can point me in the right direction, it would be most appreciated.

Eventually got it working with the help of the following tutorial:
http://blog.palehorse.net/2008/11/06/my-adventures-installing-mono-20-on-centos-4-to-work-with-apache-via-mod_mono/
Although it's for CentOS 4 it works just as well on CentOS 5.x. :)

Related

URL wants me to download a file

I have a web application on Apache/Ubuntu 14.04 that was running fine until I upgraded the server to Ubuntu 18.04. Now when I visit the site, It automatically asks me to download a file. The file that it wants to download is the launch page of the web application. The file is called index.asp. I do have the dir module enabled.
<IfModule mod_dir.c>
DirectoryIndex index.asp index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
I also compared the apache modules from the server that has 14.04 to the 18.04 and they are identical.
Here is the vhost file.
<VirtualHost _default_:443>
ServerName xxxxxxxx.net
ServerAlias xxxxxxx.net
DocumentRoot /home/computer/xxx/xxxxxx/htdocs
<Directory /home/xxxxx/xxxxx/xxxxx/htdocs>
Options -Indexes +ExecCGI +FollowSymLinks
Require all granted
</Directory>
I did add this to the vhost file and restarted apache but id didn't work.
AddHandler php5-script .php .asp .aspx .ascx .ashx .asmx .pl
AddType text/html .php .asp .aspx .ascx .ashx .asmx .pl
No errors in the apache logs

SSI Not Working on Ubuntu 16.04 and Apache 2.4.18

I'm trying to run bWAPP SSI injection lesson. However it seems SSI doesn't work on my computer. I'm using PHP 5.6.30 and Apache 2.4.18 on Ubuntu 16.04. I've added the following to /etc/apache2/apache2.conf but not working
<Directory /var/www/html/bWAPP/>
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</Directory>
Adding the following to /var/www/html/bWAPP/.htaccess is also not working
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
I've restarted the Apache server but still not working.
Is there anything I have to do to enable SSI?
To enable ssl on Ubuntu/Apache-WebServer you need to take next steps on command line:
a2enmod ssl
a2ensite default-ssl.conf
service apache2 restart
For specific virtual host just copy default-ssl.conf to, for example, bwapp.conf and change that file similar to look like this
ServerName bwapp.youserver.com
ServerAlias www.bwapp.yourserver.com
ServerAdmin webmaster#yourserver.com
DocumentRoot /var/www/html/bwapp/
<Directory /var/www/html/bwapp>
Options FollowSymLinks
DirectoryIndex index.php
</Directory>
After that, enable this virtual host from command line
a2ensite bwapp.conf
service apache2 restart
Good luck.

Apache httpd bad request when accessing by ip address - Review Board

I have setup Review Board and it works fine when accessed from localhost.
When I try to access it by ip (from LAN), I get BAD REQUEST.
I have copied apache-wsgi.conf to my apache conf directory.
apache-wsgi.conf
<VirtualHost *:8088>
ServerName localhost
DocumentRoot "/var/www/reviews.als.kz/htdocs"
# Error handlers
ErrorDocument 500 /errordocs/500.html
WSGIPassAuthorization On
WSGIScriptAlias "/reviews" "/var/www/reviews.als.kz/htdocs/reviewboard.wsgi/reviews"
<Directory "/var/www/reviews.als.kz/htdocs">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
# Prevent the server from processing or allowing the rendering of
# certain file types.
<Location "/reviews/media/uploaded">
SetHandler None
Options None
AddType text/plain .html .htm .shtml .php .php3 .php4 .php5 .phps .asp
AddType text/plain .pl .py .fcgi .cgi .phtml .phtm .pht .jsp .sh .rb
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
</Location>
# Alias static media requests to filesystem
Alias /reviews/media "/var/www/reviews.als.kz/htdocs/media"
Alias /reviews/static "/var/www/reviews.als.kz/htdocs/static"
Alias /reviews/errordocs "/var/www/reviews.als.kz/htdocs/errordocs"
Alias /reviews/favicon.ico "/var/www/reviews.als.kz/htdocs/static/rb/images/favicon.png"
I have installed reviewboard into /var/www/reviews.als.kz directory.
Chown-ed it to apache:apache.
I run it on Fedora 21.
Review Board version 2.0.12
Apache httpd version 2.4.10
Thanks
The problem had been with python settings.
Added my ip address to ALLOWED_HOSTS within settings_local.py file and everything worked.
Thanks
I had the same problem. When you configure your reviewboard, you have to give it a site name . Some thing like "reviewboard.mycompany.com". It doesn't have to be a registered name just make up something.
Then when you try to access the reviewboard main page, use the site name (reviewboard.mycompany.com) as the URL. You'll of course need to add the made-up hostname to to your /etc/hosts so your machine can resolve the address.
Create a host entry / DNS entry with the site name. like
reivews.mycompany.com x.x.x.x
It's worked for me.
I had the same problem.
Fixed it by adding this line to my httpd.conf :
HttpProtocolOptions unsafe

How to select file in subdirectory by "files" directive?

I want to compile PHP code in specific .htm file, if file located at root directory of domain I can add
<Files file.htm>
AddType application/x-httpd-php5 .htm
</Files>
to .htaccess, but what should I do if file located at another directory(/sub/file.htm, for example)?
Maybe it could be done if your are using httpd 2.4 which has <if> supports
<If "%{PATH_INFO} =~ /.*\/sub\/(file|anotherfile|andanother)\.htm/">
AddType application/x-httpd-php5 .htm
</If>
Maybe you want to use the httpd.conf instead of .htaccess file. You could then use <Location>-directive in this case:
<Location /sub/file.htm>
AddType application/x-httpd-php5 .htm
</Location>
Note that if you want to use a regexp to match the location you need to write a ~ before the location or use the <LocationMatch>-directive.
E.g.:
<Location ~ "/sub/(file|anotherfile|andanother).htm">
AddType application/x-httpd-php5 .htm
</Location>
EDIT:
Another possible solution (also only in virtualhost-config) should be a combined <Directory> and <Files>-directive:
<Directory /sub>
<Files file.htm>
AddType application/x-httpd-php5 .htm
</Files>
</Directory>
Try FilesMatch:
<FilesMatch "file.htm$">
AddType ...
</Files>
It applies a regex to the filename, so this'll match any file path which has "file.htm" at the end. It'd apply to any file in any directory that ends with "file.html". Note that this would also match on "somefile.htm" and "/subdir/somefile.htm". If you've got other files in your site tree that could trigger this, you'll have to mod the regex to exclude them.

phpmyadmin - list files in directory

I have apache+mysql+phpmyadmnin under Gentoo.
phpmyadmin-3.2.2
It worked fine before, but now, when I'm loading http://localhost/phpmyadmin I get a list of flies in phpmyadmin-directory, and when I chose index.php, I get it's own code.
What I did wrong?
It means that apache does not recognizes neither of your files as php executables. Maybe you run an 'emerge update world' and then an 'env-update' which install a new apache2 version and then re-write the old apache config file. As LiraNuna mentioned, you need to check that the phpMyAdmin directory contains the proper instruction to load the proper PHP module. In this way apache will know how to handle the php files.
This is what I have on /etc/apache2/vhosts.d/default_vhost.include under the phpMyAdmin Directory definition:
Alias /phpMyAdmin /var/www/localhost/htdocs/phpMyAdmin
<Directory /var/www/localhost/htdocs/phpMyAdmin>
Options Indexes FollowSymLinks
DirectoryIndex index.php
# Authorize for setup
<Files setup.php>
# For Apache 1.3 and 2.0
<IfModule mod_auth.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
# For Apache 2.2
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
Require valid-user
</Files>
<IfModule mod_php4.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
&lt/IfModule>
<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
php_value include_path .
</IfModule>
</Directory>
This should solve your problem.
Is mod_php5 installed? If so, do you have the php handler set up to handle .php files?
<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml .php4 .php3
AddType application/x-httpd-php-source .phps
</IfModule>
If you are not using mod_php5, do you use any form of CGI? Do the .php files have execute permissions?