2nd Attempt Ubuntu Multiple Local Sites Apache2

Note, my user name is always bryan, because he gave me his old machine, with a password on it, so I just keep everything the same, for convenience.

Step 1:
Terminal
sudo chown bryan /var/www

Step 2: having given myself rights with that above chown command
I should be able to create folders withing /var/www
e.g. /var/www/proj1

and then invoke the 1st pg of the application by typing into the browser

localhost/proj1/report.html

I shall test this, and place the exercises from Head First PHP MySQL into a folder /var/www/proj1 and see if the exercise works

The only question that remains in my mind is whether the exercise pages will work unchanges, honoring /var/www/proj1 as the root, or whether I need to issue some other command to MAKE proj1 the default directory, or whether I have to hard code paths into all the exercise pages, which, if I do, would kind of defeat the purpose of developing a project in a folder, and then transparently moving it to some other location.

What follows is the raw text from the IRC channel where I asked my questions. I sorted through it to come up with the above, step-by-step procedure to achieve my goals.

+++ the steps WORK AND here is my email feedback to the person that gave me the valuable guidance:

You saved me HOURS of grief, and made it possible for me to now make rapid progress with my HEAD FIRST book. And Yes, I want to pay $60 for the paperback, because I want to be able to take it in the bathroom or on the subway. I want to really let all this PHP MySQL stuff sink in, and become second nature, for the simple reason that I am sick and tired of years of bondage to Micr0$oft and products like Access (or worse VISUAL FOXPRO which they finally dropped as a supported product). I figure that php mysql apache is the best choice for me, because I can kind of understand whats going on, and there is tons of documentation to make it work, but forum and IRC support (like YOUR excellent patient help).

You are CORRECT, THAT YOU did tell me what I need to know, but you did not realize that as a beginner, I cannot recognize the right answer UNTIL certain concepts sink in. Once I did the CHOWN trick you showed me, then I could navigate with the GUI, to /var/www and create a folder, proj1. Then I could navigate to my Desktop to a folder where I put two of the Head First exercises, but with the word TEST inserted in each field, so I would KNOW that it was these executing, and that I was not somehow executing the same original pages in /var/www . Now, I could NOT get Desktop/testwww/report.html to run and then correctly post with report.php and see the added record in the MySQL database with phpmyadmin.

BUT, as soon as it dawned upon me the simple steps you were saying, I copied to cloned files to /var/www/proj1 went to my folder and entered localhost/report.html, actually SAW the cloned version come up with TEST prefixed to each field, I entered data prefixed by TEST so I would see it in the mysql table,… pressed submit, and BINGO, when I did localhost/phpmyadmin and signed in, there was the new record in the sql table.

SO, you see, for a beginner, the Head First book leaves out a VERY IMPORTANT CONCEPT, about creating folders for projects in /var/www and doing the CHOWN trick once, up front, to allow access.

THANKS! And, as you will notice from my blog, when I asked the same question in IRC last week, someone thought that I wanted to do that
http://www.debian-administration.org/articles/412 complex business (which was CORRECT, if I wanted to access separate projects from some remote client, BUT unnecessary for my simple desktop purposes).

And here is the RAW irc chat to illustrate what a beginner may have to do to sort out the proper answers from a technically savvy person trying to help.
++++++++++++++++++++++++++++++

I am trying to set up several websites on my desktop ubuntu under Apache 2, and I have a detailed tutorial, but it says I need my IP address, but

sudo ipconfig gives me an internal, and

whatismyip.com gives me an external, any clues as to which is required, thanks

[04:08] WilliamBuell: what IP address? where do you want to reach them from?

(the answer, as it turns out, which I did not make clear to the IRC channel, is that I only want to make this stuff work from my DESKTOP, not from some remote client on the internet, which might require some ip address)

[04:08] thanks I am following this excellent tutorial on apache2 multiple sites

http://www.debian-administration.org/articles/412

[04:09] I have Ubuntu desktop with LAMP installed, but can only get php pages to work in /var/www

[04:09] I want to be able to have several projects i.e /home/proj1

[04:09] WilliamBuell: that’s where they should go

[04:09] why not put them in /var/www?

(this turns out to be an EXCELLENT QUESTION!)

[04:10] the tutorial mentions IP address but does not indicate whether it is EXTERNAL from whatismyip.com or local from

sudo ifconfig

[04:10] BECAUSE I would need a different name for each html and php page

[04:10] WilliamBuell: where are you trying to access them from? you shouldn’t need an ip address at all most likely

[04:11] suppose I am following several tutorials, with several pages with same name, they cannot BOTH be in /var/www

[04:11] why not /var/www/proj1, /var/www/proj2?

[04:11] and i dont know how to access some search path that would support /var/www/proj1

[04:12] or does apache2 lamp automatically honor any folder within www

[04:12] yes, automatically http://localhost/folder

(above is the KEY CONCEPT that I needed)

[04:12] and, if so (i am total beginner) ….

aha…. localhost/folder seems to make sense to me

[04:13] next question in TERMINAL does it matter HOW i create those folders, i mean do i have to be sudo or root

