Apache 2 Expect </Directory> but saw </VirtualHost> - apache2

I'm trying to install DAViCal+CalDavZap in Debian 8.0. And have this problem:
/etc/apache2/sites-enabled/dav.conf:
# Virtual Host def for Debian packaged DAViCal
<VirtualHost *:80>
DocumentRoot /usr/share/davical/htdocs
DirectoryIndex index.html index.php
ServerName davical.local
Alias /images/ /usr/share/davical/htdocs/images/
Alias /cal /var/www/caldavzap/
<Directory /usr/share/davical/htdocs/>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
php_value include_path /usr/share/awl/inc
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value error_reporting «E_ALL & ~E_NOTICE»
php_value default_charset «utf-8»
</VirtualHost>
and sudo service apache2 restart:
Syntax error on line 18 of /etc/apache2/sites-enabled/dav.conf: Expected </Directory> but saw </VirtualHost>
Action 'start' failed.
Can you say me what could it be, what should i check, please?

Related

VirtualHost on Apache2 gives no response

I'm trying to create a virtual host on apache2 but I am getting no response. I have tried serveral tutorials but nothing has helped. This is my file:
<VirtualHost *:80>
ServerName androidwebservice.com
DocumentRoot "/var/www/my_webservice/public"
LogLevel warn
ErrorLog /var/log/apache2/redmine_error.log
CustomLog /var/www/my_webservice/android_access.log combined
<Directory "/var/www/my_webservice/">
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
RailsEnv production
RailsBaseURI /my_webservice
PassengerResolveSymlinksInDocumentRoot on
</Directory>
</VirtualHost>
I have enabled it using the command sudo a2ensite androidbackend(this is the file name). The file is located in /etc/apache2/sites-available.
The ServerName has been declared in /etc/hosts:
127.0.1.1 androidwebservice.com
Are you visiting androidwebservice.com or www.androidwebservice.com
Because you have declared androidwebservice.com not www.androidwebservice.com
The basic (working) example is over here:
https://reformatcode.com

How do I set up LAMP without the forbidden message when viewing my site?

I use a Linux Mint 16 + newest LAMP + Laravel.
I'm getting this error when I try viewing my website either via "localhost" or "127.0.0.1".
Forbidden
You don't have permission to access / on this server.
------------------------------------------------------
Apache/2.4.6 (Ubuntu) Server at 127.0.0.1 Port 80
My setting are as follows:
on /etc/hostname
NameServer ynwlocalwebserver
on /etc/hosts
127.0.0.1 localhost
127.0.1.1 ynwlocalwebserver
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I only have one site-enable named "ynwlocalwebserver.conf" it's current contents for the meantime are:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName ynwlocalwebserver
DocumentRoot /home/ynwmint/ynw/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/ynwmint/ynw/public>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /home/ynwmint/ynw/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/ynwmint/ynw/public>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
The folder ynw in "/home/ynwmint/ynw/public" is the Laravel project.
I put the chmod of the public folder to 777 (for the meantime) and chown it under www-data:www-data
What am I doing wrong, or what else do I need to check?
Thanks.
Apache 2.4 has some minor changes with regards to config.
This:
ServerName ynwlocalwebserver
DocumentRoot /home/ynwmint/ynw/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/ynwmint/ynw/public>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Should be changed to this:
<VirtualHost *:80>
ServerName ynwlocalwebserver
DocumentRoot /home/ynwmint/ynw/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/ynwmint/ynw/public>
Options +Indexes +FollowSymlinks + MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Also for added security you may want to this directory rule:
<Directory />
Options FollowSymlinks
AllowOverride None
</Directory>
Source: http://httpd.apache.org/docs/2.4/upgrading.html

How to add access.log to each vhost in apache

Here is my current vhost:
<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/public
<Directory /var/www/%0/public>
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php index.html
AllowOverride All
Order allow,deny
Allow from all
</Directory
</VirtualHost>
How can I get a access.log for each %0 vhost?
FYI.. If it matters, this is a debian install.
You can add the TransferLog in your VirtualHost definition. Don't forget to restart your Apache service when changing configuration.
<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/public
ErrorLog/var/logs/%0/error.log
TransferLog /var/logs/%0/access.log
<Directory /var/www/%0/public>
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php index.html
AllowOverride All
Order allow,deny
Allow from all
</Director>
</VirtualHost>

Apache2 is not wanting to be deleted

I am having trouble removing a VirtualHost, so I thought of just simply editing the /etc/apache2/sites-available/default file. It turns out that I am trying to add the original 'index.html' file, which I have in the /var/www/ directory. But it is not working because another VirtualHost has taken port 80 and I don't see my 'index.html' file listed there in the default file. I am super frustrated, so I am thinking of just doing a fresh install of the apache2 service. But even though I use this command to remove it:
sudo apt-get install --remove apache2 php5 libapache2-mod-php5
Even though I do this, it is not removed and I get this error at the end of the process:
Errors were encountered while processing:
libopenvnc-imgproc2.3
libavfilter2:armhf
libav-tools
ffmpeg
E: Sub-process /usr/bin/dpkg returned an error code (1)
Is there any way to do a fresh install of apache2 along with php5 and libapache2-mod-php5 as I had installed them when I first got my Pi? I am just lost, I have gone to a million forums and none have helped me.....
Here is the 'default' file text:
NameVirtualHost *:8091
NameVirtualHost *:80
NameVirtualHost *:443
This is what I tried doing, but it didn't work, it said the file couldn't be found!
<VirtualHost *:80>
DocumentRoot /var/www/remote_replay.php
ServerName 192.168.1.80
</VirtualHost>
This part below works fine, but I want it removed!!!!!
WSGIDaemonProcess web2py user=www-data group=www-data
<VirtualHost *:8091>
WSGIProcessGroup web2py
WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /home/www-data/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
/home/www-data/web2py/applications/$1/static/$2
<Directory /home/www-data/web2py/applications/*/static/>
Options -Indexes
Order Allow,Deny
Allow from all
</Directory>
<Location /admin>
Deny from all
</Location>
<LocationMatch ^/([^/]+)/appadmin>
Deny from all
</LocationMatch>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/self_signed.cert
SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key
WSGIProcessGroup web2py
WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /home/www-data/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
/home/www-data/web2py/applications/$1/static/$2
<Directory /home/www-data/web2py/applications/*/static/>
Options -Indexes
ExpiresActive On
ExpiresDefault "access plus 1 hour"
Order Allow,Deny
Allow from all
</Directory>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>
There is a problem with your virtual host configuration, DocumentRoot must be a directory. If you want to serve a specific file, use DocumentIndex to specify the files to use in order of preference:
<VirtualHost *:80>
DocumentRoot /var/www/
DocumentIndex remote_replay.php index.php index.html index.htm
ServerName 192.168.1.80
</VirtualHost>

