Apache Mono - 503 Error - mono

When I access my site I see the Mono icon, but trying to access any page gives 503 error - "Service Temporarily Unavailable"
Here is near the end of my httpd.conf (IP addresses hidden):
Include /etc/httpd/conf/mod_mono.conf
<VirtualHost *.80>
DocumentRoot /var/www/html
ServerName 74.63.???.?
</VirtualHost>
And here is my mod_mono.conf
<IfModule !mod_mono.c>
LoadModule mono_module /usr/lib/httpd/modules/mod_mono.so.0.0.0
</IfModule>
<IfModule mod_headers.c>
Header set X-Powered-By "Mono"
</IfModule>
<IfModule mono_module>
AddType application/x-asp-net .aspx
....
DirectoryIndex index.aspx
MonoAutoApplication enabled
MonoDebug false
MonoServerPath "/usr/local/lib/mono/gac/mod-mono-server4/2.10.2.0__032efab45532/mod-mono-server4
Alias /test "/opt/monoserv"
MonoApplications "/test:/opt/monoserv"
SetHandler mono
</IfModule>
</IfModule>

Thanks shunty for the help. I looked at the logs and it said "Failed to connect to mod-mono-server after several attempts to spawn the process."
I changed the MonoServerPath to point to the example in shunty's comment, and changed the paths found in that file to correct ones.
Then I followed the instructions here: http://www.vbforums.com/showthread.php?524548-RESOLVED-mod_mono-with-apache
I still have problems, but at least they aren't related to server configuration anymore. Thanks!

Related

Silverstripe 3.4 - Frontend works fine, but leading slash removed from /admin and /admin/pages

I've inherited an existing Silverstripe 3.4 site and am setting up a new Vagrant VM for it. It has an /app directory that Grunt copies into /public-www on build. Composer pulls everything else into public-www.
Website loads fine. Home page, and subpages multiple levels deep like http://mysite.local/dev/tasks. However it's not possible to load the admin login page.
http://mysite.local/admin redirects to http://mysite.localadmin/pages
(slash removed)
http://mysite.local/admin/pages redirects to
http://mysite.localsecurity/login?BackURL=%2Fadmin%2Fpages (slash
removed again after redirecting to security this time)
http://mysite.local/security/login?BackURL=%2Fadmin%2Fpages redirects
to a 404 (Silverstripe type, not apache)
http://mysite.local/Security/login?BackURL=%2Fadmin%2Fpages (note manually changing to uppercase "Security") loads the login form, but the default dev login defined in _config.php does not work.
Surely an Apache issue. The .htaccess file is the same that is running live right now without issue. But I can't see the problem in either. The following is my apache config (/etc/apache2/sites-enabled/default.conf)
ServerName local
DocumentRoot /var/www/html
<IfModule mod_fastcgi.c>
AddHandler php56-fcgi-www .php
Action php56-fcgi-www /php56-fcgi-www
Alias /php56-fcgi-www /usr/lib/cgi-bin/php56-fcgi-www
FastCgiExternalServer /usr/lib/cgi-bin/php56-fcgi-www -socket /run/php/php5.6-fpm.sock -idle-timeout 1800 -pass-header Authorization
<Directory "/usr/lib/cgi-bin">
Require all granted
</Directory>
</IfModule>
<IfModule mod_fastcgi.c>
AddHandler php71-fcgi-www .php
Action php71-fcgi-www /php71-fcgi-www
Alias /php71-fcgi-www /usr/lib/cgi-bin/php71-fcgi-www
FastCgiExternalServer /usr/lib/cgi-bin/php71-fcgi-www -socket /run/php/php7.1-fpm.sock -idle-timeout 1800 -pass-header Authorization
<Directory "/usr/lib/cgi-bin">
Require all granted
</Directory>
</IfModule>
<IfModule mod_fastcgi.c>
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler php56-fcgi-www
</FilesMatch>
</IfModule>
<Directory "/var/www/">
AllowOverride All
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www/html/mysite/public-www
ServerName mysite.local
<IfModule mod_fastcgi.c>
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler php56-fcgi-www
</FilesMatch>
</IfModule>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/phpmyadmin
ServerName phpmyadmin.mysite.local
<IfModule mod_fastcgi.c>
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler php56-fcgi-www
</FilesMatch>
</IfModule>
</VirtualHost>
I found the cause of this weird URL redirection. The /mysite/_config.php file had this in it:
Director::setBaseURL('http://mysite.local');
It looks like it was there to get around errors when /dev/build was run from the command line, which I have since seen show up, but at least now admin works. I tried adding a trailing slash, and that certainly did fix the URLs, but then I couldn't log in for some reason. Remove it entirely and I can log in.
Note those errors are complaining about this:
You probably want to define an entry in $_FILE_TO_URL_MAPPING that
covers "/var/www/html/website/public-www"
Despite exactly that being right above the setBaseURL() line I removed.
global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING['/var/www/html/website/public-www'] = 'http://mysite.local';
Which I think is in the wrong place in /mysite/_config.php. After moving to _ss_environment.php, all is well there too.

