I have been a programmer for many years and have recently retired. I have written a book I am about to publish, but will not publish until I have my online store within my website set up. I have been doing business applications using 4GL's, and have not done web development. I have researched several programs and have decided that PHP with Apache and MySQL is the best way to go for me. I have installed Apache 2.2.17 and PHP5 on Ubuntu Linux ver. 10.10, and the Linux performance is very stable and reliable. Apache passes the basic test, and seems to be working fine. However, for about two weeks I have been working intensely trying to configure PHP to work, and have been unable to have any success at all, which is extremely rare for me. I have done many searches on the internet trying to find information that would help me. Nothing I've tried has had success, and this is from experts who have put PHP configuration information on the internet, mostly on the Ubuntu forums website. For all I know, the solution could be a simple trick. I have tried downloading PHP from the official site and was unable to get that to work. I reinstalled Linux thinking that might help, and then used the Synaptic Package Manager to install PHP5 that comes with Ubuntu Linux. Same result; it did not work. For now I am stuck, and vitally need to move forward. Please help me with this urgent matter if you are really good at PHP configuration (i.e. getting PHP to work after installation). Thanks.

Don G

    Thread moved to Install forum. Also, welcome to PHPBuilder!

    As far as installing/configuring PHP, I don't know if I would call myself an "expert" since all I've ever done is follow the manual. Having said that, I do have a high success rate with that method.

    How are you trying to install PHP? I personally like to install from source since that gives me the greatest flexibility in fine-tuning the installed components exactly how I want them as well as ensuring I have the latest versions (whereas using a package manager you'd be left at the mercy of the package maintainer(s) and how often (or not) they choose to update the package).

    Having said that, I would never recommend installing something like PHP and MySQL from source to those who don't know the fundamentals about *nix servers and Google'ing problems to find solutions.

    Where are you at right now? Have you cleaned up from previous failed installations (e.g. removed failed packages, "make uninstall" in source directories where you tried to compile manually, etc. etc.)? Also, which method are you trying to install PHP (e.g. from source or from a package)? Note that saying you "tried downloading PHP from the official site" doesn't really say much, since the "official site" has numerous different types of downloads available.

      bradgrafelman,

      If you have had success in getting PHP to work, that is the most important factor to me, so let's see what your knowledge can do. I am probably overlooking something that is important to do to make PHP work.
      To begin with, I have two hard drives in my PC with a dual boot system when I installed Ubuntu Linux. The original drive has Windows XP on it, and the extra drive has the Linux installation on it, and is 120 Gb. The dual boot system works fine as well as the two different operating systems. Since I want to use Linux a lot more of the time than Windows, I strongly prefer being able to get PHP to work on Linux. I have installed Apache, PHP, & MySQL on Windows XP, and am unable to get PHP to work there as well.
      I installed PHP on my original Linux installation by downloading php-5.3.5.tar.bz2 (don't remember which website I got it from), then unzipping, and then installing. Apache was installed prior to that, and at first I did not know how to test Apache to see if it was working. I couldn't help but notice that PHP did not work when I embedded it into the HTML as follows:

      <!DOCTYPE html>

      <html><head>

      <?php print "Hello Web!"; ?>

      </head>

      <body>

      <br>

      </body></html>

      The browser window was blank. I got no error messages or any information to give me a hint as to the cause of the problem. However, when I ran an HTML file with no PHP instructions, it worked fine. For example:

      <!DOCTYPE html>

      <html><head>

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Listing 3.2 A PHP script including HTML</title>

      <style type="text/css">

      h1 {text-align: center; font-size: 28pt; color: blue;}

      p {text-align: left; font-size: 20pt; width: 60%; text-justify: newspaper; color: cyan;}

      </style>

      </head>

      <body>

      <h1>Listing 3.2</h1>

      <p>Paragraph Test</p>

      </body></html>

      and displays the h1 header text and the paragraph text with the appropriate colors.

      When I saw it wasn't working, I went and bought a book named 'Sams Teach Yourself PHP, MySQL, and Apache' by Julie C. Meloni. and was published in July, 2009 which was the most recent edition. I followed the instructions in that book for configuring PHP, and that did not work. I researched the internet for sites that gave PHP configuration information, and tried a few of those ideas, and they did not work either. In the book, there was a CD that had the Apache, MySQL, & PHP install files, so I uninstalled the programs and re-installed them from the CD. I had the same result after adding the PHP configuration instructions in the book. In the book, and at most every website that I found, the primary file that required additions or changes was the php.ini file. And I discovered that for the different Ubuntu Linux installations, that the php.ini was placed in different folder locations. So between the different Linux installations, there were significant differences.

      I began thinking that this was too unreal since I saw no indication on the internet that people were having the problems I was having to get it to work. So I decided to reinstall Linux, which I did. On the original Linux install, I did the manual partitioning, and partitioned the Swap, root, and boot drives. On the installation I have now, I let the install program set up all of the folders. It seemed to run a bit more efficiently. In my research on the internet, someone recommended that one should install the Apache, MySQL, & PHP from the software that came with the Ubuntu Linux install files because they are more stable, and work without the problems one can have from the downloaded versions.
      After the new Linux installation, I installed the the Apache and PHP programs via the Synaptic Package Manager, and they installed successfully. At this point, I had accumulated the knowledge from my research to test Apache to be sure it was working properly, and it worked fine. However, PHP still did not work, even after making the recommended changes to the php.ini file. I even found that a PHP Debug software was available, and was called XDebug. I downloaded and installed that, and tried to figure out how to use it, and there was insufficient documentation to enable me to know how to make that software work. I carefully and selectively looked for and marked more of the PHP modules for installation, tried to get PHP to work again, and still had no success.
      I have not uninstalled the current Apache and PHP installations, and did not want to install MySQL until I got PHP working. At this point, I'm willing to try anything you suggest. Until then, I'm 'dead in the water'.

      Don G

        Can you open a Terminal window (or SSH into the box remotely) and execute 'which php' (without the quotes) on the command line and tell me what the response is?

        Also, try executing:

        find /usr -name libphp\*.so

        and let us know what the output is.

          I have done this, and 'which php' result is '/usr/bin/php'.
          'find /usr -name libphp*.so' result is '/usr/lib/apache2/modules/libphp5.so'.

          Don G

            Okay, so PHP seems to be installed for Apache just fine.

            When you tested the "Hello Web" PHP code, did you rename the file to have a .php file extension?

              It was a PHP file with a .php extension to begin with, but when double-clicking from the Nautilis file manager, it opened up and displayed the file contents in gedit. When I right-clicked on it to see if I could open it up with the PHP, software there was no option available to run it from PHP. So I copied the 'Hello Web' PHP file, and added HTML code and changed it to a .htm extension. Then when double-clicking from Nautilis, it opened up a new browser window, which was blank as I had communicated previously.

              Don G

                Er... you can't open the file directly, you have to view it through the Apache webserver, which is what is responsible for invoking PHP for files ending in .php file extension.

                  Well, that last reply from you was a bit of a mind blower for me. First, because if PHP is set up to work on website pages, and is normally and naturally imbedded in HTML, it makes no sense to me that it would not work on a local PC on a browser in an HTML file, starting it in the manner I explained in my last reply to you. Second, and correct me if I have this wrong, isn't the purpose of installing and using Apache on a local PC is to emulate the web server and test the website files prior to uploading them to one's web host directory(ies), and thus to the Production website?

                  And finally, before answering your last reply, I tried to find out how get a GUI type viewing screen of Apache so I could see the results of a .php file loaded, and was unable to find out how to do that in the short time I had available before replying back to you. However, I did load Apache from the command line with '/usr/sbin/apachectl start', but was unable to get a GUI type viewing screen from that as well. What do I need to do to make this work?

                  Don G

                    donglass wrote:

                    First, because if PHP is set up to work on website pages, and is normally and naturally imbedded in HTML, it makes no sense to me that it would not work on a local PC on a browser in an HTML file, starting it in the manner I explained in my last reply to you

                    Why doesn't that make sense to you? If you simply double click on a .htm or .php file in Windows, your default web browser is going to read the file's contents and render it.

                    PHP is a server-side language, meaning it is only processed by the server. If you're opening a file from your hard drive, there is no server at all. You have to view the files through the webserver (e.g. http://localhost/path/to/myscript.php) in order for them to be processed by PHP.

                    donglass wrote:

                    Second, and correct me if I have this wrong, isn't the purpose of installing and using Apache on a local PC is to emulate the web server and test the website files prior to uploading them to one's web host directory(ies), and thus to the Production website?

                    Definitely, but if you just double click the files and load them from your hard drive, then all of that is moot since the Apache webserver isn't involved at all.

                    donglass wrote:

                    I tried to find out how get a GUI type viewing screen of Apache

                    I don't really understand what you're referring to here... a GUI for what? Apache is just a daemon processes that sits in the background waiting to serve HTTP requests... there's no GUI because there's nothing to see.

                      I have created complex non-web business applications, but know little about web development, and am totally committed to learning it well. I know this all is very simple to you since you have gone through the necessary learning curve, but I am a newby to both web development and PHP, and am still in the process of learning the basic concepts of how all this web tech stuff works. For example in a recent reply to me you stated 'you can't open the file directly, you have to view it through the Apache webserver, which is what is responsible for invoking PHP for files ending in .php file extension.', and that led me to think that perhaps Apache has some sort of GUI viewer with it. Then in your last reply you state that 'Apache is just a daemon processes that sits in the background waiting to serve HTTP requests... there's no GUI because there's nothing to see', (and this is what I thought to begin with). These two statements seem to be in conflict to me given my limited understanding.

                      Then I tried to use the 'http://localhost/path/to/myscript.php' concept, and was unable to get that to work. Is this the key to get PHP to work with Apache, i.e. put the correct specific verbage for the program to test in the address bar of one's browser? I assume that the 'localhost' part of that is literal (since when only 'http://localhost' is used, it displays 'It Works'. Is that correct? Does 'path' in that mean the path where my test files are located in Linux (on my hard drive)? If not, what does it mean? You have 'path' and 'to' separated by a '/'; what does the 'to' part of that represent? If that means some sort of local webserver address on my PC, how do I get that specific information? Am I on the right track to get this working now? If so, please let me know the answers to my above questions. I greatly appreciate your help.

                      Don G

                        donglass wrote:

                        that led me to think that perhaps Apache has some sort of GUI viewer with it.

                        I suppose in a way you could say it has a GUI, because the GUI is the browser on a client's machine. Basic model:

                        1. Client opens browser and goes to http://yoursite.com/myscript.php

                        2. Apache server receives request for "/myscript.php" and looks for 'myscript.php' file in the website's document root (e.g. the "htdocs" folder).

                        3. Apache notes that the ".php" extension has been mapped to the PHP interpreter, and thus instead of simply reading the file's contents and spitting it out to the client it takes the contents and invokes the PHP language interpreter to handle the request.

                        4. PHP gets invoked and processes the .php file for PHP code to interpret/execute. All other data (e.g. plain HTML outside of <?php .. ?>) tags is treated as output and simply passed back to the webserver as such.

                          Otherwise, PHP code is executed and its output is sent back to the webserver.

                        5. Apache gets response from PHP interpreter and sends that response back to the original HTTP request made by client's browser.

                        6. Browser receives response from Apache and then interprets it (e.g. parses it for HTML/CSS/Javascript/etc.).

                        7. Rendered content is presented to the client.

                        In a nutshell, this is how the WWW works.

                        donglass wrote:

                        Is this the key to get PHP to work with Apache, i.e. put the correct specific verbage for the program to test in the address bar of one's browser?

                        Er... you might want to go find some very basic tutorials/articles about how websites work in general. The "correct specific verbage" is simply using the correct URL.

                          This process is certainly not user friendly, and there should be more consistency among the different Ubuntu Linux installations available, and that would probably save the programmers that develop these different installations a lot of analysis, design, and coding time.

                          i could not find an 'htdocs' folder in my Linux installation. I then did a grep to find 'document root', but ended up finding 'documentroot' (without the space) in the /etc/apache2/sites-available/ and /etc/apache2/sites-enabled/ folders. In all files that had 'documentroot' in them, they specified /var/www/ as the default directory under a 'Virtual Host' module in each of the text-based (not binary) programs.

                          I then copied my test PHP files in that folder. Then I input 'http:///var/www/first.htm' or 'http:///var/www/first.php' (the 'Hello World" PHP program) in the browser's address line, and then pressed the Enter key, I still get nothing, so neither the .php or the .htm file worked. I must be doing something wrong. Hopefully you'll be able to tell me what.

                          Don G

                            Write a Reply...