SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-12-19 01:12:53

bubbadave
New Member
Registered: 2011-12-19
Posts: 6

[SOLVED] Apache and PHP troubles

I just installed the Statler build of Crunchbang released around November 25th, 2011. I want to set up a small web server with the ability to serve PHP pages.

The post-installation script seemed to be just what I needed to set up Apache with PHP support. However, after installing Crunchbang and placing some PHP pages in my /var/www directory, I found that they would not display in a web browser when accessing the site from another computer (or even on the host computer). What am I doing wrong? The Apache web server works fine when serving HTML pages but PHP pages aren't displaying. Is there something I have to do to enable PHP? I'm not a TOTAL noob, but I am new to Apache and PHP on the server end. Any help would be greatly appreciated. Thanks.

Last edited by bubbadave (2011-12-28 21:52:26)

Offline

Help fund CrunchBang, donate to the project!

#2 2011-12-19 03:27:30

dkeg
#! Die Hard
From: Mid-Atlantic Grill
Registered: 2011-12-05
Posts: 716

Re: [SOLVED] Apache and PHP troubles

put your project in htdocs instead of www.  That should solve your problem.  then it would be

localhost/username/projectname

not sure if you said yes to symlink option during setup.  I did, hence the above.  if not probably would be just

localhost/projectname

hope that helps.


grill it | the rocky path may just be the best path

Offline

#3 2011-12-19 05:48:04

Ozitraveller
#! CrunchBanger
From: Far from the madding crowd!
Registered: 2011-04-26
Posts: 244

Re: [SOLVED] Apache and PHP troubles

I installed xampp from  http://www.apachefriends.org/en/xampp-linux.html#372

Last edited by Ozitraveller (2011-12-19 05:48:44)

Offline

#4 2011-12-19 12:37:51

dkeg
#! Die Hard
From: Mid-Atlantic Grill
Registered: 2011-12-05
Posts: 716

Re: [SOLVED] Apache and PHP troubles

Ozitraveller wrote:

that would only be necessary if you skipped over the option to install the lampp stack during the install process.  bubbadave stated that he did select to install at that time. 

the problem is not if he has it but that he is not placing the projects in the correct folder.   The projects need to be in the htdocs folder.

good luck


grill it | the rocky path may just be the best path

Offline

#5 2011-12-19 15:56:07

vlahonick
Banned
From: Universe
Registered: 2011-12-03
Posts: 347

Re: [SOLVED] Apache and PHP troubles

sorry that i wont post a solution to your problem, i will
just post a super easy and functional alternative...


1. uninstall xampp and all php mysql stuff u have there so u dont mess 'em

2. type in terminal the following commad as is:

sudo apt-get install mysql-server mysql-client apache2 apache2-doc php5 php5-mysql libapache2-mod-php5 phpmyadmin

3. if u want to activate the rewrite module (must in my opinion) do the following (replace geany with ur own text editor if u use a different one):

~$ sudo a2enmod rewrite
~$ sudo geany /etc/apache2/sites-available/default

There find the following

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

and change it to

Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

(so None becames all and then)

~$ sudo /etc/init.d/apache2 restart


4. type localhost in ur browser and "It works!".
    u can also work with dbs from http://localhost/phpmyadmin/
    now u do all work from /var/www (to access it super easy i added a shortcut on my menu
    executing the following command: gksu thunar /var/www)
    i also for even easier access a custom keyboard shortcut (Super + L) at my rc.xml using
    the following code:

    <keybind key="W-l">
      <action name="Execute">
        <command>gksu thunar /var/www</command>
      </action>
    </keybind>


Usefull tip: do not try to mess with the permissions on /var/www, when
                  u put something there just right click and change permissions.
                  from my personal experience if u try to change persmissons for
                  the whole directory u gonna prolly f**k up as i did a lot of times tongue

Last edited by vlahonick (2011-12-19 16:00:01)


"I do not fear computers. I fear the lack of them."
Isaac Asimov

Offline

#6 2011-12-20 17:29:43

bubbadave
New Member
Registered: 2011-12-19
Posts: 6

Re: [SOLVED] Apache and PHP troubles

I moved everything to the HTDOCS directory and it had no effect. Anyone trying to access the web site publicly still reaches only HTML files located in the /VAR/WWW directory. This is ok, as long as I am only interested in serving HTML files, but I want to use PHP pages on my public web site.

I need to have a web site that works for anyone publicly - not just on my own computer.

I will try vlahonick's solution, if I can. I will probably start by completely reinstalling Crunchbang and running the post-installation script again, just to be sure I didn't screw something up along the way.

Offline

#7 2011-12-20 18:27:06

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: [SOLVED] Apache and PHP troubles

i set up my php/apache just yesterday, and all i did was run 'cb-welcome', skip through the menu's until you get to the 'install some other stuff'-menu, look for it asking for the LAMP-stack, agree to that, it will ask you if it should make a symlink in /home/user/htdocs, say yes. open a browser, go to http://localhost/user and you will see your htdocs-dir. place your projects in this dir and be done with it.

