My setup was
Ubuntu 14.04
php 5.x
The website was working fine.
I upgraded the system to:
Ubuntu 16.03
php 7
When I do:
php -v
I get:
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
I have:
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2017-09-18T15:09:02
But, when I try to access the website, I now see a listing of the file index.php in the browser window.
Any ideas?
You should add a .htaccess file to the directory root with the line DirectoryIndex index.php index.html which tells Apache to use index.php first followed by index.html when in a directory, which is why you're seeing a directory listing of index.php
Related
I am using PhpStorm for a year and now I want to run my PHP server using the PHP Run menu:
I run the server pushing the green arrow button. Then the console show:
/home/john/.cache/JetBrains/PhpStorm2020.1/plugins/idea-php-latest-plugin/php-v7.3.1/php.sh -S localhost:8080 -t /home/john/my-nice-project/backend/web
Then I go to localhost:8080 in my browser and I see this error:
I execute php -v in my terminal and I can see this:
PHP 7.2.34-18+0~20210223.60+debian10~1.gbpb21322 (cli) (built: Feb 23 2021 16:47:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.34-18+0~20210223.60+debian10~1.gbpb21322, Copyright (c) 1999-2018, by Zend Technologies
So maybe the problem is the version of the PHP interpreter: I have 7.2.34 and PhpStorm has php-v7.3.1 configure.
Is there any way to configure the version?
But if I execute this command, it works fine:
php yii serve --docroot="backend/web/"
Add this to your php.ini file:
extension=pdo.so
https://www.php.net/manual/en/pdo.installation.php
I'm trying to call json_decode(). I'm using a shared Hostgator server. I have already checked some other questions on StackOverflow regarding "json_decode"
After ssh-ing in, php -v outputs the following:
PHP 7.4.16 (cli) (built: Mar 9 2021 17:55:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with the ionCube PHP Loader + ionCube24 v10.4.5, Copyright (c) 2002-2020, by ionCube Ltd.
and when I search the PHP modules using php -m it does appear to have the line
json
in the output
Try this:
Create a file in the servers web root called phpinfo.php and add the following to it:
<?php
phpinfo();
?>
Go to phpinfo.php in your web browser to confirm that JSON is installed, and that the web server is using the same version of PHP as the CLI version.
I was using the built in macos big sur apache and php, but an update deleted all the preferences that i had in apache...as it allways does.
This time i wanted to install the homebrew version of apache and php, and followed all the indications:
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/8.0/
after i configure everything, check the config file with: sudo apachectl configtest and returned ok. i test my new php with: php -v and it returns the same php that i had before install the hombrew version:
WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: Dec 21 2020 21:33:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies
if i run /usr/local/bin/php -v directly from the brew php folder:
PHP 8.0.3 (cli) (built: Mar 4 2021 20:45:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies
how can i use the brew php?
It's usually not a good idea to remove system binaries. Instead, you can add an alias in the ~/.zshrc file. At the end of the file, add:
alias php="/usr/local/bin/php"
the solution was to put this in ~/.bash-profile
export PATH=/usr/local/bin:$PATH
the restart the pc, and it was ready, now when i php -v
PHP 8.0.3 (cli) (built: Mar 4 2021 20:45:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies
I have an automated process to run a php script on 2 machines. It does the following:
/opt/rh/php54/root/usr/bin/php myphp.php
However, It is not running on Host 1(error: /opt/rh/php54/root/usr/bin/php: not found) but running fine on Host 2:
Host 1: Not running
PHP 7.2.9 (cli) (built: Aug 15 2018 09:19:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Host 2: running fine
PHP 5.4.40 (cli) (built: Jul 22 2016 07:31:37)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
/opt/rh/php54/root/usr/bin/php--->>> This path does not exist on host 1
SELinux is disabled on both hosts.
PHP will not be installed to the path u are using. Try to use php myphp.php instead.
The path \opt/rh/php54/root/usr/bin/php does not seem to be correct. Find out the correct path for the php installation directory.
You can use which php or whereis php command.
For some reason my phpldapadmin doesn't want to work with my website and it says "If you are seeing this in your browser, PHP is not installed on your web server!!!" Which is not true as if the info.php file is navigated to like here it says php is enabled along with the ldap extension. The apache error log doesn't say anything about the error though.
Every other php page on my website works except phpldapadmin. I am really confused.
This is what I get when I run php -v
PHP 7.1.1-1+deb.sury.org~xenial+1 (cli) (built: Jan 20 2017 09:20:20) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.1-1+deb.sury.org~xenial+1, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
Your webserver's document root is /var/www/html and you have to place everything within this folder (may use subfolders /var/www/html/phpmyadmin, /var/www/html/phpldapadmin, etc.). Or you can define alias for certain purposes which can point to a folder outside document root. How to config an alias: https://httpd.apache.org/docs/2.4/mod/mod_alias.html#alias
Everything else what's outside isn't accessible by webserver itself and neither can be processed by PHP.