Need tips to get perl running on Ubuntu LAMP with fastcgi/suexec - perl

I have perl installed on the server and working fine, but I can't get Apache to serve anything with fastcgi/suexec installed. Below is an example of one of my Apache vhost configs without perl as I can't get anything in there to work with perl:
<VirtualHost example.example.example.example:80>
ServerName example.com
ServerAdmin webmaster#example.com
DocumentRoot /home/user/public_html
SuexecUserGroup username username
ScriptAlias /php-fastcgi/ /home/user/php-fastcgi/
FCGIWrapper /home/user/php-fastcgi/wrapper .php
AddHandler fcgid-script .php
Options ExecCGI Indexes
<Directory /home/user/public_html>
Options -Indexes FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/user_error.log
LogLevel warn
CustomLog /var/log/apache2/user_access.log combined

IIRC, you need to use:
use FCGI;
in your Perl script and code with FastCGI in mind. More info can be found here: http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch3perl.htm
The SuexecUserGroup entry looks right and /should/ be all you need to do. At least, it works on my VPS running RedHat.

Related

Zend Framework - don't have permission to access file in public

That is my iframe:
<iframe allowtransparency="true" class="igm" src="/flash/dewplayer-vol.xml&
amp;container=enterprise&view=default&lang=en&country=ALL&sanitize=0&
amp;v=cb90d5949f2275bc&up_CCOL=%23d1dae3&up_START=No&
amp;up_MP3=http://www.youtube-mp3.org/get?video_id=z0FERtqhwHs&
h=6a29a4973a0431d2638ba3f5a1aecfeb&r=1373776845504&up_LOOP=No&
amp;libs=analytics:core:flash&mid=55&rpctoken=-1666220716119396559"
frameborder="0" height="400" scrolling="yes" width="500"></iframe>
But when I open my page it appears:
Forbidden
You don't have permission to access /flash/dewplayer-vol.xml&container=enterprise&view=default&lang=en&country=ALL&sanitize=0&v=cb90d5949f2275bc&up_CCOL=#d1dae3&up_START=No&up_MP3=http://www.youtube-mp3.org/get on this server.
Apache/2.2.8 (Win32) PHP/5.2.6 Server at 212.43.43.254 Port 80
That is my httpd.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:\AppServ\www\site\public
</VirtualHost>
<Directory "C:/AppServ/www/site/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
There some several step you have to follow in web server just go throw all this
1. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines)
2. Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line)
Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out.
And still you have more query then go to this LINK
Also
If you set up your virtual host the default way, i.e.
<VirtualHost *:80>
DocumentRoot "D:/Users/user/www/yourwebsite.dev/public"
ServerName .local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "D:/Users/user/www/yourwebsite.dev/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You may access the public dir, by:
http://yourwebsite.dev/
and files in public dir by:
http://yourwebsite.dev/filename.ext
It is all about DocumentRoot.
i hope this will sure help you.

Can't open localhost after configuring httpd.conf

I've installed Zend Framework, and I've created my project "zendy" to the path: D:\wamp\www\zendy. So I modified the file "httpd.conf" (I use WAMPSERVER) by adding:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName zendy
DocumentRoot D:\wamp\www\zendy\public
<Directory D:\wamp\www\zendy\public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And then I restarted all the services of WAMPSERVER. I add a line "127.0.0.1 zendy" in the file C:\Windows\System32\divers\etc\hosts
Then I type "zendy/" or "localhost" in my navigator but it displays something like:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request."
I totally follow the tutorial for installing zend frameline like :
http://www.youtube.com/watch?v=m7svJHmgJqs and http://framework.zend.com/manual/en/learning.quickstart.create-project.html
Who can help me?? Thanks a lot!!
Verify virtual configuration syntax using “httpd -S”
Also find something like this in httpd.conf and uncomment it by removing the preceding # sign before Include
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
Please don't remove the # sign before Virtual hosts as depicted above.
Also, add
Options Indexes FollowSymLinks
before
AllowOverride All
and restart wamp
Here is the correct configuration:
<VirtualHost *:80>
ServerName zendy
DocumentRoot D:\wamp\www\zendy\public
</VirtualHost>
You do not need to mention directory under this.
Try and revert! :)
PS: Also, check for AllowOverride in your main httpd.conf or apache2.conf file. Hope it helps!

How to create multiple virtual hosts with apache2 and zend

