Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
LAMP problems
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
while true
Guru
Guru


Joined: 07 Apr 2010
Posts: 532
Location: Ljubljana, Slovenia

PostPosted: Thu Jul 08, 2010 12:19 pm    Post subject: LAMP problems Reply with quote

Hello

I am having trouble with LAMP

I have laptop, and I emerged apache, mysql ahd php.

To write the code I use netbeans.


The first problem is, that the php file is not running.
As I try to open it, I get option to save it, or to open it with html editor...
The php file works fine as I upload it on server (that I pay for, I do not have my server).

and second problem is, that apache is not working (I guess),
since http://localhost/ is not giving me "It works!" page, but I get error page.

I have several more questions about LAMP, but let us kick of with those two.

(I am not a native English speaker, so I might miss-spell-something, kheh, sorry)

Thank you
_________________
Kind regards, Goran Mitic

alive
while true
kick ass
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Thu Jul 08, 2010 1:27 pm    Post subject: Reply with quote

IIRC php need to activated inside the apache config.

add -D PHP5 to APACHE2_OPTS inside /etc/conf.d/apache2.
you might also want -D USERDIR to be able to put your php files inside your users web directory ~/public_html, accessible through http://localhost/~username/ by a webbrowser.

second, did you start apache2? (/etc/init.d/apache2 start; rc-update add apache2 default)

cheers
V.
Back to top
View user's profile Send private message
szmytson
n00b
n00b


Joined: 29 Apr 2009
Posts: 20
Location: UK

PostPosted: Thu Jul 08, 2010 4:00 pm    Post subject: Re: LAMP problems Reply with quote

while true wrote:

The first problem is, that the php file is not running.
As I try to open it, I get option to save it, or to open it with html editor...

How do you "run" the php files ?
Do you double click them from your file browser ?
You have to have a http server running and configured first, then you'll be able to access your php scripts via http (e.g. http://localhost/myscript.php).

while true wrote:

and second problem is, that apache is not working (I guess),
since http://localhost/ is not giving me "It works!" page, but I get error page.

Have you started your apache ?
What's the error message ?
Back to top
View user's profile Send private message
while true
Guru
Guru


Joined: 07 Apr 2010
Posts: 532
Location: Ljubljana, Slovenia

PostPosted: Fri Jul 09, 2010 11:41 am    Post subject: Reply with quote

Hello guys!

(I must say, I LOVE support on this forum, it is realy superb!!!)

First thing I did is this:
Code:
C6820s ~ # /etc/init.d/apache2 start
 * Starting apache2 ...
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName                                            [ ok ]
C6820s ~ # rc-update add apache2 default
 * apache2 added to runlevel default
C6820s ~ #


and now http://localhost/ does give me "It works!"

moving on,
I have APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5" so -D PHP5 is already there.

I am not sure how to do the "you might also want -D USERDIR to be able to put your php files inside your users web directory ~/public_html, accessible through http://localhost/~username/ by a webbrowser. " thing...

If I understand correctly, I have to assign a folder for apache, and put my php files inside it in order for those files to run? Should I do something like this:
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5 -D /home/grom/NetBeansProjects/"


I "run" my php files (e.g. index.php) by double-clicking on it in file browser.


Now, double-clicking php file is still not bringing up the web site, I have option to save it or open it with some html editor.

Also I tried this:
http://localhost/home/grom/NetBeansProjects/PhpProject1/index.php
which gives me this:
Not Found
The requested URL /home/grom/NetBeansProjects/PhpProject1/index.php was not found on this server.
Apache Server at localhost Port 80

---------------------

So, if I am assuming correctly, I need to add a directory for apache in order to run my php files?
Did I guessed correctly like this:
APACHE2_OPTS="........ -D /home/grom/NetBeansProjects/"
or should I do something else?

Thank you
_________________
Kind regards, Goran Mitic

alive
while true
kick ass
Back to top
View user's profile Send private message
szmytson
n00b
n00b


Joined: 29 Apr 2009
Posts: 20
Location: UK

PostPosted: Fri Jul 09, 2010 12:48 pm    Post subject: Reply with quote

while true wrote:

I "run" my php files (e.g. index.php) by double-clicking on it in file browser.

It won't work unless you want to run shell scripts written in php.


From /etc/apache2/vhosts.d/default_vhost.include :
Code:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# If you change this to something that isn't under /var/www then suexec
# will no longer work.
DocumentRoot "/var/www/localhost/htdocs"


Copy your php scripts to this directory and go to http://localhost/myscript.php
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Fri Jul 09, 2010 1:56 pm    Post subject: Reply with quote

There are 2 ways to run php on your local webserver.
szmytson also should you the second option, which is great for a more permanent installation, but in general it requires root (or at least apache) access

In your case, as you developing php, i would suggest to use userdir.

* add -D USERDIR to you apache config, the same way that php has been added (-D PHP5)

* create a folder called public_html inside your home directory (eg. mkdir /home/grom/public_html)

* restart you apache to get the new config active.

* access your personal webdir through http://localhost/~grom/

now you should be able to put any php/html/whatever pages inside that directory, and test them directly. the advantage of this variant that only user access is required.

I hope that made it a bit clearer

cheers
V.
Back to top
View user's profile Send private message
while true
Guru
Guru


Joined: 07 Apr 2010
Posts: 532
Location: Ljubljana, Slovenia

PostPosted: Mon Jul 12, 2010 10:32 am    Post subject: Reply with quote

Ola,

aha, ok, there are two ways to access php files on appache?
One way is putting php files in /var/www/localhost/htdocs (which needs root)
The other is in my home directory ~/public_html (user level)
Both ways require the php files to be opened with web browser,
not by doubleclicking on php files (szmytson: It won't work unless you want to run shell scripts written in php.)

ok, first question, Can I do both ways?
I did Veldrin version already, for user level
(U!-HA-HA!! IT WORKS!!! U!-HA-HA)
but I am quite eager to have both ways, kheh,
so can I safely do szmytson version as well?


Now I can run php files on my laptop, thank you!

Veldrin: I hope that made it a bit clearer
http://www.youtube.com/watch?v=NkwJ-g0iJ6w


Now I have LA'P out of LAMP, so last set of questions, kheh;
How can I check if I have correctly mySQL installed on gentoo,
do I have to start it (as I did with apache),
how to "integrate" mySQL into LA'P, as plain as I can explain it, kheh...

Thank you
_________________
Kind regards, Goran Mitic

alive
while true
kick ass
Back to top
View user's profile Send private message
aztech
Tux's lil' helper
Tux's lil' helper


Joined: 29 Jul 2002
Posts: 130
Location: Stenungsund, Sweden

PostPosted: Sat Jul 24, 2010 11:22 pm    Post subject: Reply with quote

You can do both ways.

The only difference is the paths and owners of the files

http://local.server/myscript.php = /var/www/localhost/htdocs/myscript.php
- owned by "root"

http://local.server/~user/myscript.php = /home/user/public_html/myscript.php
- owned by "user"

If you have mysql installed and a rootpassword for it set, you can simply install dev-db/phpmyadmin and start playing.
... dont forget to edit it's config.inc.php


Last edited by aztech on Sun Jul 25, 2010 8:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
bus_drivr
n00b
n00b


Joined: 20 Feb 2003
Posts: 48
Location: Florida

PostPosted: Sun Jul 25, 2010 7:25 pm    Post subject: Reply with quote

There is a mysql howto for Gentoo here http://www.gentoo.org/doc/en/mysql-howto.xml
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum