The file /etc/apache2/sites-available/default that comes with the standard build is like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
....
Is there something wrong with line 5: <Directory />? Wouldn't the /> close the <Directory element?
By the way, what is this block supposed to specify?
You're thinking 'proper XML'. An apache configuration file isn't. Strictly speaking, it should probably be enclosed in quotes. (e.g. <Directory "/" >)
That's specifying that - for the 'root' directory on your web server (probably /var/www/html or similar) that symlinks are allowed. (And '.htaccess' is disabled).
http://httpd.apache.org/docs/current/mod/core.html#directory
Related
I'm using Apache2. My server's website (Linode) loads normally only if I include the www.[name].com link. If I use [name].com without the www, I actually receive a page, but it reads the 400 Bad Request Error. Here is my etc/apache2/sites-available files:
website.conf
<VirtualHost *:80>
ServerName website.com
ServerAlias www.website.com
Redirect 301 / https://www.website.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =website.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Here is my website-le-ssl.conf file (for HTTPS/SSL):
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.website.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/name/website/static
<Directory /home/name/website/static>
Require all granted
</Directory>
Alias /media /home/name/website/media
<Directory /home/name/website/media>
Require all granted
</Directory>
<Directory /home/name/website/website>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/name/website/website/wsgi.py
WSGIDaemonProcess django_app python-path=/home/name/website/ python-home=/home/name/website/venv
WSGIProcessGroup django_app
SSLCertificateFile /etc/letsencrypt/live/name.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/name.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
In addition, I do not use .htaccess file, I do not use any other redirect file, and I have already enabled the a2enmod rewrite module. This site sometimes works without the non-www, but there are brief periods of time where it doesn't work and I'm confused as to why it acts this way. Is there a way to get Apache2 to redirect from non-www addresses to www addresses, and how do I make the redirect work ALL the time. Thank you!
Things tried:
I've tried using the RewriteEngine and mod_rewrite on the .htaccess file and I've tried completely restoring everything to default and reconfiguring it all from scratch and tutorials.
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.
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 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.
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.