ZPanelcp , Domains activation not work

-Hello everyone , I just rent an a dedicated server (ubuntu 12.4) and i install apache + php, mySQL etc ...but using SSH to creat domains (virtual hosts) it is a litle bit laborer so I decided to install some GUI admin panel and also decided for ZPanelcp last version so everything installed fine without errors and I set first time two domains something like :
new.domain.com
new.otherdomain.com
these domains has been activated successfully without set zpanel DNS for those domains but next day I notice when I try to create again other domains in my ZPanel show as "live" but in my webbrowser can not see so in reality they were not activated , ok first time I Run Daemon again and restart BIND also restart apache I try a few changes in my server conf files but nothing I reboot my server also nothing my server use one static ip.
Here are my Zpanel, apache2 conf files.
Apache2 files:
folder files:
/etc/apache2/apache2.conf
# Here is last lines of this files related to my problem
# Include of directories ignores editors' and dpkg's backup files,
# see the comments above for details.
# Include generic snippets of statements
Include conf.d/
# Include the virtual host configurations:
Include sites-enabled/
ServerName cp.zpanel.com
Include /etc/zpanel/configs/apache/httpd.conf
/etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
/etc/apache2/sites-enabled/000-default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/zpanel/configs/apache/httpd.conf
# ZPanel Apache Include file for CentOS Linux
# Written by Bobby Allen, 15/05/2011
# Set the Zpanel Alias (used for development, sable will eventually use a VHOST)
Alias /zpanel /etc/zpanel/panel
# Setup the directory settings and PHP security flags for the Zpanel application directory.
<Directory /etc/zpanel/panel>
Options FollowSymLinks
DirectoryIndex index.php
<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_admin_value upload_tmp_dir /var/zpanel/temp
</IfModule>
</Directory>
# Disallow web access to directories that don't need it/that we don't want people looking in!
<Directory /etc/zpanel/panel/cnf>
Order Deny,Allow
Deny from All
</Directory>
# Set server tokens (security??)
ServerTokens Maj
# Now we include the generic VHOST configuration file that holds all the ZPanel user hosted vhost data
Include /etc/zpanel/configs/apache/httpd-vhosts.conf
/etc/zpanel/configs/apache/httpd-vhosts.conf
################################################################
# Apache VHOST configuration file
# Automatically generated by ZPanel 10.0.1
# Generated on: 09:15 13th Dec 2012 CET
################################################################
NameVirtualHost *:80
# Configuration for ZPanel control panel.
<VirtualHost *:80>
ServerAdmin zadmin#localhost
DocumentRoot "/etc/zpanel/panel/"
ServerName cp.zpanel.com
ServerAlias *.cp.zpanel.com
AddType application/x-httpd-php .php
<Directory "/etc/zpanel/panel/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Custom settings are loaded below this line (if any exist)
</VirtualHost>
################################################################
# ZPanel generated VHOST configurations below.....
################################################################
# DOMAIN: new.domain.com
<virtualhost *:80>
ServerName new.domain.com
ServerAlias new.domain.com www.new.domain.com
ServerAdmin zadmin#localhost
DocumentRoot "/var/zpanel/hostdata/zadmin/public_html/new_domain_com"
php_admin_value open_basedir "/var/zpanel/hostdata/zadmin/public_html/new_domain_com:/var/zpanel/temp/"
php_admin_value suhosin.executor.func.blacklist "passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_$
ErrorLog "/var/zpanel/logs/domains/zadmin/new.domain.com-error.log"
CustomLog "/var/zpanel/logs/domains/zadmin/new.domain.com-access.log" combined
CustomLog "/var/zpanel/logs/domains/zadmin/new.domain.com-bandwidth.log" common
<Directory />
Options FollowSymLinks Indexes
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
AddType application/x-httpd-php .php3 .php
ScriptAlias /cgi-bin/ "/_cgi-bin/"
<location /cgi-bin>
AddHandler cgi-script .cgi .pl
Options ExecCGI -Indexes
</location>
ErrorDocument 403 /_errorpages/403.html
ErrorDocument 500 /_errorpages/500.html
ErrorDocument 404 /_errorpages/404.html
ErrorDocument 510 /_errorpages/510.html
DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtm
# Custom Global Settings (if any exist)
# Custom VH settings (if any exist)
</virtualhost>
# END DOMAIN: new.domain.com
################################################################
##ETC other domains##
/etc/hosts
### Hetzner Online AG installimage
# nameserver config
# IPv4
127.0.0.1 localhost
6.8.81.52 Ubuntu-1210-quantal-64-minimal
#
# IPv6
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Check the permissions of httpd-vhosts.conf file. Maybe you don't have write permission.

Resources