I've just installed Apache, MySQL and PHP 7 on an Ubuntu 14.04 machine. I began by installing PHP 5.5, and then upgraded to PHP 7 - although admittedly I didn't test PHP 5.5 before upgrading. Probably should have done that.
I've created a test PHP script (info.php) to see if everything is working:
<?php
phpinfo();
?>
The script executes and displays the phpinfo output as expected when I run it in the Terminal, but when I open it in a browser I get a blank screen. Have checked to make sure I have the right URL etc.
I also get a blank screen if I try the following:
<?php
echo "Hello World";
?>
If I add HTML elements before the PHP code, these are displayed in the browser just fine.
I've turned display_errors to On in php.ini, and checked the Apache error log, which isn't showing anything strange. I can't find a PHP error log in the etc/php/7.0 folder or any of its subfolders.
I have noticed that in the etc/php5 folder I have three subfolders: apache2, cli and mods-available - but in the etc/php/7.0 folder I have no apache2 subfolder - in its place I have a subfolder named fpm.
This is suggesting to me that I simply don't have PHP7 set up as an Apache module, but maybe someone could confirm this for me? I'm not sure how to check this.
Can anyone suggest anything?
Thanks in advance,
Gareth
The problem here turned out to be that I simply hadn't installed mod_php as part of the PHP 7 installation process.
To rectify this I entered the following in the terminal:
sudo apt-get install libapache2-mod-php7.0
Everything appears to be working as expected now.
Related
Firstly, please forgive me if this is in the wrong section (and could you tell where this should be?)
I am starting to use Laravel, and it requires PHP with Mcrypt.
So I followed the tutorial for Homebrew and have got PHP5.4 set up with Mcrypt
Typing which php and php -v at the terminal all confirm that this PHP 5.4.24 is loaded and are ready to go.
However, the output of phpinfo() in the localhost directory (via Apache) shows I am using PHP 5.4.17 with no Mcrypt.
OK, so I know I should have set up the httpd.conf with:
LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so
And when I do that, I get the right PHP version in Apache, but PHP seems to fail in subdirectories.
I have a file index.php at localhost/test containing <? echo phpinfo();?>, and...
...it works when the line in httpd.conf says this: LoadModule php5_module libexec/apache2/libphp5.so...
...but does not work when I change to homebrew's suggestion.
Any ideas?
TL;DR...
When I set up httpd.conf to work with php54 (installed via Homebrew), then PHP is executed in the home directory of localhost, but not in the subdirectories.
Oh. You. Idiot.
This post proves that I am, without a doubt, the biggest fool that walked the earth.
Clearly, short tags are turned off in the newer version of PHP but not in the older one.
So everything was working fine - if only I had used <?php echo phpinfo(); ?> then I could have saved about 8 hours of tears.
I'm trying to install TestLink 1.9.7 but the index.php script in the Install folder only shows the source code. I've read a question ticket on StackOverflow about a similar problem with PHPMyAdmin but the solution (enabling short tags in php.ini) didn't work for me. the file install/index.php still won't execute.
I've installed the following prior to testlink:
Apache 2.2.25,
PHP 5.3.27,
MySQL Server 5.6.12.2(Web Community)
This is all that the installation manual for testlink tells me to install. I believe something else is missing. Is there any setting in Apache that I should change, or any service I need to enable?
Edit: I've read the instructions on php.net on how to configure Apache to work with PHP, however the section about configuring it as handler cause the Apache server to fail to restart and the section about configuration as CGI contains insufficient instructions(like which files to copy over and how to edit them).
I have Ubuntu 10.04 and my apache2 server has been running for a couple of days now.
I have created a new directory called 'xmlscores' and when I run any PHP file inside of this directory nothing gets returned, not even my HTML that is inside of the page.
Note: Other File Types open correctly in the browser (I have tried HTML & XML).
This suggests to me that the php code is not even interpreted and thus not even sent to my apache server - my browser, by default, returns blank page (source is blank)
Note: The problem is not with my php code, as I have tried multiple files and none have worked.
Check your Apache Error logs, ensure the entire version of PHP is installed
If you're using Debian/Ubuntu you can run
apt-get install php5
I have installed XAMPP server on my system to be able to use PHP. But after installation, when I run any php script on the browser it does not run. I do not see any ouput. No checking the phpinfo() from local host I see that version 5.3.5 is installed
Even when running a a simple php file like where I echo a line;
I do not see anything on my browser. So, my question is do I need to make any configuration changes to my browser or system to get PHP running.
Put your scripts into /XAMPP/htdocs and then point your browser to: http://localhost/your_script.php
Your best bet is taking a look at your log files, and perhaps turning error reporting on. Put a simple script in your webroot that simply echo's a string, for example:
<?php echo "Hello World!";
with the above there is very little that can go wrong. Work from there. Take a look at your phpinfo, and see where your log files are located. Search for
error_log
for the path to your PHP error log file and maybe see if
display_errors
is on.
This is something that has a multitude of possibilities that can be the cause of your problem.
install phpxx-php which is used for creating dynamic web sites
check version of php using php -v
if you have php55 then use:
yum install php55-php.x86_64
Ensure to save file as .php ; e.g. index.php and not index.html
From Troublespy here are the reasons why php might not be working in the browser:
You did not download a local server
You are using the wrong version of php
You put your scripts in the wrong directory
You have a php error and the error didn't get printed
Your php code is wrong or incomplete
Make sure you check all reasons.
I'm using WAMP on windows, which installs PHP, Apache and MySQL.
I'm now working on something new that requires PostgreSQL. The current install won't do it for me, as I keep getting these errors:
Call to undefined function pg_query()
Always
undefined function
I've installed PostgreSQL 8.3.7-1 for windows, added php_pgsql.dll,php_pdo_pgsql.dll and even libpq.dll, which a note on the PHP page for postgreSQL says Windows users need starting from PHP 5.2.6
Still, I keep getting these errors...
Can someone advise the best course of action? Or should I just uninstall apache and everything else, and do a fresh install of each component seperatly?
xampp doesn't "tell" apache/php which php.ini to use. Therefore php uses its default lookup strategy to find the .ini file. If you haven't changed anything this will be the one in the directory where the apache binary is located, xampp/apache/bin/php.ini. Did you edit this file and removed the semicolon before extension=php_pgsql.dll ?
When in doubt askecho 'php.ini: ', get_cfg_var('cfg_file_path');which file you have to edit.
xampp installs php as a module by default and you have to restart the apache in order to get php to read the php.ini again.
After thatecho extension_loaded('pgsql') ? 'yes':'no';should print yes. If it doesn't stop the apache service, open a command shell, go to your xampp directory and enterapache_start.batThis will start the apache as a console application and you can see startup errors in this console (instead of windows' event manager). If a dll is missing you will get a message box.
Did you enable it in the php ini file?
What does a call to phpinfo() say is installed for extensions?
Depending on what kind of errors you see in the Apache's error.log the answers on this question might be helpful.
I did the same as you did and got rid of the issue.But mine was for xampp. Probably you should re-install your wamp.