LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-28-2013, 05:04 AM   #1
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Rep: Reputation: Disabled
PHP with Apache


I have no problem getting php to work under root, but when I copy the apache Dir to a users home Dir (so I can give them access to thier own web server) php won't work.
What do I need to do to enable php for other users?
 
Old 02-28-2013, 05:42 AM   #2
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
You mean, other users of LAN can't access web page on the server.
Open port 80 on firewall.
It is preventing user to access web on the server.
 
Old 02-28-2013, 02:44 PM   #3
lrtward
Member
 
Registered: Feb 2011
Distribution: CentOS, Ubuntu
Posts: 97

Rep: Reputation: 9
Are you sure it is php that does not work?
If you put a plain html file in the user's home directory, does that work?
 
Old 02-28-2013, 05:28 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Why are you copying the apache dir into the user's home dir? Why not just give the user write permissions on the original apache dir?
 
Old 03-01-2013, 12:34 AM   #5
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by lrtward View Post
Are you sure it is php that does not work?
If you put a plain html file in the user's home directory, does that work?
Yes, Plain html works fine. I have no problem having multiple users, all with their own apache in their home dir (/home/UserName/apache). All run off separate ports (lan/Wan) ... php only responds to root server /var/www/html/index.php (example).

Not overtly versed with php yet, is this something I'll need to config within php somewhere? If so what/where?

I like setting up apache this way to keep it as isolated from root as possible, also makes experimenting easy.

Thank you for your replies
 
Old 03-01-2013, 08:25 AM   #6
lrtward
Member
 
Registered: Feb 2011
Distribution: CentOS, Ubuntu
Posts: 97

Rep: Reputation: 9
What are ownership and permission on the php files?
What is being logged in access_log and error_log?
 
Old 03-01-2013, 09:02 AM   #7
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,504

Rep: Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490
Is the user_dir in /etc/php.ini set to public_html? If you created an apache directory in each users /home directory, you need to change this entry.
 
1 members found this post helpful.
Old 03-02-2013, 02:10 AM   #8
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
Is the user_dir in /etc/php.ini set to public_html? If you created an apache directory in each users /home directory, you need to change this entry.
No it is not, I tried changing the line from:

user_dir =
to
public_html =

Nothing, is this wrong? Is there more I should configure?

http://localhost/index.php:8080 results in URL not found
http://localhost:8080 results with normal plain html files showing up fine.

http://localhost --everything works as it should. (root)

Last edited by TheQuicken; 03-02-2013 at 02:37 AM.
 
Old 03-02-2013, 08:58 AM   #9
lrtward
Member
 
Registered: Feb 2011
Distribution: CentOS, Ubuntu
Posts: 97

Rep: Reputation: 9
Quote:
Originally Posted by TheQuicken View Post
No it is not, I tried changing the line from:

user_dir =
to
public_html =

Nothing, is this wrong? Is there more I should configure?
You should edit php.ini so that the line reads:
user_dir = apache
 
Old 03-02-2013, 06:50 PM   #10
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lrtward View Post
You should edit php.ini so that the line reads:
user_dir = apache
Tried this, nothing.

This is most likely a big part of the problem:
I have the included version of apache installed, but I removed the existing apr/apr-util and installed the newest versions so I could config/install apache-2.4.3 that I downloaded.
So this gives me an apache2 dir under path= /usr/local/apache2
I then copy this apache2 to my Users home dir and rename it 'apache' path= /home/username/apache
At which point I edit its httpd.conf file for that users dir. (ports/access etc...)

So...php works in the pre-configured pre-installed apache...but not for my 2.4.3. Php paths are obviously not configured correctly. I would really like to figure this out, once again I appreciate your suggestions. (maybe this extra info will clear things up a bit... )
 
Old 03-02-2013, 07:59 PM   #11
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,504

Rep: Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490
You changed it incorrectly, it should be the following in php.ini:

Code:
user_dir = "public_html"
Info on this entry from the php.ini file:

Quote:
; The directory under which PHP opens the script using /~username used only if nonempty.
http://www.php.net/manual/en/ini.core.php#ini.user-dir
There is the same line in the apache config file, httpd.conf and you need it there also, almost at the bottom of the file:

Quote:
<IfModule mod_userdir.c>
UserDir public_html
</IfModule>
This is the default setting for apache. Most Linux distros will have a public_html directory in the /home/user directory. If not you can create it. Which Linux distribution are you using? You would access files in that directory with the h t t p://localhost/~username/index.html. Replace the localhost with your ip or server name. You can then create other directories/sub-directories/files there. You should be able to change the User_Dir entry from public_html to some other directory in the user /home directory as long as you make all the changes in the configuration files. I've never seen the need to change it myself so can't verify that.

Last edited by yancek; 03-02-2013 at 08:02 PM.
 
