Change Apache2 root folder drive

6,772

Enclose your DocumentRoot in quotes

DocumentRoot "/media/omk/New Volume2/Server"

Same goes for the directory directive.

<Directory "/media/omk/New Volume2/Server/">

To change the Volume name you can just remount the drive.

sudo umount /media/omk/New\ Volume2 note: a slash will work to escape the space

sudo mkdir /media/omk/volume2

sudo mount /dev/sdXX /media/omk/volume2 replace XX with the drive letter&number

Share:
6,772

Related videos on Youtube

Omkar Khair
Author by

Omkar Khair

Technology Enthusiast. Exploring Cloud, IOT and Distributed/Decentralized tech.

Updated on September 18, 2022

Comments

  • Omkar Khair
    Omkar Khair over 1 year

    I'm trying to change the directory of my default Apache site to a folder in another drive.

    The problem arises with the fact the Ubuntu has named all my additional mounted drives as New Volume, New Volume1, New Volume2, etc.

    The space in the drive name causes issues in the /etc/apache2/sites-available/default which looks like this.

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    
    DocumentRoot /media/omk/New Volume2/Server
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /media/omk/New Volume2/Server/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
    
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        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
    

    On apache2 restart, I get the following error

    Syntax error on line 4 of /etc/apache2/sites-enabled/000-default:
    

    DocumentRoot takes one argument, Root directory of the document tree Action 'configtest' failed. The Apache error log may have more information. ...fail!

    This is caused due to the space in the path, which Apache assumes as 2 different arguments separated by a space.

    I need to either make it look like a single argument retaining the path

    OR

    Change the volume name (which again I'm not able to figure out how)

    Any help appreciated! Thanks.