PHP on Linux

Hello,

I am a linux user (fedora 12), and I would like to start with PHP, JS and MySQL development.

So I’ve installed apache (httpd), php, mysql, phpmyadmin and eclipse with PHP plugin.
I’ve managed to configure it to work, but one thing bothers me.

The only way I can get my test.php to run is by manually placing it inside var/www/html which you are able to manipulate with only with root permissions.
Which means the development in such case would be pain in the ass. I can’t manage to get my php run in firefox from my workspace.

I also tried trough Eclipse’s run in browser (127.0.0.1:8000/test/index.php), but all I get is blank (php not executing).

Please help, how do I make it run PHP script from everywhere on my system.

Also I miss Dreamveawer, is there any good alternative for linux?

Thanks,

Jan

Try these suggestions:

Open terminal and type:

su -

Enter root password

Now to chmod that www dir OR own by a user use these:
1st try this,

root@yyy2-desktop:~# chown [B]username[/B] /var/www/html

Change username in above command.

If that does not work, mean still forbid error.
2nd option:

root@yyy2-desktop:~# chmod 777 -R /var/www/html

This one i am pretty sure will work.

Good luck.

Glad to hear you solved it. :slight_smile:

I did all this:

[root@localhost ~]# chown jan1024188 -R /home/jan1024188/public_html/
[root@localhost ~]# chmod 777 -R /home/jan1024188/public_html/
[root@localhost ~]# chown apache -R /home/jan1024188/public_html/
[root@localhost ~]# chown apache:apache -R /home/jan1024188/public_html/

I have index.html specified as directory index, I have set proper permissions in httpd.conf, I really can’t find the issue.

EDIT:
Here’s what says in Apache manual about forbidden:

In the case where file system permission are at fault, remember that not only must the directory and files in question be readable, but also all parent directories must be at least searchable (i.e., chmod +x /directory/path) by the web server in order for the content to be accessible.

So I tried:

[root@localhost ~]# chown apache -R /home/jan1024188/
chown: cannot access /home/jan1024188/.gvfs': Permission denied [root@localhost ~]# chown apache -R /home/ chown: cannot access /home/jan1024188/.gvfs’: Permission denied
[root@localhost ~]# chmod 777 -R /home/jan1024188/
chmod: cannot access /home/jan1024188/.gvfs': Permission denied [root@localhost ~]# chmod 777 -R /home/ chmod: cannot access /home/jan1024188/.gvfs’: Permission denied
[root@localhost ~]#

My guess is this is the issue!

So I did:

[root@localhost ~]# chmod +x /home/
[root@localhost ~]# chmod +x /home/jan1024188/

AND NOW IT WORKS. Thanks a TON you guys for help :slight_smile: Love you :slight_smile:

it is not PHP on linux question but more likely Apache config question.
you can setup any directory as a DocumentRoot for your site in httpd.conf

Alternatively, you could store the PHP in question in /var/www/html and give your user account write permissions to that folder.

I’d recommend using virtual hosts so you can have
/home/[user]/webprojects/site1/
/home/[user]/webprojects/site2/
http://site1.local
http://site2.local

Google it, you will find lots of info

ok, I went to etc/httpd/conf/httpd.conf and I changed DocumentRoot to my dir where I keep my php stuff.

But now when I run localhost in browser I get Forbidden error. Any ideas?

Check if the webserver’s user has permission to access that directory.

I have, do I have to chmod my DocumentRoot? Also how do I do it?

as any other folder
using chmod utility

what command (and parameters)?

I did chmod +x +r but it didn’t help. Any ideas why I get 403?

You want to set your dir to say x755 or something so you can write and execute files.
And no, there’s not really an “alternative” to Dreamweaver on Linux, there are other apps similar and you can actually run Dreamweaver through Wine or one of those.
Why are you looking at doing PHP development and thinking of using Dreamweaver? Dreamweaver is not good when it comes to real coding…

Make sure that you’ve defined a <Directory> directive for that folder and given permission.

http://httpd.apache.org/docs/1.3/mod/core.html#directory
http://httpd.apache.org/docs/2.0/mod/core.html#directory
http://httpd.apache.org/docs/2.2/mod/core.html#directory

Order deny,allow
Allow from all

Nono, I use Eclipse SDK with PHP addon for doing PHP, I just want dreamweaver for HTML, CSS and JS as I’m used to it.

Here is what I have in config:

DocumentRoot “/home/jan1024188/Desktop/WORKSPACE”
<Directory “/home/jan1024188/Desktop/WORKSPACE”>

Order allow,deny
Allow from all

Still is 403 :frowning:

Make sure to restart Apache after changing config.

Yes, I’ve done it million of times already!

Check Apache’s logs to see if they say anything worthwhile.

Checklist:

  1. <Directory> directive
  2. Appropriate user & permission modes
  3. You are accessing a file, and not a directory listing
  4. You are editing the right configuration file

Yeah, here it is:

[Fri Mar 05 21:02:10 2010] [error] [client 127.0.0.1] (13)Permission denied: access to /test denied