LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   PHP on Linux (https://www.linuxquestions.org/questions/linux-software-2/php-on-linux-793234/)

jan1024188 03-04-2010 02:17 PM

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 (http://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

rweaver 03-04-2010 02:18 PM

What do your error and access logs say?

alunduil 03-04-2010 02:24 PM

Why don't you create a staging web that has a docroot of your project development directory?

Regards,

Alunduil

chrism01 03-04-2010 09:19 PM

You can enable UserDir directive to allow Apache to read pages from /home/you/public_html. See Apache docs http://httpd.apache.org/docs/2.2/howto/public_html.html

resetreset 03-05-2010 02:14 AM

Quote:

Originally Posted by jan1024188 (Post 3885933)

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

There's only Kompozer and Quanta, the latter is somewhat sophisticated, but both are still not the same as Dreamweaver - they make the designing more *work*, whereas with DW, it's more PLAY. Like I said, in another message, this is a reason I *have* to keep Dingblows around :(

resetreset 03-05-2010 02:15 AM

Quote:

Originally Posted by alunduil (Post 3885943)
Why don't you create a staging web that has a docroot of your project development directory?

Regards,

Alunduil

Sorry - can you explain this message a little? What's a "staging web"?

mattseanbachman 03-05-2010 02:37 AM

Quote:

Originally Posted by jan1024188 (Post 3885933)
Please help, how do I make it run PHP script from everywhere on my system.

Well if you're just wanting to run a php script, you can do this, but it may not be feasible for scripts designed for websites and such:

Code:

toor@toor-d ~/ $ php ./myscript.php
If your script could be easily hacked with to let you pass in command line arguments in place of other variables, that might be something to possibly consider. Then the finished script could be re-taylored to be put back into /var/www/ or whereever for apache to deal with.

alunduil 03-05-2010 11:24 AM

A staging web is a webserver that runs on your local machine that allows you to quickly view the websites you're developing. I use a combination of rewriterule and aliasmatch to get a nice listing of current projects when I browse to localhost and am able to then see what my projects are doing.

On a side note, the best PHP editor I know of right now is vim (I hope this doesn't start a fire).

Regards,

Alunduil

rweaver 03-05-2010 02:59 PM

Quote:

Originally Posted by alunduil (Post 3887157)
On a side note, the best PHP editor I know of right now is vim (I hope this doesn't start a fire).

*there is a faint fphtpoof sound as a flame thrower ignites*

Just kidding, vim is my preferred editor for most languages. That being said emacs and eclipse are fine development environments as well. Whatever you're comfortable with is great.

jan1024188 03-05-2010 03:51 PM

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?

frieza 03-05-2010 04:14 PM

you should probably create it as a virtual host

create a (pick_a_name.conf) in /etc/apache2/sites_available with the following
Code:

<VirtualHost 127.0.0.1:80>
DocumentRoot "path/to/your/test_scripts"
ServerName same_name_as_above
<Directory "path/to/your/test_scripts">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

then add a line in your /etc/hosts
Code:

127.0.0.1 same_name_as_above
put the default site back to your main document root
then create a symlink from /etc/apache2/sites-available/same_name_as_above.conf to /etc/apache2/sites-enabled/same_name_as_above.conf
Code:

ln -s /etc/apache2/sites-available/same_name_as_above.conf /etc/apache2/sites-enabled/same_name_as_above.conf
and re-start your apache server and it should work

jan1024188 03-06-2010 05:49 AM

Quote:

Originally Posted by frieza (Post 3887509)
you should probably create it as a virtual host

create a (pick_a_name.conf) in /etc/apache2/sites_available with the following
Code:

<VirtualHost 127.0.0.1:80>
DocumentRoot "path/to/your/test_scripts"
ServerName same_name_as_above
<Directory "path/to/your/test_scripts">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

then add a line in your /etc/hosts
Code:

127.0.0.1 same_name_as_above
put the default site back to your main document root
then create a symlink from /etc/apache2/sites-available/same_name_as_above.conf to /etc/apache2/sites-enabled/same_name_as_above.conf
Code:

ln -s /etc/apache2/sites-available/same_name_as_above.conf /etc/apache2/sites-enabled/same_name_as_above.conf
and re-start your apache server and it should work

Ok, I did it till the last part as etc/httpd does not contain either sites-available either sites-enabled.

Now when I try to access http://jan.com I get 403 error again:
Quote:

Forbidden

You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.14 (Fedora) Server at jan.com Port 80

alunduil 03-06-2010 10:51 AM

Usually, a forbidden is either a permissions problem or Directory statement with the wrong options. What are the permissions on the files in your vhost's docroot?

Regards,

Alunduil

frieza 03-06-2010 03:32 PM

some versions of apache might have a vhosts.conf others might just have the vhosts defined in the apache2.conf or (more likely) the httpd.conf file

another option is to use webmin http://www.webmin.com/ to create the vhost

Quote:

Usually, a forbidden is either a permissions problem or Directory statement with the wrong options. What are the permissions on the files in your vhost's docroot?
this is true, folders and files should be at least READABLE by the webhost (eg chmod 644) or 555 for directories
any folder you want uploading to should be writable

jstephens84 03-07-2010 12:01 PM

Just to chime in with my 2cents, I would go the route of the virtual host. Normally I create a group called webmaster and add my account to the Root folder for the site. I give the webserver's user account and the webmaster group rw on the folder.

As for a development I normally use EclipsePHP for the project management, But normally get frustrated by it and go back to vim. I am just more efficient with vim. But you might want to look into Bluefish.

Also as for your error that is usually a permissions problem. meaning that the webserver's user account does not have at least read access to the directory.


All times are GMT -5. The time now is 02:24 PM.