Using AWStats for multiple VHosts - 404 on perl file

I have a server setup using Centos 7 and the Centos Web Panel, I am using this to host several different domains.
I want to enable AWStats for the domains, I have managed to install AWStats, I've added awstats.[domain].conf files for all the domains and I've setup cron jobs to process the logs.
I am now trying to allow each domain to see only their own data, I tried to add the awstats.pl file to their html folder:
/home/[user]/public_html/stats/awstats.pl
But calling this via http://[domain]/stats/awstats.pl gives me a 404 error.
I've also tried the following locations, all of which give the same 404 error:
/home/[user]/public_html/cgi-bin/awstats.pl
/home/[user]/public_html/stats/cgi-bin/awstats.pl
/home/[user]/public_html/awstats.pl
an example of one of my vhosts files is below:
<VirtualHost [localserverip]:80>
ServerName [domain]
ServerAlias www.[domain]
ServerAdmin webmaster#[domain]
DocumentRoot /home/[user]/public_html
UseCanonicalName Off
ScriptAlias /cgi-bin/ /home/[user]/public_html/cgi-bin/
CustomLog /usr/local/apache/domlogs/[domain].bytes bytes
CustomLog /usr/local/apache/domlogs/[domain].log combined
ErrorLog /usr/local/apache/domlogs/[domain].error.log
# Custom settings are loaded below this line (if any exist)
# IncludeOptional "/usr/local/apache/conf/userdata/[user]/[domain]/*.conf"
<IfModule mod_setenvif.c>
SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
</IfModule>
<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled [user]
</IfModule>
<IfModule mod_suexec.c>
SuexecUserGroup [user] [user]
</IfModule>
<IfModule mod_suphp.c>
suPHP_UserGroup [user] [user]
suPHP_ConfigPath /home/[user]
</IfModule>
<IfModule mod_ruid2.c>
RMode config
RUidGid [user] [user]
</IfModule>
<IfModule itk.c>
AssignUserID [user] [user]
</IfModule>
<Directory "/home/[user]/public_html">
Options -Indexes -FollowSymLinks
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
</VirtualHost>
I'm sure there's a misconfiguration with the cgi-bin somewhere but I'm not really familiar with how this works, can anyone see why I can't load the awstats file?
Just don't use perl at all, you can get ALL of the exact same functionality with Node.js with absolutely NO setbacks at all.
You're welcome.

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

apache + php-fpm: Apache forwarding some png requests to php-fpm suddenly

