LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   PHP with Apache (https://www.linuxquestions.org/questions/linux-general-1/php-with-apache-4175452056/)

TheQuicken 02-28-2013 05:04 AM

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?

fortran 02-28-2013 05:42 AM

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.

lrtward 02-28-2013 02:44 PM

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?

suicidaleggroll 02-28-2013 05:28 PM

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?

TheQuicken 03-01-2013 12:34 AM

Quote:

Originally Posted by lrtward (Post 4901873)
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 :)

lrtward 03-01-2013 08:25 AM

What are ownership and permission on the php files?
What is being logged in access_log and error_log?

yancek 03-01-2013 09:02 AM

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.

TheQuicken 03-02-2013 02:10 AM

Quote:

Originally Posted by yancek (Post 4902462)
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)

lrtward 03-02-2013 08:58 AM

Quote:

Originally Posted by TheQuicken (Post 4902966)
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

TheQuicken 03-02-2013 06:50 PM

Quote:

Originally Posted by lrtward (Post 4903112)
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...;) )

yancek 03-02-2013 07:59 PM

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.

TheQuicken 03-02-2013 09:59 PM

Quote:

Originally Posted by yancek (Post 4903420)
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.

TheQuicken 03-02-2013 10:19 PM

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

yancek 03-03-2013 01:10 PM

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?

TheQuicken 03-03-2013 10:08 PM

Quote:

Originally Posted by yancek (Post 4903816)
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.:)


All times are GMT -5. The time now is 06:46 AM.