[04:13] do permissions matter?

[04:13] what would the proper command be to create the folder in /var/www would it be mkdir /home/www/www.example.com
[04:14] with sudo mkdir /home/www/www.example.com

[04:14] except it would be sudo mkdir /var/www/www.example.com

[04:14] if i follow along with this one tutorial

[04:15] but that tutorial is talking about MULTIPLENAMEHOST

[04:15] WilliamBuell: you can cheat and do sudo chown USER /var/www

( the above is the OTHER KEY CONCEPT that I require.. and if it works, then I can navigate in a GUI file folder system and create project folders at will, without fussing with sudo permissions)

[04:15] it sounds like you are saying if I simply create a folder in /var/www/proj1 that it will work from localhost/proj1

[04:15] WilliamBuell: only on a desktop though
[04:16] WilliamBuell: correct

[04:16] i am a 60 year old total beginner, so i dont need hints like “you can cheat” I am truly lost

[04:17] so i should say from TERMINAL sudo chown bryan /var/www but… HOW DO I MAKE THE FOLDER PROJ1
[04:17] i mean the chown command is changing rights or something

[04:17] chown changes the ownership of the file
[04:17] nothing else

[04:17] WilliamBuell: oh, one you own the folder, you can go into /var/www and make whatever you want 🙂

[04:18] in other words, from terminal, what is the command to correctly creat /var/www/proj1 with all the proper user rights for apache2 to work

[04:18] BUT, whenever i go into /var/www it doesnt let me do stuff i dont think unless i am root admin

[04:18] WilliamBuell: the support here is not too great… might want to try a support channel

[04:18] WilliamBuell: yeah, that’s why I suggested owning the folder

[04:18] yeah, but you guys know this like the back of your hand

[04:19] once you do that, you can mkdir in /var/www all you wnat

[04:19] and you just cant give a beginner the command to create the folder

[04:19] WilliamBuell: if we did we would have told you straight away

[04:19] so, you say , create the folder, and then use chown to change ownership?
[04:19] and then everything will be honkey dory ok

[04:19] WilliamBuell: no, chown /var/www, then you can create all the folders you want without sudo

[04:21] ok so sudo chown bryan /var/www gives me the rights, then i should be able to navigate with the gui and create proj1

[04:21] WilliamBuell: yep 🙂

[04:21] aha… now that is making sense to this beginner brain
[04:22] and i WONT need to mess with that other tutorial
[04:22] since i only want stuff to work locally…

[04:22] WilliamBuell: right no apache configs 🙂

[04:23] BUT, second question,…. if i make a bunch of php html pages in /var/www/proj1 do I need explicit paths to the other pages, or will they default to that local directory

[04:23] and is there some command i need to issue to make /var/www/proj1 a local directory for that session

[04:23] WilliamBuell: not sure I’m following

[04:23] WilliamBuell: not sure you’re sure what you’re asking
[04:24] http://localhost basically loads what’s in /var/www

[04:24] ok… you are telling me if i do all this then from browser .. i type localhost/proj1/report.html and it comes up

[04:24] yep

[04:24] but INSIDE report.html it is going to POST to report.php

[04:24] if you have /var/www/proj1/report.html

[04:24] yeah, default is current folder

[04:24] but, it will know enough to look in var/www/proj1 without
[04:25] well, it looks in http://localhost/proj1/report.php
[04:25] or rather posts to

[04:25] aha, and the very act of launching the project as localhost/proj1 is sufficient to make that the local directory for the entier project session

[04:25] which should correspond to /var/www/proj1/report.php
[04:25] if so, that makes sense

[04:25] WilliamBuell: not sure you quite get URL vs local path
[04:25] it’s not for the session

[04:25] in other words, i dont have to HARD CODE specific addresses in each html and php…

[04:26] that’s just how it it

[04:26] WilliamBuell: that you have to do
[04:26] i want to develop something in /var/www/proj1 test it , but have it work if i move it somewhere else

[04:26] WilliamBuell: why not just have a .php file?
[04:26] why have anything .html?

[04:26] well, i dont know enough to understand your hint

[04:26] WilliamBuell: a PHP file can have HTML and PHP in it

[04:27] because, the tutorial book i am following starts with report.html posting with report.php… but now i see what you are saying

[04:27] WilliamBuell: what book?

[04:27] but, php or html, is not germain to my path question at hand

[04:27] it is a great book called HEAD FIRST php mysql, which leads you step by step, including cookie sessions

[04:28] i have in my blog links to the book

[04:28] i am buying the book for $60 tomorrow, and i already downloaded a zip file of all the source code exercises from the publisher

[04:29] WilliamBuell: do you have any programming background and are you interested in mysql>??

[04:29] i started programming in 1979, through the 1980s, with stuff like cobol, rpg, then basic, then pick

[04:29] WilliamBuell: BTW, you know you can get it as an ebook for $36

[04:29] i am not a moron

[04:30] i just have some simple questions which in reality have very simple answers, but getting straight answers from techie types is like pulling teeth
[04:31] WilliamBuell: do you like head first series?

Advertisements

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: