I have installed PHP5 into a recent Linux Ubuntu 12.04 installation (over a month ago), and have been working on trying to configure PHP and make it work, but have been unsuccessful. I have nearly always been able to figure out hardware and software problems, but am currently stumped and need some help. I have three PHP technical books I bought a couple of years ago, and I can find nothing in them to help me resolve this problem. There is urgency since I have a website (developed in HTML) that I need to add new features to with PHP. I have coded about 90% of it in PHP and tested it, but my Ubuntu 10.10 stopped working and there was no longer any support for that version. So I had to reinstall a current version of Linux Ubuntu, Apache, PHP, MySQL, and PHPAdmin (LAMP), and get them to work first.

I installed PHP with the 'sudo apt-get install php5' command at the Terminal Window. I got the following information from inserting '127.0.1.1/info.php' in my browser address input space. That is the only PHP command that I can get to work. The version of PHP that was installed is 5.3.10; the localhost port is 127.0.1.1 (the default since the installation was unable to find a port designation); the Apache version is 2.2.22; my root directory is /var/www; my php.ini configuration file is at /etc/php5/apache2; additional .ini files are at /etc/php5/apache2/conf.d; the path is '/usr/local/bin; /usr/bin; /bin'. My browser is Firefox version 22.0 (the current and newest version).
When I double click on a .php file in Nautilus, the editor (gedit) is started, and shows the contents of the .php file, and the PHP commands are not executed (whereas they executed fine in my previous Ubuntu 10.10 installation). When I double click on a .html file that has PHP code in it, I get the output from the HTML commands, but no output from the PHP commands. When I right click on the browser output to view the Page Source, the HTML commands are in purple, and the PHP commands are in red (I think this indicates the PHP commands are not being executed). All of these worked fine in my previous Ubuntu 10.10 and PHP installation, so unless basic coding rules have changed drastically, it cannot be a HTML or PHP coding problem.

My /etc/apache2/httpd.conf file is as follows:

AddType application/x-compress .z 
AddType application/x-gzip .gz .tgz 
AddType application/x-httpd-php .php .phtml .html 
AddType application/x-httpd-php-source .phps
LoadModule access_module modules/mod_access.so 
LoadModule actions_module /usr/lib/apache2/modules/mod_actions.so 
LoadModule alias_module modules/mod_alias.so 
LoadModule asis_module /usr/lib/apache2/modules/mod_asis.so 
LoadModule auth_basic_module modules/mod_auth_basic.so 
LoadModule ssl_module modules/mod_ssl.so
LoadModule php5_module  modules/libphp5.so

My /etc/php5/apache2/php.ini file (without the commented lines) is as follows:

[code=php]
engine = On
short_open_tag = On
asp_tags = Off
precision = 14
y2k_compliance = On
output_buffering = 4096
zlib.output_compression = Off
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func = 
serialize_precision = 17
allow_call_time_pass_reference = Off
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir = 
safe_mode_exec_dir = 
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
disable_classes = 
zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = Off
variables_order = "GPCS"
request_order = "GP"
register_globals = Off
register_long_arrays = Off
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file = 
auto_append_file = 
default_mimetype = "text/html"
include_path = ".:/usr/bin/php5: /usr/share/php5: /usr/lib/php5: /var/lib/php5: /etc/php5"
doc_root = 
user_dir = 
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[Date]
[filter]
[iconv]
[intl]
[sqlite]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket= 
[Phar]
[Syslog]
define_syslog_variables  = Off
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port = 
mysql.default_socket = 
mysql.default_host = 
mysql.default_user = 
mysql.default_password = 
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket = 
mysqli.default_host = 
mysqli.default_user = 
mysqli.default_pw = 
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain = 
session.cookie_httponly = 
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check = 
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
mssql.secure_connection = Off
[Assertion]
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[mcrypt]
[dba]
[xsl]

I have downloaded the PHP manual, and read the Configuration section, and have found nothing helpful there. In addition, the PHP manual is outdated, and is primarily about PHP4, and many things in PHP5 seem to have changed since PHP4. The only other clue I have is from the /var/log/apache2/error.log file, and I have been unable to interpret the meaning of the error messages in it. They are as follows:

[Sun Jun 23 18:32:36 2013] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico 
[Sun Jun 23 18:41:35 2013] [error] [client 192.168.210.100] File does not exist: /var/www/currentsetting.htm

