phantom21 Posted November 26, 2013 Share Posted November 26, 2013 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:<?phpphpinfo();?>phpit 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/ Share on other sites More sharing options...
requinix Posted November 26, 2013 Share Posted November 26, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460128 Share on other sites More sharing options...
phantom21 Posted November 26, 2013 Author Share Posted November 26, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460206 Share on other sites More sharing options...
AbraCadaver Posted November 26, 2013 Share Posted November 26, 2013 (edited) 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 November 26, 2013 by AbraCadaver Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460208 Share on other sites More sharing options...
phantom21 Posted November 26, 2013 Author Share Posted November 26, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460214 Share on other sites More sharing options...
AbraCadaver Posted November 26, 2013 Share Posted November 26, 2013 Hmmm... Not very helpful but that's why I use Ubuntu. Debian only better, in my opinion. Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460215 Share on other sites More sharing options...
phantom21 Posted November 26, 2013 Author Share Posted November 26, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460242 Share on other sites More sharing options...
Ch0cu3r Posted November 26, 2013 Share Posted November 26, 2013 (edited) 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 November 26, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460250 Share on other sites More sharing options...
phantom21 Posted November 26, 2013 Author Share Posted November 26, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460257 Share on other sites More sharing options...
jazzman1 Posted November 26, 2013 Share Posted November 26, 2013 It should be inside /usr/lib/apache2/modules/ Instead a find command try run a locate. locate libphp5.so Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460259 Share on other sites More sharing options...
Ch0cu3r Posted November 26, 2013 Share Posted November 26, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460260 Share on other sites More sharing options...
phantom21 Posted November 26, 2013 Author Share Posted November 26, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460262 Share on other sites More sharing options...
jazzman1 Posted November 26, 2013 Share Posted November 26, 2013 (edited) 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 November 26, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460263 Share on other sites More sharing options...
phantom21 Posted November 27, 2013 Author Share Posted November 27, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460269 Share on other sites More sharing options...
jazzman1 Posted November 27, 2013 Share Posted November 27, 2013 Then try, php -f /var/www/test.php You can also check for apache errors in the apache error log file. Debian / Ubuntu Linux Apache error log file location - /var/log/apache2/error.log Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460283 Share on other sites More sharing options...
Solution phantom21 Posted November 27, 2013 Author Solution Share Posted November 27, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460286 Share on other sites More sharing options...
jazzman1 Posted November 27, 2013 Share Posted November 27, 2013 Maybe you were trying to display the content of the file in your browser with URL like - http://var/www/test.php or something similar Quote Link to comment https://forums.phpfreaks.com/topic/284277-php-newbie-having-trouble-with-php5-on-debian-72/#findComment-1460287 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.