Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 07-05-2014, 08:07 PM   #1
Registered: Dec 2004
Distribution: Debian Wheezy
Posts: 441

Rep: Reputation: 30
Moving the sites-available/enabled folder to somewher else

Hello everyone, I just installed Apache 2.4.7 web server in Linux Mint. I intend to work on a few websites at the same time, and I don't want to have to log into root and copy the files I wrote to /var/www/*. I plan to develop websites in ~/Programs/Web. Every website will be developed in a subdirectory inside the Web directory, and each website will be virtually hosted. The virtual host files will be put into ~/Programs/Web/sites-available and ~/Programs/Web/sites-enabled. Moving those virtual host configuration files is proving to be pretty difficult. Here's what I've done so far.
inside /etc/apache2/apache2.conf we have
# Global configuration
ServerName ""

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:>);
# you will save yourself a lot of trouble.
# Do NOT add a slash at the end of the directory path.
#ServerRoot "/etc/apache2"

# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
Mutex file:${APACHE_LOCK_DIR} default

# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars

# Timeout: The number of seconds before receives and sends time out.
Timeout 300

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
KeepAlive On

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
KeepAliveTimeout 5

# These need to be set in /etc/apache2/envvars

# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., (on) or (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog ${APACHE_LOG_DIR}/error.log

# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
	Options FollowSymLinks
	AllowOverride None
	Require all denied

<Directory /usr/share>
	AllowOverride None
	Require all granted

<Directory /var/www/>
	Options Indexes FollowSymLinks
	AllowOverride all
	Require all granted

#<Directory /srv/>
#	Options Indexes FollowSymLinks
#	AllowOverride None
#	Require all granted

# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
AccessFileName .htaccess

# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
<FilesMatch "^\.ht">
	Require all denied

# The following directives define some format nicknames for use with
# a CustomLog directive.
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
# IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I put a link in /var/www called bob which point to /home/bob. Inside /home/bob a .htaccess contains the following.
<Directory Programs/Web>
	Options Indexes
	Include sites-enabled/*.conf
	Require all granted
Inside the /home/bob/Programs/Web/sites-enabled directory I have two .conf files: myexample1.conf and myexample2.conf. They both read fairly simularly:
<VirtualHost *:80>
        DocumentRoot ../MyExample1/htdocs/

        # Indexes + Directory Root.
        DirectoryIndex index.html
When apache is started and I type in the name of my webpage, it takes me to the server root, but doesn't display index.html. Can someone explain to me what the proper way to set this up would be? Or maybe I should go about this in an entirely different way. I'm totally new to apache, so any advice would be appreciated.
Old 07-07-2014, 01:48 AM   #2
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,454

Rep: Reputation: 901Reputation: 901Reputation: 901Reputation: 901Reputation: 901Reputation: 901Reputation: 901Reputation: 901
First off try specifying /the/full/path/ for DocumentRoot rather than the relative ../MyExample path.
Old 07-07-2014, 02:23 AM   #3
Senior Member
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
You are over-complicating things a bit.
I do something similar to your setup, but in an easier way:

I have a directory /private under which I put all configuration & data.
So for apache, I have /private/config/html/http_tuxit.conf for my configuration, and a directory /private/config/html/sites-enabled/ for my vhost-configs.
In apaches apache2.conf I include /private/config/html/http_tuxit.conf - that's all I need to change in Apache when installing or updating newer version. And there's no need for a .htaccess, all is written in vhost-config.
Then I put all DocumentRoots under /private/data/apache/www/
Of course you can use your home-dir instead of a separate "/private", only if someone else is to administer sites then you have to give access to your home directory. Maybe not an issue today but it's always good to plan ahead.

Also follow good advice from TenTenths. If you want flexibility I believe in apache 2.4 you can use variables, then maybe you can add a variable for the base directory and set it to "/var/www" - but I have only read a little about this, never tried it.
Old 07-13-2014, 01:21 AM   #4
Registered: Dec 2004
Distribution: Debian Wheezy
Posts: 441

Original Poster
Rep: Reputation: 30
Thank you for sharing your Apache2 configuration with me pingu although I have a difficult time understanding the full mehtod without seeing your .conf files. I figured out a really cool way to move those configuration files without using .htaccess files. Just add the folling line to your /etc/apache2.conf file.
IncludeOptional /home/*/.sites-enabled/*.conf
This will allow any user to create .sites-enabled folder in their home directory, and use it just like the default one.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
VMWare shared folder enabled but no folder under /mnt/hgfs davidmyde Linux - Newbie 2 04-25-2014 03:19 AM
[SOLVED] load balancing ssl enabled sites Linux - Newbie 4 03-12-2013 10:24 AM
[SOLVED] [Apache] Is this a correct sites-enabled entry? earthw0rmjim Linux - Server 2 09-15-2012 02:34 PM
Moving a folder, versus moving its contents (within the same partition) the dsc General 7 06-29-2012 04:46 AM
[SOLVED] [APPENDED]Real moving of a folder's content to another folder. MODYSAMA Linux - Newbie 10 02-07-2011 11:30 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration