Ubuntu 9.10/Apache. How do I move localhost root from var/www/?

'm new to Linux and have just set up a dualboot system on a new pc, winxp and ubuntu 9.10…

I need to use some of my win specific software such as dreamweaver to create php and html pages so set up a third partition as ntfs where I could share sites.

Because I really wanted to spend as much time in Ubuntu as possible (and try out other linux based code editors, the Gimp too etc)I set up apache and php in Ubuntu rather than windows by doing “Synaptic > Edit > Mark Packages by task. Select LAMP server and clicking OK.”

Opened firefox, entered http://localhost and got the “it works!” page… I eventually found that the default installation’s server root is in var/www/

Now, I want to set/change the default to be my third partition so I can save pages there from windows and Ubuntu and serve them.

In the ntfs partition I have created a folder called htdocs, from which I’d like apache and localhost to serve pages. I then right clicked it, selected “Make link”, and then copied the resulting “Link to htdocs” and dropped it into var/www/

I placed a file, test.php containing <?php phpinfo();?> in htdocs, and tried http://localhost/test.php but just get a 404 not found.

Obviously my limited understanding of symlinks is faulty, I’d expected that files in htdocs would now be treated as though they were in var/www/, but after scratching my head and googling etc I am no nearer working out how to do this, or what I am doing wrong.

Any help would be very gratefully received!

colin,

Look in Apache’s httpd.conf file for DocumentRoot “{whatever}” and change that to the shared directory. It need NOT be in htdocs but you may want to use that for the location of phpmyadmin’s directory. Personally, I have all my local domains setup in httpd-vhosts.conf (and listed in the hosts file - do a whereis to find where they’re located) and am very pleased with the results.

Regards,

DK

Thanks DK, unfortunately although /etc/apache2/httpd.conf exists it is empty…?

But I’ve also found /etc/apache2/sites-available/default which does contain these lines:

<VirtualHost *:80>
	ServerAdmin webmaster@localhost

	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/>
		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 /var/log/apache2/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

I’m quite happy to keep on muddling along, (have I found the right config file?) but again some advice as to which lines to change and the significance of the

Alias /doc/ "/usr/share/doc/"

section would be appreciated.

Please excuse me, (I’m a beginner at Linux) I can understand that I can I can use the apache config file(s) to point at a new path, but I’m not sure what the path to my shared ntfs partition actually is. Sounds stupid I know, but although I know that to Ubuntu all files, folders, hardware devices etc are just nodes on the directory tree, starting from / which is the absolute root, I don’t see how extra drives fit into that scheme and how
they are addressed.

Looking at my computer in the media File Browser I see my ntfs partition named as 221 GB Filesystem, but if I right click that and select properties I see name: 12830E7515E3BC8E and location: /media

So, is the path I need to put in the apache config for me to get apache to start in the htdocs folder thus: /media/12830E7515E3BC8E/htdocs ?

Thanks!

colin,

I’m rather stuck on my XP test server (although I “require” a Linux box from a host) because my unix (Linux is a subset) knowledge is spotty at best (albeit, not quite non-existant).

There was a post 2-3 weeks ago (please use the search and look for “+httpd.conf +Linux” w/o the quotes) in which a member was able to find the httpd.conf equivalent on his Linux system - what you found looks more like the equivalent of httpd-vhosts.conf).

I’m ‘pleased’ to be able to report that your ntfs drive is apparently mounted as /media - that’s how other devices are connected (mounted) in Linux. With that, you should be able to link into your htdocs with /media/htdocs (but don’t complain if you have to use that ridiculous alphanumeric string - at least you can connect to it!).

It feels like the blind leading the blind here - let me know if you want me to move your thread to the server board where more hosting sysadmins poke their heads in.

Regards,

DK

[ot]“Her” Linux system : )

“Linux” is so different from distro to distro regarding Apache and where files are placed and named, and if you haven’t run across the post, Rich Bowen likes to call anyone with a Debian variant “Debian encumbered” lawlz. Ubuntu is a Debian variant.[/ot]

Just posting this to answer an unanswered question from Colin. I was having a similar problem as his in the last few days until I found this posting, which guided me in exploring some options (I couldn’t find any other “newer” threads that talks about this for Debian/Ubuntu). I’m on Debian Linux which is very similar to Ubuntu.

After some mucking around, I found out that there are at least 2 ways to work around it, for the Debian flavour and possibly Ubuntu too:

  1. In the binary install (non-threaded version), the default config file is apache2.conf which contains an “include” calling statement to httpd.conf. So, one can add a line to the empty httpd.conf file with
DocumentRoot  {new directory}

This should work as DK had mentioned.

  1. Since the installed default DocumentRoot is /var/www (non-threaded version), one can also create a symbolic link to a new user-defined directory:
    [HIGHLIGHT=“Shell command”]ln -s {target} {new directory}
 This link is placed inside the original DocumentRoot directory.

That's all.  For my purpose, I prefer the second version which was tested and worked quite well.

~Kin

Referring back to Method #2, I had neglected to clarify further (to avoid confusion between target and directory parameters) with an example, i.e.

[HIGHLIGHT=“Shell command”] ln -s {new user-defined dir} /var/www/{linkname}


Here, {linkname} is thus placed in the DocumentRoot.  Say, to access a file called MyIndex.php in the new user-defined directory, use the web URL:

[HIGHLIGHT="Shell command"] http://localhost/{linkname}/MyIndex.php

Cheers,
Kin

Yeah it was from October 09… and doesn’t have Ubuntu/Debian in the title.

Stomme poes, thanks very much for the link!
Otherwise I wouldn’t have found it.
~Kin