PHP

From Indie IT Wiki
Jump to: navigation, search

php_info File

<?php
phpinfo();
?>

HOWTO: Fix Error: failed to execute shell

Error...

failed to execute shell: bash -c /usr/share/lighttpd/create-mime.assign.pl: No such file or directory
failed to execute shell: bash -c /usr/share/lighttpd/include-conf-enabled.pl: No such file or directory

Reason...

Because the Ubuntu Release Upgrader has removed PHP during the upgrade process. God knows why.

Solution...

Reinstall the PHP CGI module and the PHP MySQL module.

Fix...

sudo apt-get install php-cgi php-mysql
sudo lighty-enable-mod fastcgi-php
sudo service lighttpd restart

FIX: Error: Unable to Load Dynamic Library

Error...

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/dom.so' - /usr/lib/php/20160303/dom.so: undefined symbol: php_libxml_node_free_list in Unknown on line 0

Fix...

sudo apt-get install --reinstall `dpkg -l | grep 'ii  php7' | awk '{ printf($2" "); next}'`

openSSL Check

echo '<?php phpinfo(); ?>' | php 2>&1 |grep -i ssl

PEAR

Installation

sudo apt-get install php-pear

Error: requires PEAR Installer

requires PEAR Installer (version >= 1.10.1), installed version is 1.9.4

The fix is below...

Upgrade

sudo -i
pear upgrade --force --alldeps http://pear.php.net/get/PEAR-1.10.1
pear clear-cache
pear update-channels
pear upgrade
pear upgrade-all

Thanks - https://superuser.com/a/1129953/287000

HOWTO: Secure Tighten PHP

sudo nano /etc/php5/apache2/php.ini /etc/php5/cgi/php/ini

Change the following lines as the following :

display_errors = Off
log_errors = On
allow_url_fopen = Off
safe_mode = On
expose_php = Off
enable_dl = Off
disable_functions = system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, escapeshellarg, escapeshellcmd

Thanks - http://secure-ubuntu-server.blogspot.co.uk/2009/07/howto-hardening-your-apache-and-php-on_07.html

HOWTO: Upgrade To PHP 5.5 On Ubuntu 12.04 LTS

sudo add-apt-repository ppa:ondrej/php5
sudo aptitude update
sudo aptitude -v -s safe-upgrade
sudo aptitude -v -y safe-upgrade
php --version

Thanks - https://joshtronic.com/2013/12/30/upgrade-php-5-3-php-5-5-ubuntu-12-04-lts/

HOWTO: Upgrade PHP 5.3 To PHP 5.4 On Ubuntu 12.04 LTS

sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo aptitude update
sudo aptitude -v -s safe-upgrade
sudo aptitude -v -y safe-upgrade
php --version

Thanks - http://www.nicovs.be/install-php-5-4-on-ubuntu-12-04-lts

HOWTO: Install Extensions

Centos

pecl install zip