I have created zend application in /var/www/zendapp , but i have also installed mediawiki app
in /var/www/mediawiki
Now i want to access mediawiki app with http://mediawiki.local
and http://zendapp.local.
How can i do that?
I had couple of unsuccessful atempts. So far i edited /etc/hosts and added these two lines:
127.0.0.1 zendapp.local
127.0.0.1 mediawiki.local
I also created two files in /etc/apache2/sites-available/ :
zendapp
mediawiki
mediawiki :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mediawiki.local
DocumentRoot /var/www/mediawiki
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/mediawiki>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
zendapp :
ServerName zendapp.local
SetEnv APPLICATION_ENV "development"
DocumentRoot /var/www/zendapp/public
<Directory /var/www/zendapp/public>
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
But now it semes that only zendapp.local works, and if I go to :
http://mediawiki.local
it redirects me to http://zendapp.local/mediawiki/index.php/Main_Page
Do this: Separate virtualhost blocks:
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mediawiki.local
DocumentRoot /var/www/mediawiki
#all other settings
.
.
.
</VirtualHost>
<VirtualHost *:80>
ServerName zendapp.local
DocumentRoot /var/www/zendapp/public
#all other settings
.
.
.
</VirtualHost>
Check out this blog, his answer worked!
http://justanswersnobullshit.wordpress.com/
I tried this out myself, after being frustrated by online video tutorials on how to setup multiple virtual hosts
And you do not accidentally forgot to include this site? That is, in the 'sites-enabled' directory should be by appropriate reference. Usually you should run the following commands:
sudo a2ensite host_name
sudo service apache2 reload
As a second variant, I can suppose, that 'DocumentRoot' should be ended by a slash:
DocumentRoot /var/www/zendapp/public/

.htpasswd without .htaccess

I would like to protect a web folder via .htpasswd.
However, as the .htaccess file is under version control, I would prefer to not mess with it.
Instead, I would like to have the configuration in
/etc/apache2/sites-enabled/mysite
/etc/apache2/.htpasswd
Any idea what I need to put in the "mysite" apache configuration file?
So far it is sth like this,
<VirtualHost (ip address):80>
ServerName my.domain
DocumentRoot /var/sites/sitename
ServerAdmin ...
</VirtualHost>
Heureka, I figured it out myself.. or what I think to be the solution.
<VirtualHost (ip address):80>
ServerName my.domain
DocumentRoot /var/sites/sitename/
ServerAdmin ...
<Directory /var/sites/sitename/>
AuthUserFile /etc/apache2/.htpasswd
AuthGroupFile /dev/null
AuthName "What is the pw"
AuthType Basic
require user (username)
</Directory>
</VirtualHost>
The .htpasswd can be created in the usual way via commandline,
# htpasswd /etc/apache2/.htpasswd (username)
EDIT: anthony in the comment below strongly recommends you use https/SSL, to prevent the password from being sent unencrypted.

Mason and Apache configuration, loading files that don't exist

I have a really strange behavior while using Mason, for example:
I have an index.html file ( that contains mason tags like <% $var %> hello ).
When I'm browsing to http://bla.com/index.html the variable is translated during compilation.
But there's a strange behavior when I'm browsing to http://bla.com/index.
Though there's no file called index (only index.html) it still loads index.html and the entire code is shown as plain/text including the <% ... %> !!!
What have I configured wrong ?
this is my Apache configuration:
<VirtualHost *:80>
ServerAdmin webmaster#abc.com
ServerAlias abc.com www.abc.com
ServerName abc.com
DocumentRoot /var/www/abc.com
DirectoryIndex index.html
<Directory "/var/www/abc.com/">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SetHandler perl-script
PerlModule HTML::Mason::ApacheHandler
PerlSetVar MasonUseObjectFiles 1
<LocationMatch "(\.html|\.txt|\.pl|\.js)$">
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</LocationMatch>
<LocationMatch "(\.m(html|txt|pl)|dhandler|autohandler)$">
SetHandler perl-script
PerlHandler Apache::Constants::NOT_FOUND
</LocationMatch>
After a ~year I accidently found the answer, so I wanted to share my findings:
The problem was that Mason(Perl) displaying the code itself of another file on the web instead of providing "404 file not found" and I had no idea how to stop it. e.g: when requesting index it shows the code of index.html
The solution is that in my Apache configuration there was the following:
<Directory "/var/www/my_dir/">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Apparently "MultiViews" is activated through mod_negotiation.c, which cause the site to search for a pattern of the next-best match in-case the file is not found on the server. ( so from www.site.com/index it found index.html )
But because there's no configuration in the Apache to execute /index in Mason ENV ( no file extension ) , it simply displayed the code ...
Funny :) but the solution was to change "Options FollowSymLinks MultiViews" to "Options FollowSymLinks -MultiViews" and not using the MultiViews.
Found this solution while seen the following response headers:
Content-Location index.html
Vary negotiate
The "MultiViews" doesn't have any meaning to me, as it was a copy-paste from a 5 years ago that I simply carried from one web-server to another :)
Thanks,
Ricky.
Why the webserver automagically
translates index into index.html
still insists on treat it specially (it apparently don't feed it into the PerlHandler as it should) I honestly don't know (perhaps the answer is elsewhere in your configuration).
However, you could as a work around try to add 'index' (or perhaps rather'^index') to the regex that defined what files should be dispached to HTML::Mason::ApacheHandler. I do admit it is a bit ugly though.
Am I correct that once you load the index page and get that verbatim code displayed, once you check out the page info, the encoding is literally plain/text? Perhaps you need to configure some mime settings to ensure that files without suffixes (files not ending with .html etc) are not sent to the remote browser at all, not even as plain/text?