You are not logged in.

#1 2009-03-10 00:20:13

The Orange Peanut
Member
Registered: 2008-01-06
Posts: 152

Does php need apache to execute scripts when opened in a browser?

I installed php via pacman last night and expected it to 'just work.'  The php entry in the Arch wiki doesn't even use standard php as far as I can tell, or if it does it uses a web server that is bundled with php (zend or something.)  I looked in the lamp entry, and its instructions installs apache and mysql (obviously) as well as php.  I'd rather not have apache installed if I can avoid it because I'm not running a web server, I just want something that can execute php scripts on my local machine so I can develop my website on it instead of on my web server.  Is this possible or am I going to have to install and configure apache as per the lamp wiki?

Offline

#2 2009-03-10 00:59:12

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: Does php need apache to execute scripts when opened in a browser?

PHP does have a command line interface but for web development I have always used it in apache. Not sure how you would be able to serve up pages without a web server. If you don't want apache installed on your workstation put it in a vm or use one of the resource efficient webservers like lighttpd.

Offline

#3 2009-03-10 01:59:48

The Orange Peanut
Member
Registered: 2008-01-06
Posts: 152

Re: Does php need apache to execute scripts when opened in a browser?

If installing apache is necessary, that's fine.  I didn't even realize how small it was (5 or so megs).  I've run into a problem, though.  I followed the instructions on the lamp wiki for setting up apache.  I could go to http://localhost/ and it would take me to the default apache page, so I know it worked up to that far.  Since I don't want (or need) the outside world to be able to see these pages, I opted to skip the instructions that tell you how to do that and went straight to the advanced options.

One of them is that pages which you want to serve should go into /srv/http.  This requires root permissions to modify and create files and that is a hassle to a lowly web developer, so I changed the two configs from /srv/http to /home/Myusername/websites/personalphp which is where my index.php file lies.  I then restarted my httpd daemon.  Now when I go to http://localhost/ I get page not found error.  Likewise if I try http://localhost/index.php  What did I do wrong?

EDIT:  Nevermind, I typed my username with a capital letter instead of a lowercase.  It works now.  Is there any way to add multiple root directory's to apache so I can work on more than one website at a time?

Last edited by The Orange Peanut (2009-03-10 02:13:42)

Offline

#4 2009-03-10 02:17:26

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: Does php need apache to execute scripts when opened in a browser?

I'd suggest using the userdir module (google will help you here) then you can have your root directory where it "should" be, then have multiple dev sites under your home dir at ~/public_html/sitename/ and access them with http://localhost/~username/sitename/


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#5 2009-03-10 02:31:34

The Orange Peanut
Member
Registered: 2008-01-06
Posts: 152

Re: Does php need apache to execute scripts when opened in a browser?

Thanks for the help.  I seem to have everything working the way I wanted.

Offline

#6 2009-03-11 00:31:38

pierce.jason
Member
Registered: 2009-03-02
Posts: 19

Re: Does php need apache to execute scripts when opened in a browser?

I would like to add that lighttpd is a great choice for local development. It is easy as cake to configure, and uses barely a drop of system resources.

For per-project webservers, you can even create a bash script in your php project directory to spawn a lighttpd instance right from there, and all in less than 5 lines(including configuration).

Offline

Board footer

Powered by FluxBB