Offline

#8 2011-12-20 20:38:21

bubbadave
New Member
Registered: 2011-12-19
Posts: 6

Re: [SOLVED] Apache and PHP troubles

I ran a fresh install of Crunchbang, followed the post-installation script, asked it to make a symlink in /home/user/htdocs. Placed an HTML file in the htdocs directory and gave it a try.

DID NOT WORK. No matter what I do, the /var/www directory is the ONLY directory which will display pages when someone accesses the web site. It's like the htdocs directory doesn't even exist. Why is it that the symlink thing didn't work? Is there a way I can set the htdocs manually as my default directory for web (and PHP) pages?  I would try placing the PHP pages in the var/www directory, since it's the only one which is working as a web directory, but PHP pages don't work there either. I wish I knew more UNIX so I wouldn't feel like such an idiot - all I'm trying to do is use an old computer for a web server, to display both HTML and PHP pages. Oh, and I need the mySQL database.

Offline

#9 2011-12-20 20:48:31

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: [SOLVED] Apache and PHP troubles

when you open your browser and go to http://localhost/YOURUSERNAMEHERE ... what do you get?

funny, when i try right now i get a 404 error. i suppose apache is not running... ok fixed. type this:

sudo apache2ctl start

then try again. for me that makes it work.

Last edited by rhowaldt (2011-12-20 20:48:49)

Offline

#10 2011-12-21 01:19:44

vlahonick
Banned
From: Universe
Registered: 2011-12-03
Posts: 347

Re: [SOLVED] Apache and PHP troubles

@bubbadave

to be honest i am bit confuse from ur last comment...not rly sure what u want to do exactly.
i suppose u want to create a website. a directory (/var/www in the case if u followed my mini guide)
is nothing if apache, php, mysql and all the stuff are not installed and configured propertely.
if ur configuration is right the /var/www would be able to handle php and html files.
now i cant understand why u want the htdocs folder to work...there is no point on that...
why because all the online management systems (plesk, cpanel) have as the main folder
the httpdocs??? remember that when ur site will be active no one will be able to see the
directory name that contains the files...
now i suppose for my example (i am assuming the most simple case) that u dont have a domain
name yet and u have not configure ur nameservers from ur domain panel so u can access
your /var/www from localhost and your IP only. u will observer that the /var/www is not showing
up somewhere...
i mean that u type in browser localhost or your IP and the /var/www contents appear...
so u see /var/www is not showing up somewhere because for apache lets say is the
folder 0 smile

so if u want to access/see your /var/www from another machine (try it from ur own browser is the same)
just time your IP and u will see the contents of www (ofc the contents must have the right permissions).

now if u CANT manage to display ur contents of /var/www by typing ur IP in the browser
but only by typing localhost, let me know...this is a common problem for ISPs blocking port 80.
(i know how to resolve that but is not relevant).

my final suggestion is to make a clean install of cb and follow my guide and set up lamp
by using /var/www. no need to use other directory or mess up with the permissions.


if the problem is something else plz be as much specific as u can be. i hope this post will not confuse u... :S

Last edited by vlahonick (2011-12-21 01:23:00)


"I do not fear computers. I fear the lack of them."
Isaac Asimov

Offline

#11 2011-12-21 03:53:53

bubbadave
New Member
Registered: 2011-12-19
Posts: 6

Re: [SOLVED] Apache and PHP troubles

My user name is "dave" so here it what happens:

http://localhost/dave/
I get the htdocs directory.