A confusing aspect of this for me is that the port address in the second error message is shown as 192.168.210.100 instead of 127.0.1.1. I have spent a lot of time searching with grep for a file with 'currentsetting.htm' in it to see where this comes from, but have been unable to find it. The first error message has the default port address in it. And to me, this begs the question, why won't this work when you install PHP without all of this hassle? I'm beginning to think that even though I have invested a lot of time developing several vitally needed features using PHP in my website, perhaps I should move on to other software to complete this. I feel quite exasperated and frustrated by this experience. I hope at least one of you has the knowledge, experience, and competence to help me resolve this problem soon so I don't have to start over with something else. Thanks.

    I have downloaded the PHP manual, and read the Configuration section, and have found nothing helpful there. In addition, the PHP manual is outdated, and is primarily about PHP4, and many things in PHP5 seem to have changed since PHP4.

    The first thing you should probably do then is download the PHP manual (http://www.php.net/download-docs.php) - assuming you don't want to read it online (http://www.php.net/docs.php).

      What do you see when you go to [font=monospace]http://localhost[/font]?

      What are the contents of [font=monospace]info.php[/font] (and what, specifically, was the output)?

        To Weedpacket:
        Why do you suggest I get the manual when I stated that I already have it, have studied the Configuration section, and could not find any information that would help? PHP and Apache installed without any error messages. The only section of the manual that would potentially have been helpful would have been the Configuration section.

        You say I have inadequate information. I thought I included every bit of information pertinent to this problem. What other information is needed that could possibly be helpful?

        To traq:
        When I input http://localhost into my browser, I get a blank browser screen. When I right click on the browser screen, I get a light gray number '1' in the upper left hand corner of the browser screen. I do not know what that means. Do you know what that means?
        The contents of info.php are as follows:
        <?php
        phpinfo();
        ?>
        When I double click on that file in Nautilis, the gedit editor is brought up with the contents of info.php displayed.

        The contents of phpinfo.htm are as follows:
        <!DOCTYPE html>
        <html>
        <body>
        <?php
        phpinfo();
        ?>
        </body>
        </html>
        When I double click on phpinfo.htm, I get a blank browser screen again. However, when I right click on the browser screen and view the page source, I get the same as the contents of phpinfo.htm, but the '<?php phpinfo(); ?>' text is in red (which I think designates an error).

        I hope this information helps.

          donglass wrote:

          Why do you suggest I get the manual when I stated that I already have it,

          Because of:

          In addition, the PHP manual is outdated, and is primarily about PHP4, and many things in PHP5 seem to have changed since PHP4.

          it sounded like you had a really old version of the manual.

          That said, configuration hasn't changed that much in over a decade.

          When I double click on phpinfo.htm, I get a blank browser screen again.

          The name of the file is literally [font=monospace]phpinfo.htm[/font]? [font=monospace]htm[/font] isn't in the list of file extensions you've told the server to treat as PHP.

          AddType application/x-httpd-php .php .phtml .html 

            If you're simply double clicking on files, you shouldn't expect to see the same result as you would if you use your browser to navigate to the appropriate URL through your webserver. The latter is the only case I would expect the PHP code to actually get sent through the PHP interpreter (with the output being forwarded along to your browser as the body of the HTTP response).

              donglass;11030745 wrote:

              When I input http://localhost into my browser, I get a blank browser screen. When I right click on the browser screen, I get a light gray number '1' in the upper left hand corner of the browser screen. I do not know what that means. Do you know what that means?

              Blank screens happen when there is a PHP error and you have [font=monospace]display_errors[/font] set to "off". Check your error logs.

              donglass;11030745 wrote:

              When I double click on phpinfo.htm, I get a blank browser screen again. However, when I right click on the browser screen and view the page source, I get the same as the contents of phpinfo.htm, but the '<?php phpinfo(); ?>' text is in red (which I think designates an error).

              Couple things:

              1) as Weedpacket says, ".htm" is not one of the extensions you've set php up to parse. Change the extension to one of those - ".php", for example.

              2) [edit: bradgrafelman beat me to it] what do you mean by "double click on" the file? Are you trying to open these directly from the folder they're stored in? In most cases, that means your browser will be using the file:/// protocol, and php will be bypassed anyway. You need to open these files by typing the url into your browser (e.g., "http://localhost/yourfile.php").

              3) the text is not highlighted in red to indicate an error. Your browser does not parse PHP, does not understand PHP, and cannot tell you if your PHP code has any errors. The highlighting color will vary between browsers, but probably represents "text" or "malformed html tags" or similar. Again, to check PHP errors, check your error log. (I don't see an entry in your php.ini for the error_log - is there, or not? If not, PHP errors will be sent to the SAPI error log (probably your [FONT=Courier New]/var/log/apache2/error.log[/FONT] file - are there really only two messages in that log?)).

                I had forgotten that you have to put the .php file in the browser to get it to work; most programs in Ubuntu work from Nautilis when you double click on the file. And I want to thank everyone who responded thus far. However, as I was thinking back, I remember that shortly after I experienced this problem, I did some research on the Internet, and tried a couple of recommendations that didn't work. I did not document what I tried, and I don't remember what I tried either. I have a huge concern that our difficulty lies in other unseen and unpredictable effects from these factors. So, I feel that to continue as is will keep us in an unrewarding quagmire. Thus I have decided that I will back up my recently added files in Ubuntu, and then reinstall Ubuntu 12.04, formatting the drive as the installation is done so that the new installation will be completely fresh. Then I will execute the following in the Terminal Window:

                sudo apt-get install apache2
                sudo apt-get install php5
                sudo apt-get install libapache2-mod-php5
                sudo /etc/init.d/apache2 restart

                I will then see if PHP/Apache works. If not, then I will address this issue again in this thread. If it works, then I will proceed in similar fashion and install MySQL and PHPMyAdmin, and close this thread as solved. If someone has a method of PHP/Apache installation that will be more likely to work, please let me know about that very soon.

                  donglass;11030809 wrote:

                  most programs in Ubuntu work from Nautilis when you double click on the file.

                  If by "programs" you mean executable files, then yes, that would make sense. It would also make sense that this would not work for .php scripts, since those scripts are not "programs."

                    I have re-installed Ubuntu 12.04, and have made several attempts to see if PHP/Apache works on this fresh installation. However, the info.php file no longer gives the PHP
                    that it did before; instead it gives a blank display in the browser, and when I right click to view the page source, there is only a light gray '1' in the upper left hand corner. When I
                    entered 'sudo /etc/init.d/apache2 restart' I got the following output:

                    • Restarting web server apache2 [Wed Jul 03 23:51:59 2013] [warn] module alias_module is already loaded, skipping
                      [Wed Jul 03 23:51:59 2013] [warn] module auth_basic_module is already loaded, skipping
                      [Wed Jul 03 23:51:59 2013] [warn] module php5_module is already loaded, skipping
                      apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
                      ... waiting [Wed Jul 03 23:52:00 2013] [warn] module alias_module is already loaded, skipping
                      [Wed Jul 03 23:52:00 2013] [warn] module auth_basic_module is already loaded, skipping
                      [Wed Jul 03 23:52:00 2013] [warn] module php5_module is already loaded, skipping
                      apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
                      [ OK ]

                    Then I checked the /var/log/apache2/error.log, and have the entire output since the Ubuntu installation as follows:

                    [Wed Jul 03 22:19:41 2013] [notice] Apache/2.2.22 (Ubuntu) configured -- resuming normal operations
                    [Wed Jul 03 22:20:16 2013] [notice] caught SIGTERM, shutting down
                    [Wed Jul 03 22:20:21 2013] [notice] Apache/2.2.22 (Ubuntu) configured -- resuming normal operations
                    [Wed Jul 03 22:20:27 2013] [notice] caught SIGTERM, shutting down
                    [Wed Jul 03 22:20:29 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.6 with Suhosin-Patch configured -- resuming normal operations
                    [Wed Jul 03 22:22:35 2013] [notice] caught SIGTERM, shutting down
                    [Wed Jul 03 22:22:36 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.6 with Suhosin-Patch configured -- resuming normal operations
                    [Wed Jul 03 23:29:47 2013] [notice] caught SIGTERM, shutting down
                    [Wed Jul 03 23:30:42 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.6 with Suhosin-Patch configured -- resuming normal operations
                    [Wed Jul 03 23:40:31 2013] [error] [client 127.0.0.1] script '/var/www/hello-web.php' not found or unable to stat
                    [Wed Jul 03 23:40:32 2013] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/favicon.ico
                    [Wed Jul 03 23:40:32 2013] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/favicon.ico
                    [Wed Jul 03 23:40:50 2013] [error] [client 127.0.0.1] script '/var/www/hello-web.php' not found or unable to stat
                    [Wed Jul 03 23:40:50 2013] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/favicon.ico
                    [Wed Jul 03 23:40:50 2013] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/favicon.ico
                    [Wed Jul 03 23:41:54 2013] [error] [client 127.0.0.1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
                    [Wed Jul 03 23:41:54 2013] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/var/www/phpinfo.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
                    [Wed Jul 03 23:42:53 2013] [error] [client 127.0.0.1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
                    [Wed Jul 03 23:42:53 2013] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/var/www/phpinfo.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
                    [Wed Jul 03 23:42:53 2013] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/favicon.ico
                    [Wed Jul 03 23:42:53 2013] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/favicon.ico
                    [Wed Jul 03 23:43:50 2013] [error] [client 127.0.0.1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
                    [Wed Jul 03 23:43:50 2013] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/var/www/info.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
                    [Wed Jul 03 23:50:29 2013] [error] [client 127.0.0.1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
                    [Wed Jul 03 23:50:29 2013] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/var/www/info.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
                    [Wed Jul 03 23:51:59 2013] [notice] caught SIGTERM, shutting down
                    [Wed Jul 03 23:52:00 2013] [warn] module alias_module is already loaded, skipping
                    [Wed Jul 03 23:52:00 2013] [warn] module auth_basic_module is already loaded, skipping
                    [Wed Jul 03 23:52:00 2013] [warn] module php5_module is already loaded, skipping
                    [Wed Jul 03 23:52:00 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.6 with Suhosin-Patch configured -- resuming normal operations
                    [Thu Jul 04 00:44:58 2013] [error] [client 127.0.0.1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
                    [Thu Jul 04 00:44:58 2013] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/var/www/info.php' (include_path='.:/usr/bin/php5: /usr/share/php5: /usr/lib/php5: /var/lib/php5: /etc/php5') in Unknown on line 0
                    [Thu Jul 04 01:15:49 2013] [error] [client 127.0.0.1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
                    [Thu Jul 04 01:15:49 2013] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/var/www/info.php' (include_path='.:/usr/bin/php5: /usr/share/php5: /usr/lib/php5: /var/lib/php5: /etc/php5') in Unknown on line 0

                    I'm not sure how to interpret this, but I seem to have a 'permission denied' problem and a problem accessing the '127.0.1.1' Server. Does anyone have information about this
                    that would be helpful?

                      I got the following errror message after my last thread reply message, and is as follows:

                      [Wed Jul 03 23:42:53 2013] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/favicon.ico

                      I searched for favicon.ico in the Terminal Window and found this file in /var/www. I used chmod to change the permissions on it, and now I am able to run all .php files, but only from that root (/var/www) directory. When I try to run .php files from a subdirectory of /var/www, I get the following error message in my error.log file:

                      [Thu Jul 04 17:50:00 2013] [error] [client 127.0.0.1] (13)Permission denied: access to /TestFiles/PHP_Test1.php denied

                      Also, when I try to run a .html file from any directory (including the /var/www directory), I get different results. If the .html file that has only HTML code, and does not try to run any .php commands, runs fine. If the .html has some HTML code and some PHP code in it, then I get the HTML output that is not trying to run PHP code, but when it tries to run PHP code, that part of it does not produce any output, and when I right click on the browser output I see the HTML code in purple, and the PHP code in red.

                      An error message I got with the previous installation came up afterwards as well, which is as follows:

                      [Thu Jul 04 19:22:29 2013] [error] [client 192.168.210.100] File does not exist: /var/www/currentsetting.htm

                      I tried to find currentsetting.htm, and is nowhere on my Ubuntu or any other drive. I Googled currentsetting.htm, and all I could find is that it is a Netgear problem. But I have no Netgear hardware or software on or in my PC. So I do not understand where that error message comes from. My main concern about that error message is if it is affecting my ability to get PHP to work successfully, but I don't know for certain.

                      It appears that this situation is a combination of more than one cause of the problems, and fortunately I have resolved one of the problems. But this is on a fresh standard Ubuntu 12.04 installation, and a fresh standard PHP installation, so there must be quite a few other people that have experienced this same problem. So someone out there surely has some answers that can resolve these issues, and I hope someone comes forward with them soon so I can move on to other important and urgent matters. Thanks.

                        Write a Reply...