Jump to content

Recommended Posts

Hi,

I am learning PHP, I just got apache server got up and running in my AMD64 RHEL4 machine. I am wondering why I should create my PHP file under /var/www/html/ ?. For that I have to be a super user (root).

I want to create pages in user account, that can be viewed by browser. Can any one guide me how to make browser to read my PHP file kept under my user account?.

Thanks

Summa

Link to comment
https://forums.phpfreaks.com/topic/71774-php-file-location/
Share on other sites

This is more a Linux question than that of php. You need to make a group which is allowed to create files within /var/www/html. As an example I will use the group www. As root, make /var/www/html be owned by root:www

 

$ groupadd www
$ chown -R root:www

 

Next you need to add your username to this same group. Again, as root issue...

 

$ usermod -G www yourusername

 

Note: If you allready are the member of suplimentary groups you will need to put them is a comma seperated string after the -G option as well. eg;

 

$ usermod -G wheel,cdrom,audio,www yourusername

 

Once this is all done you will be able to write to the /var/www/html directory when logged in to yourusername account.

Link to comment
https://forums.phpfreaks.com/topic/71774-php-file-location/#findComment-361688
Share on other sites

This is more a Linux question than that of php. You need to make a group which is allowed to create files within /var/www/html. As an example I will use the group www. As root, make /var/www/html be owned by root:www

 

$ groupadd www
$ chown -R root:www

 

Next you need to add your username to this same group. Again, as root issue...

 

$ usermod -G www yourusername

 

Note: If you allready are the member of suplimentary groups you will need to put them is a comma seperated string after the -G option as well. eg;

 

$ usermod -G wheel,cdrom,audio,www yourusername

 

# gpasswd -a username groupname

 

I always hated typing out all of the group names when I had to add a user to a group.

 

And to publish files in your home directory, you can create a directory ~/public_html, define USERDIR (-D USERDIR) in the startup options in your apache conf file (/etc/conf.d/httpd, maybe). Just make sure that directory is readable by the apache user.

Link to comment
https://forums.phpfreaks.com/topic/71774-php-file-location/#findComment-361814
Share on other sites

You could create a symbolic link in /var/www/html/ that points to the directory in which you will have your web files. In other words, create a symbolic link using the command "ln" that points to your directory /home/user_name/web. Please take note that the directory "web" is where you will keep all your web files. It is as simple as that.

Link to comment
https://forums.phpfreaks.com/topic/71774-php-file-location/#findComment-363506
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.