Jump to content

PHP newbie having trouble with php5 on debian 7.2


Go to solution Solved by phantom21,

Recommended Posts

I'm not new to Linux, but I am new to php. I'm trying to set up a lamp server. Using Debian 7.2, Apache2, Mysql, and PHP.

I want to install wordpress eventually.

Doing all this in a VM using virtualbox (4.2.10).

Now, have installed the OS. Using apt-get installed apache, mysql, and php.

Apache is installed. the test page displays.

Mysql I can log into the mysql cli.

The php test page does not display. The browser (firefox) says it can't find the file. This test uses the code as follows:
<?php
phpinfo();
?>php

it was placed in /var/www (the same place the test index.html file is).

Further, when I type php -a to invoke the interactive php shell, it seems to halfway work. It acts as if I was in a cli shell, except it doesn't display any kind of a prompt. Further, I can type stuff into this, but it does nothing except move to the next line (after pressing the enter key, as if it was text editor) or nothing. For example, type "echo 5+8;" produces nothing.

Looking up documentation on installing these components in debian, the docs say I should have a file libphp5.so in a modules diirectory somewhere. Using find I cannot fine a file libphp5.so nor a directory module or modules.

So, a little help here. Anyone have a clue why this is not happening?

Thanks,

Mark

The php test page does not display. The browser (firefox) says it can't find the file. This test uses the code as follows:

<?php

phpinfo();

?>php

 

it was placed in /var/www (the same place the test index.html file is).

Are you sure it's not something simple like having the wrong URL or the wrong filename? Even if PHP wasn't working, going to the right URL should get you something besides a 404.

 

Further, when I type php -a to invoke the interactive php shell, it seems to halfway work. It acts as if I was in a cli shell, except it doesn't display any kind of a prompt. Further, I can type stuff into this, but it does nothing except move to the next line (after pressing the enter key, as if it was text editor) or nothing. For example, type "echo 5+8;" produces nothing.

You don't have readline installed, which is fine.

 

Enter anything you want there, remembering to use <?php and ?> when you want in and out of PHP mode. Whatever you input should be like a valid .php file. When you're done hit ^D and PHP will execute whatever you entered.

Are you sure it's not something simple like having the wrong URL or the wrong filename? Even if PHP wasn't working, going to the right URL should get you something besides a 404.

 

You don't have readline installed, which is fine.

 

Enter anything you want there, remembering to use <?php and ?> when you want in and out of PHP mode. Whatever you input should be like a valid .php file. When you're done hit ^D and PHP will execute whatever you entered.

 

Yes.  I've found the installation of the packages didn't install the modules directory in /etc/apache2 and the file libphp5.so file wasn't available in that and wasn't loaded.  That may have had an effect on the cli.

 

When I get that sorted out I will try again.

 

Thanks

 

Mark

Probably need the glue for all of the pieces:

apt-get install php5-mysql libapache2-mod-php5

libapache2-mod-php5 - Apache PHP module

php5-mysql - MySQL extension for PHP (you'll need this when you try to use mysql in PHP :-) but try mysqli as that is what you should be using or PDO

Edited by AbraCadaver

Probably need the glue for all of the pieces:

apt-get install php5-mysql libapache2-mod-php5

libapache2-mod-php5 - Apache PHP module

php5-mysql - MySQL extension for PHP (you'll need this when you try to use mysql in PHP :-) but try mysqli as that is what you should be using or PDO

 

done that multiple times.  libphp5.so and the modules subdirectory refuse to be made/instlalled.

 

Mark

Probably need the glue for all of the pieces:

apt-get install php5-mysql libapache2-mod-php5

libapache2-mod-php5 - Apache PHP module

php5-mysql - MySQL extension for PHP (you'll need this when you try to use mysql in PHP :-) but try mysqli as that is what you should be using or PDO

tried that several times.  Even though it says it is installing, and it does do things like create mods-enabled and mods-available (directories underl /etc/apache2)and ppopulate those, it doesn't create or populate /etc/apache2/modules.

 

Mark

If you have install php and the apache php module via the repositories (apt-get intsall command) then it should already be enabled.

 

All you need to do is restart apache after installation.

sudo apachectl restart

If the php module is not enabled, run

sudo a2enmod php5 && sudo apachectl restart

To enable the php apache module.

 

Apache on Debian loads all (enabled) modules (and their configuration) into the mods-enabled directory.

 

When I started using Debain/Ubuntu with Apache this guide help me understand how Apache's config was setup.

Edited by Ch0cu3r

If you have install php and the apache php module via the repositories (apt-get intsall command) then it should already be enabled.

 

All you need to do is restart apache after installation.

sudo apachectl restart

If the php module is not enabled, run

sudo a2enmod php5 && sudo apachectl restart

To enable the php apache module.

 

Apache on Debian loads all (enabled) modules (and their configuration) into the mods-enabled directory.

 

When I started using Debain/Ubuntu with Apache this guide help me understand how Apache's config was setup.

OK, let me restate.

 

I've attempted to reinstall all the php5 required modules, apt-get tells me I have already install php5-common, php5, php-cli, libapache2-mod-php5 and also run the a2enmod php5 command.  It says the module is already enabled.

 

when I use find as root (find / libphp5.so and find / modules)

the result says it cannot find the file or directory.

 

There is no directory /etc/apache2/modules

 

So, something is broken in the packages, the installation process, or somewhere else.

 

php, according to everything I have used and tried is supposedly installed.  Yet, an important directory where the modules should reside is not existing and the important file libphp5.so is also not in evidence.

 

So, once again, how can I fix this/

 

Thanks,

 

Mark

 

There is no directory /etc/apache2/modules

On debian all Apache modules are installed in /usr/lib/apache2/modules/

 

this is where you should find libphp5.so (it comes with the libapache2-mod-php5 package).

 

The configuration for this module is located in /etc/apache2/mods-available.

When you enable the module via a2enmod*  its configuration is linked in /etc/apache2/mods-enabled. When Apache is (re)started it loads all modules from this directory.

 

* a2enmod is called during package installation

 

It should be inside /usr/lib/apache2/modules/ :)

 

Instead a find command try run a locate.

locate libphp5.so

OK.  Found that (finally) and see the php5-load file properly refers to it.

 

So, how come I cannot see, in a browser (firefox) the test.php code?

 

Is there some additional configuration, perhaps in .htaccess or httpd.conf I need to do?

 

Mark

 

So, how come I cannot see, in a browser (firefox) the test.php code?

 

Try to run the script into a terminal.

 

For example:

php-cgi /var/www/test.php

Most likely the browser (apache or someone else) doesn't have permission to read the content in /var/www.

Edited by jazzman1

Try to run the script into a terminal.

 

For example:

php-cgi /var/www/test.php

Most likely the browser (apache or someone else) doesn't have permission to read the content in /var/www.

When I try the command php-cgi I get a return saying the command cannot be found

 

Mark

  • Solution

Then try,

php -f /var/www/test.php

You can also check for apache errors in the apache error log file.

now THAT did something.  It gave me a lot of info on php.

 

OK!  I now tried something else, and the file worked in the browser

 

and anotehr test!!!! Thanks to all.

 

Mark

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.