Recently set up PHP-FPM on a server with apache and it's working marvellously, however some png files I'm getting access denied for example https://socialsavanna.com/scripts/candy-1.6.0/res/img/action/statusmessage-off.png
In the error logs i'm getting
FastCGI: server "/{DirectoryToCGIBin}/php5-fcgi" stderr: Access to the script '/{DirectoryToWebsite}/scripts/candy-1.6.0/res/img/action/statusmessage-on.png' has been denied (see security.limit_extensions)
Other pngs are working fine, why is Apache forwarding this to FastCGI to parse as a PHP file? any ideas how I stop this?
Thanks
Edit: Configuration
LoadModule fastcgi_module modules/mod_fastcgi.so
<IfModule mod_fastcgi.c>
DirectoryIndex index.php index.html index.shtml index.cgi
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /{DirectoryToCGIBin}/php5-fcgi
FastCgiExternalServer /{DirectoryToCGIBin}/php5-fcgi -socket /{socketPath}/php5-fpm.sock -pass-header Authorization
# For monitoring status with e.g. Munin
<LocationMatch "/(ping|status)">
SetHandler php5-fcgi-virt
Action php5-fcgi-virt /php5-fcgi virtual
</LocationMatch>
It's obviously your LocationMatch which has "status" in the regex, which matches your filename statusmessage-on.png.
Without more details of what you had expected to match, it will be hard to suggest how to make that more specific. If you meant the URL to start with either of those things, try
<LocationMatch "^/(ping|status)">

Apache 2.4 + PHP-FPM, catching error pages

Here is my vhost file:
<VirtualHost *:80>
ServerName awesome.dev
## Vhost docroot
DocumentRoot "/var/www/awesome"
## Directories, there should at least be a declaration for /var/www/awesome
<Directory "/var/www/awesome">
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
## Logging
ErrorLog "/var/log/apache2/w0JhArMoDehc_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/w0JhArMoDehc_access.log" combined
## Server aliases
ServerAlias www.awesome.dev
## SetEnv/SetEnvIf for environment variables
SetEnv APP_ENV dev
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/awesome/$1
</VirtualHost>
I'm trying to catch all requests for non-existing *.php files.
For example, if /var/www/awesome/index.php exists and I go to http://foo.com/index.php I get the correct response, but if /var/www/awesome/foo.php does not exist and I go to http://foo.com/foo.php, I am simply getting a response of File not found..
The .htaccess file isn't being read because Apache hands everything off to PHP-FPM.
I need to catch all 404 requests and show a common error page, as you would normally see on any site.
However, since Apache hands everything off to php-fpm, it doesn't seem to be handling these errors properly.
For anyone reading today, HERE is the correct answer, thanks to Tito1337 for his answer.
ProxyErrorOverride may give you problems or break your application if you set 404's or handle some errors elsewhere in your code, and is more complicated to implement.
Instead, you should pass the request to php-fpm only if the file exists. If the file does not exist, Apache will direct to your defined ErrorDocument. You can add this check around your PHP handler in the Apache config.
Example for CentOS 8:
#
# Redirect to local php-fpm (no mod_php in default configuration)
#
<IfModule !mod_php5.c>
<IfModule !mod_php7.c>
# Enable http authorization headers
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
<FilesMatch \.(php|phar)$>
# NEW ADDITION - CHECK IF FILE EXISTS FIRST
<If "-f %{REQUEST_FILENAME}">
SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
</If>
</FilesMatch>
</IfModule>
</IfModule>
I used to have the same problem and finally I fixed it.
Try add this after ProxyPassMatch setting:
ProxyErrorOverride on
BTW, do not forget your
ErrorDocument 404 /path/to/file
setting.
As many problems can occur during apache / php-fpm process, many errors can lead to the response
"File not found" and in logs "AH01071: Got error 'Primary script unknown\n'": (double slashes in paths, permissions,...)
To track them you can:
Put in your apache configuration "LogLevel debug" and check error log.
And/Or revert temporary your configuration to "simple apache only try", in my case it lead me to permissions problems (www 0751 needed to be 0755) error wich was invisible before.
Ps: Take care on a other thread, people says that using ProxyErrorOverride for that is "really a bad idea": Server Fault | Apache 2.4 + PHP-FPM + ProxyPassMatch