Localhost URL without username

Hi, I’m beginning with openSUSE and basically even with Linux and I installed LAMP according to the instructions here https://en.opensuse.org/SDB:Linux_Apache_MySQL_PHP . Now I would like to know, how can I use the URL address without mine username, just like http://localhost. I don’t like something as http://localhost/~username/someFile.php. Is any options to change it?

Regards Draffix

What you do not want is not even switched on by default IIRC.

Your web pages should go into /srv/www/htdocs and there is also a /srv/www/cgi-bin if you need that. IIRC that is already in the deafult Apache configuration, thus not much to change there.

My advice is to use a seperate user for maintaining your web server (not any “normal” end-user). Make that user member of the group www and see that all inside /srv/www is owned by that user and the group www. When you then see that all there is readable for the group www, your http deamon (which runs under group www) will be able to read and thus to serve them.

I think it is, at least in the openSUSE packages, but it’s been a while since I installed apache2 from scratch.

My advice is to use a seperate user for maintaining your web server (not any “normal” end-user). Make that user member of the group www and see that all inside /srv/www is owned by that user and the group www. When you then see that all there is readable for the group www, your http deamon (which runs under group www) will be able to read and thus to serve them.

You could change the DocumentRoot in apache’s config to point to a user’s home directory or subfolder.
But I would suggest you create a Virtualhost for this instead of changing the default supplied httpd.conf.
You can do this with YaST btw (but editing the config files directly works as well), see here:
openSUSE 12.3: Chapter 20. The Apache HTTP Server

Thanks you both, I didn’t know that there is any other “web container”.

Regards Draffix

What do you mean with that, /srv/www/httdocs?
Yes, that’s the central location for web pages in the default configuration.

And every user can set up his/her own webpage in his/her $HOME/public_html as you already knew.

The central location (/srv/www/httdocs) can be changed in apache’s config with the DocumentRoot directive as I mentioned before. And it can be set differently for each virtual host, that’s why it’s recommended to set up a virtual host if you want to change it and leave the default configuration files alone.
The link I posted should explain how to do this, but in short virtual hosts are defined in files in /etc/httpd/vhosts.d/ which are included automatically by the default configuration, so you don’t need to change those files that got shipped in the RPMs.

Yes I thought /srv/www/httdocs/ and the only one who use this PC is me so I don’t need set up anything. It’s only for my purpose, develop and testing, nothing more. I think that use the file as I mentioned before is the simpliest solution for me.

OK. I thought you want to have it in your home directory because of the permissions…(in /srv/www/httdocs you normally only can change things as root)
In that case you could of course also just change the permissions of /srv/www/httpdocs/ to rwxrwxrwx so you can edit everything in there.

Why do you want to change all the rights for /srv/www/htdocs? Everybody can write and execute all fhe files there, if you would have changed to rwxrwxrwx. That isn’t the sense of chmod.

Because of this:

Changing the permissions is the easiest way to achieve this, IMHO.

And you’re wrong with:

Everybody can write and **execute **all fhe files there, if you would have changed to rwxrwxrwx.

‘x’ on a directory doesn’t mean you can execute files in there, it just means that you can enter the directory and list it.
(And html and php files are not executable on their own anyway, but that’s a different story… :wink: )