# LAMP problems

## while true

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

----------

## Veldrin

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.

----------

## szmytson

 *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 ?

----------

## while true

Hello guys!

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

First thing I did is this:

```
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

----------

## szmytson

 *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 :

```
# 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

----------

## Veldrin

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.

----------

## while true

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

----------

## aztech

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.phpLast edited by aztech on Sun Jul 25, 2010 8:53 pm; edited 1 time in total

----------

## bus_drivr

There is a mysql howto for Gentoo here http://www.gentoo.org/doc/en/mysql-howto.xml

----------

