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.
Related
I have one local server called server1 with a subdirectory sub (server1/sub/).
Now i have a dns entry which redirects server2 to server1.
I want to configure my apacher server in a way that when I open server2 in a browser I get the content from server1/sub/.
The url should not change to server1/sub/.
Is this possible with mod_rewrite?
EDIT:
I added
127.0.0.1 localhost
127.0.0.1 wiki2
127.0.0.1 wiki3
to the hosts file and
VirtualHost 127.0.0.1>
ServerName wiki2
ServerAlias 127.0.0.1
DocumentRoot c:/xampp/htdocs/wiki_angua
<Directory c:/xampp/htdocs/wiki_angua >
Allow From All
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName wiki3
ServerAlias 127.0.0.1
DocumentRoot c:/xampp/htdocs/weatherwax
<Directory c:/xampp/htdocs/weatherwax >
Allow From All
</Directory>
</VirtualHost>
to httpd.conf and restarted apache.
Whether I open wiki2 or wiki3 I land in ./wiki_angua.
Is there anything I forgot?
If you have a DNS entry for server2 then the Host HTTP request header will be correctly set, and all you need then is a virtual host, without the need to use mod_rewrite.
For example:
<VirtualHost *:80>
ServerName server2
DocumentRoot /path/to/server1/sub
<Directory /path/to/server1/sub>
Allow From All
</Directory>
# ... etc
</VirtualHost>
edit:
In the case you still want to use mod_rewrite you can do something like:
RewriteCond %{HTTP_HOST} ^server2$
RewriteRule ^(.+) /path/to/server1/sub/$1
This must be located in the global server configuration, and not in an existing virtual host.
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!
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/
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.
I run a Rails app on Passenger and it all works like it should.
I want to add a Sinatra app to run as a Rack application with Passenger, but I get a routing error.
My VirtualHosts File looks like:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain1.com
DocumentRoot /home/user1/vhosts/project1/public
ErrorLog /home/user1/vhosts/project1/log/httpd_error_log
CustomLog /home/user1/vhosts/project1/log/httpd_access_log combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.sub.domain2.com
DocumentRoot /home/user2/vhosts/sinatra_app/lib/public
ErrorLog /home/user2/vhosts/sinatra_app/lib/log/httpd_error_log
CustomLog /home/user2/vhosts/sinatra_app/lib/log/httpd_access_log combined
</VirtualHost>
My Sinatra app is really simple; I have a route called get "/do_something" do .... with no public files. it only responds with some JSON.
How can I make it do requests like www.sub.domain2.com/do_something
It seems OK,are the priviledges set correctly?