Old 03-02-2013, 09:59 PM   #12
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
You should be able to change the User_Dir entry from public_html to some other directory in the user /home directory as long as you make all the changes in the configuration files.
...fun.

I'm using Centos 6.3, currently trying to implement the info you have offered, thank you

I'm curious, are you thinking I'm try to use the virtual hosts provided with the auto installed/yum install httpd apache? I don't want to use this version, /var/www/html/ /etc/httpd/conf/httpd.conf

I have manually downloaded and installed apache.2.4.3 and it's path is /usr/local/apache2 all config files I should need are in this dir. Of course I then copy the apache2 server to a users home dir and configure it from there.
I've been stuck using the other apache server because it's the only one that php will play with.

Would you agree or disagree with this approach? Should I scrap this and focus on virtuals?

Trying out different configs is relatively painless as I'm using VMs for development.

Last edited by TheQuicken; 03-02-2013 at 10:14 PM.
 
Old 03-02-2013, 10:19 PM   #13
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
List of public*

/usr/share/selinux/devel/include/services/publicfile.if
/usr/share/selinux/targeted/publicfile.pp.bz2
/usr/share/man/man8/publicfile_selinux.8.gz
/usr/local/apache2/manual/howto/public_html.html.ja.utf8
/usr/local/apache2/manual/howto/public_html.html.ko.euc-kr
/usr/local/apache2/manual/howto/public_html.html.fr
/usr/local/apache2/manual/howto/public_html.html.en
/usr/local/apache2/manual/howto/public_html.html
/usr/local/apache2/manual/howto/public_html.html.tr.utf8
/usr/src/httpd-2.4.3/docs/manual/howto/public_html.html.ja.utf8
/usr/src/httpd-2.4.3/docs/manual/howto/public_html.html.ko.euc-kr
/usr/src/httpd-2.4.3/docs/manual/howto/public_html.html.fr
/usr/src/httpd-2.4.3/docs/manual/howto/public_html.html.en
/usr/src/httpd-2.4.3/docs/manual/howto/public_html.html
/usr/src/httpd-2.4.3/docs/manual/howto/public_html.html.tr.utf8
/etc/selinux/targeted/modules/active/modules/publicfile.pp
/home/vmquik/apache/manual/howto/public_html.html.ja.utf8
/home/vmquik/apache/manual/howto/public_html.html.ko.euc-kr
/home/vmquik/apache/manual/howto/public_html.html.fr
/home/vmquik/apache/manual/howto/public_html.html.en
/home/vmquik/apache/manual/howto/public_html.html
/home/vmquik/apache/manual/howto/public_html.html.tr.utf8
/var/spool/postfix/public
 
Old 03-03-2013, 01:10 PM   #14
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,504

Rep: Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490Reputation: 2490
Sorry, the suggestion I posted above is only for virtual hosts. I have Apache configured on a localhost and have access to directories/files in the /home/user/public_html directory. I'm not using CentOS or the version of apache you are. I have a modules.d directory in the /etc/httpd directory and in that directory is a file named 67_mod_userdir.conf which has a Directory entry relating to public_html. You might look for a file with a similar name and try that. It's been so long since I've done this I really don't remember. You could also take a look at the Apache site below:

http://httpd.apache.org/docs/2.2/howto/public_html.html

Have you made the change in the php.ini file. If you can access other files in the user directory but not php files, that would seem to be the problem?
 
Old 03-03-2013, 10:08 PM   #15
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
Sorry, the suggestion I posted above is only for virtual hosts. I have Apache configured on a localhost and have access to directories/files in the /home/user/public_html directory. I'm not using CentOS or the version of apache you are. I have a modules.d directory in the /etc/httpd directory and in that directory is a file named 67_mod_userdir.conf which has a Directory entry relating to public_html. You might look for a file with a similar name and try that. It's been so long since I've done this I really don't remember. You could also take a look at the Apache site below:

http://httpd.apache.org/docs/2.2/howto/public_html.html

Have you made the change in the php.ini file. If you can access other files in the user directory but not php files, that would seem to be the problem?
Seems like we've been reading the same documentation lol, I agree the solution lies in the php.ini. Fun part is trying to configure it for the way I want to implement apache. There is plenty of documentation for virtual setup...just not much of anything for my preferred approach.

Once again, I appreciate your time and suggestions.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Connection issue involving mysql when run through apache php but not through cli php. sasheto86 Linux - Server 2 01-24-2013 09:43 AM
Open edit Php file problem (PhP apache installed) waerfwe Programming 3 06-30-2011 09:29 AM
php/shell script to install mysql,apache and php automatically stranger_6_7 Linux - General 2 08-11-2009 02:07 AM
Please help with Apache Web Server / Apache Tomcat / PHP / Java / PHP-Java Bridge jpmad4it Linux - Server 2 01-05-2009 06:07 AM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration