OT - Linux and Apache and all my hair being pulled out

Post anything that doesn't belong in any other forum, including gaming and topics unrelated to motorsport. Site specific discussions should go in the site feedback forum.
Giblet
Giblet
5
Joined: 19 Mar 2007, 01:47
Location: Canada

OT - Linux and Apache and all my hair being pulled out

Post

Hey enlightened users of this great forum.

I am an old school DOS guy. Had a PC on my desk in the very early eighties, know windows upside down and backwards in a home and corporate environment.

I have been out of IT for a few years, and am going to school to take a 'webmaster' program, but the linux course isn't for a while.

One reason I am taking it is to possibly take over my fathers consulting business when he retires, as it is already established. I am in the process of setting up a web server, and just for ease of use, I have decided to install Ubuntu Workstation 9.1 so I have a GUI, as I don't need the double frustration of just the terminal window.

The install is no big deal, anyone with half a brain can get it running on just about any machine. I've also managed to install Apacahe2 from following some simple steps on line, and I have also managed to serve up the page on my lan, also child's play.

The part where it gets troublesome for me is when I go to simply edit the index.html file in the /var/www folder. This is where I am lost. I need to set permissions, need to have permissions in Apache to make a web site that is password protected. The HTML portion itself I have some experience in and I grasp it conceptually, and will have no trouble building this online database. Programming I get.

Any suggestions for good resources for someone like me who is used to being a whiz, and feels like a chump trying to simply save a file in Linux when I don't have permissions to a folder?

From what I can grasp every site I find seems to suggest a different way to go about this.

Going ahead and deleting a file was a simple 'sudo rm index.html" if I remember, but going into gedit and making a new html file and saving it seems to be a new kettle of fish.

Do I need to create a new group with permissions ot the var/www folder, and add my user name to it? A new user with permissions there? Log in as root?

I hate feeling dumb in an area when I am usually the keenest amongst everyone I know.
Before I do anything I ask myself “Would an idiot do that?” And if the answer is yes, I do not do that thing. - Dwight Schrute

Giblet
Giblet
5
Joined: 19 Mar 2007, 01:47
Location: Canada

Re: OT - Linux and Apache and all my hair being pulled out

Post

Apparently alt-f2 and running gksudo nautilis was what I needed to be able to go into permissions for the /var/www folder and add read and write, create and delete, etc.

I have a sinking feeling this is not the way to do things, and will bite me in the rear later.

I figure once I learn all I need to for this, I'll install a proper command line only server and start over with some knowledge in my pocket.
Before I do anything I ask myself “Would an idiot do that?” And if the answer is yes, I do not do that thing. - Dwight Schrute

Jon
Jon
-1
Joined: 27 Aug 2008, 15:22

Re: OT - Linux and Apache and all my hair being pulled out

Post

I'm not sure I'm understanding what exactly is the problem, but here I go.

From my experience with Win servers, you will need OS permissions in your folder, and then also in your application.

In Linux you probably need to create the file as root and edit it as such, and then then in Apache you will need to give the application user rights on the file.

Does that make sense?

User avatar
Hangaku
0
Joined: 20 Apr 2009, 16:38
Location: Manchester, UK

Re: OT - Linux and Apache and all my hair being pulled out

Post

One thing before I reel off a load of commands:

- Linux uses things called "manpages", which is documentation for all the commands. You prefix the command with the word "man". So for example, if you want to see the manpages for "groupadd", you'd type:
man groupadd
On to the website stuff:

- Create a new user group called "webs" or something similar:
sudo groupadd webs
- Add users to the new group:
sudo usermod -G -a webs <username>
- Set group permissions on the desired directory, so that group users have Read,Write and eXecutable access:
sudo chmod -R g+rwX /var/www/<whatever>

- Set the group ownership on the desired directory to "webs":
sudo chgrp -R webs /var/www/<whatever>
- Set the group sticky bit on the desired directory, so that all files or directories created under the desired directory are inherited from the "webs" group:
sudo chmod g+s /var/www/<whatever>
For more information on the commands an d the switches that I've used, refer to the manpages for each command, e.g.:

"man chmod"
"man chgrp"
etc.

Then, for making the website secure, you want to look into something called ".htaccess" files. This can get a little bit tricky if you've never played with it before, and there is a lot of reading up to get it right, but here is the de facto source of information for this:

http://httpd.apache.org/docs/1.3/howto/ ... .html#auth

Any queries, just shout back ;)
Yer.

User avatar
Hangaku
0
Joined: 20 Apr 2009, 16:38
Location: Manchester, UK

Re: OT - Linux and Apache and all my hair being pulled out

Post

Edited original post for readability.

Also, the "-R" switch in nearly all cases means "recursively" - some commands use "-r" for recursively, but it's best to read the manpages for reference.
Yer.

Miguel
Miguel
2
Joined: 17 Apr 2008, 11:36
Location: San Sebastian (Spain)

Re: OT - Linux and Apache and all my hair being pulled out

Post

I'd like to add to hangaku's great post that the command

Code: Select all

chown user:group file
Also works for changing the ownership of files. You need to have write permissions or be root (run with sudo in ubuntu) in order to change it. A directory is a valid target. If you want to change all the files inside a directory, target that directory and use the "-R" option.

You will see chmod used with numbers as well (i. e. chmod 755 this-new-cool-script). This is a number representation of the permissions. First number is "user", second is "group" and the third is for "others". Permission to execute counts as 1, write as 2 and read as 4. You add the numbers of the permissions you want to give, 755 is rwxr-xr-x

And the final permission trick: in order to read the contents of a directory you must have "execute" permission.
I am not amazed by F1 cars in Monaco. I want to see them driving in the A8 highway: Variable radius corners, negative banking, and extreme narrowings that Tilke has never dreamed off. Oh, yes, and "beautiful" weather tops it all.

"Prediction is very difficult, especially about the future." Niels Bohr