http://localhost/
I get the /var/www directory. (the directory I'd like to use)

PHP pages will not display no matter how I access the site. I would like for people to be able to access my site without having to type "dave" after the main URL, but I really don't care where I have to stick the files, as long as someone can access the site from the public IP. 

I guess my main problem is getting a web browser to see the PHP files on my computer, and hopefully get it attached to the mySQL database. The PHP pages aren't displaying, no matter where I place them. No matter what I do.

I only mentioned the htdocs directory because it is the directory the Apache servertakes you to, unless you add a user name to the end of the URL (which I don't really want to do).

Offline

#12 2011-12-21 04:17:02

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,847
Website

Re: [SOLVED] Apache and PHP troubles

@bubbadave, don't give up - it is possible!
My apache/php installation displays php pages fine from the local server in the directory of my choice. I haven't tried external access though, and don't really want outsiders poking into my main machine...

Anyway, our fellow-crunchbanger safetycopy put up a nice guide on github last year about getting apache and friends working. The link is now dead, but I got a local copy at the time, and have put the html file here: http://dl.dropbox.com/u/10808732/safetycopy-webdev.html You might find some useful advice there. smile


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#13 2011-12-21 04:37:51

nathwill
#! CrunchBanger
From: Portland, OR USA
Registered: 2010-11-05
Posts: 215
Website

Re: [SOLVED] Apache and PHP troubles

ok, so the thing is, XAMPP is intended to be used as a development environment. it's great, if you're just using it to do development before deploying elsewhere. it should *not* be used for production servers. If you want to setup a web server that will be publicly accessible, i *highly* recommend you follow one of thousands of how-to articles accessible through the magic of google.

a tutorial i would recommend would be:

http://library.linode.com/lamp-guides/debian-6-squeeze

alternatively, the tutorials on debian-administration.org tend to be very good.


NOTICE: alloc: /dev/null: filesystem full

Offline

#14 2011-12-21 11:06:58

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: [SOLVED] Apache and PHP troubles

i think nathwill is onto something. i also thought this whole question was meant for php-development, offline-viewing of php-documents which will later be uploaded to a webspace or something. which is what i do. but it seems the OP wants to do something different.

Offline

#15 2011-12-21 12:14:20

vlahonick
Banned
From: Universe
Registered: 2011-12-03
Posts: 347

Re: [SOLVED] Apache and PHP troubles

i think is important to explain exactly what means "php is not displayed". i assume that u
can access a php file via browser (ofc the file has to have the right permissions too)
but the code is not parsed write??? so you have /localhost/something.php but
even u wrote 100% correct php code the something.php is white. is that correct ???

if it is something is rly fu***d up in your installation/configuration. plz check in synaptic
if php5 is rly installed and if it is try some reinstallation.

the simplest way is backup your files remove apache and everything u got and
make a clean install of them.

i dont know, so this will be a question for all of the ppl here that might know,
is possible that apache is configured (maybe by accident) for another directory???
so your php configured directory is something else??? (as far as i understand
from all the posts here i read this is not the case, just checking every possibility).


"I do not fear computers. I fear the lack of them."
Isaac Asimov

Offline

#16 2011-12-21 18:34:31

bubbadave
New Member
Registered: 2011-12-19
Posts: 6

Re: [SOLVED] Apache and PHP troubles

I am going to take johnraff's suggestion and follow that guide that is online.

I'm not interested in making just a development web site. I want this to be an actual working site, open to the public. A real web site.  As vlahonick said, the PHP pages are just displaying as blank white pages. I will double check all of the settings and permissions and try again.

Thanks to everybody for all of your help! I won't clog up the forum with any more dumb questions. I think you have all given me enough information for me to figure out what I am doing wrong. Thank you.

Offline

#17 2011-12-21 21:16:10

vlahonick
Banned
From: Universe
Registered: 2011-12-03
Posts: 347

Re: [SOLVED] Apache and PHP troubles

a blank white .php (in most cases) is displayed twhen the permissions are wrong.
go to your /var/www directory as root (sudo thunar /var/www) and make the dir accessible
for ALL kind of users. i am saying this because one of the first times that i had to configure
my apache i had give full permissions to root but i was opening opening as simple user
so i was getting the same blank page. so make sure all kind of users and groups are
have full access to the directory (or open browser as root).

plz after you solve your problem post the solution for future users that might encounter the
same problem.


"I do not fear computers. I fear the lack of them."
Isaac Asimov

Offline

#18 2011-12-21 21:18:55

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: [SOLVED] Apache and PHP troubles

bubbadave wrote:

I won't clog up the forum with any more dumb questions.

please feel free to keep posting any (dumb) questions you have. there are enough people happy to answer them. i think the main issue in this case was simply that it wasn't clear from the beginning what your exact problem was. so you can consider that for the next question you post, but please please please do not hesitate when asking your question. it is good to think 'i will search a bit more before asking, this must be a really simple thing', but in the end, if you can't get stuff to work, just ask. that's what the forum is for. (aside from talk about coffee and cigarettes of course smile)

Offline

#19 2011-12-23 20:08:43

bubbadave
New Member
Registered: 2011-12-19
Posts: 6

Re: [SOLVED] Apache and PHP troubles

PROBLEM SOLVED (I think)!!

It's always something small you may have missed, isn't it? After trying everything else, I finally got the web site working, complete with PHP pages, and everything is in the /var/www directory, where I wanted it. I had checked the permissions on every one of the PHP and HTML pages, but couldn't get anything to display other than the default "IT WORKS!" page.

It was vlahonick's last suggestion that finally got me wondering, so I checked and double checked the permissions, and finally realized that I had not set the permissions for the /var/www directory itself! After I did that, the PHP pages magically started displaying. I feel like such an idiot.

So, for anyone else having problems getting PHP pages to work after installing Crunchbang and running the post-installation script, just remember to set the permissions on the DIRECTORY where the PHP pages are stored. Changing permissions on each individual page within the directory is not enough (duh).

Many thanks to all of you who have had the patience to help me through this. I really appreciate it. And if I run into trouble getting my mySQL database working, I may be back. smile

Offline

#20 2011-12-23 22:52:47

vlahonick
Banned
From: Universe
Registered: 2011-12-03
Posts: 347

Re: [SOLVED] Apache and PHP troubles

glad to help smile i hope u dont encouter any problem with mysql but even u do u know
u can always find help here!

plz mark this post as solved if u do not experience the problem any longer.
(just write [SOLVED] in front of the post's title)


"I do not fear computers. I fear the lack of them."
Isaac Asimov

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo