Drush + Cygwin PHP fatal errors - php

I have had to re-install / update Cygwin on Windows 8.1, and I have some how broken Drush on my Drupal 7 sites.
Previously I followed this guide Here So I have tried to do a clean install of drush, and noticed that you can now install drush via pear.
pear channel-discover pear.drush.org
pear install drush/drush
So in my home directory :
$ drush --version
Drush Version : 6.2.0
That seems to work, but when I go into my directory where my Drupal web site is, I am getting PHP fatal errors, it is like the PATH or something is broken when I run drush from there :
$ cd /cygdrive/c/websites/www.mywebsite.com
$ drush
require_once(c:/websites/www.mywebsite.com/modules/system/system.module): failed to open stream: No such file or directory drupal.inc:21 [warning]
PHP Fatal error: require_once(): Failed opening required 'c:/websites/www.mywebsite.com/modules/system/system.module' (include_path='.:/usr/share/pear') in /usr/share/pear/drush/includes/drupal.inc on line 21
require_once(c:/websites/www.mywebsite.com/modules/system/system.module): failed to open stream: No such file or directory drupal.inc:21 [warning]
PHP Fatal error: require_once(): Failed opening required 'c:/websites/www.mywebsite.com/modules/system/system.module' (include_path='.:/usr/share/pear') in /usr/share/pear/drush/includes/drupal.inc on line 21
My Current set up is :
Windows 8.1
Cygwin
Drupal 7
For PHP I am using WAMP, but PHP is working in Cygwin
.
$ php -v
PHP 5.5.16 (cli) (built: Aug 24 2014 01:12:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

When using Cygwin's version of PHP, the "require" statement does not recognize path names which start with a drive letter. Thus require 'C:\path-to-file' will generally fail. Internally, it sees the 'C:' as a relative path and appends it to the default directory rather than treating it as an absolute path.
If you rewrite the require statements to use __DIR__, then things usually work.
require __DIR__ . '/modules/system/system.module';

Related

"PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/http.so'" after downgraded PHP from 8.1 to 7.1

We have a requirement that needs to downgrade PHP from 8.1 to 7.1 in our Ubuntu 18 server.
sudo update-alternatives --set php /usr/bin/php7.1
After the downgrade, we're seeing PHP Startup error everytime we check php -v
Below is the exact error text:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/propro.so' - /usr/lib/php/20160303/propro.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/raphf.so' - /usr/lib/php/20160303/raphf.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/http.so' - /usr/lib/php/20160303/http.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 7.1.33-47+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jun 27 2022 08:15:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.33-47+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
The missing libraries are really not found in the said directory as I checked.
/usr/lib/php/20160303
We have tried reinstalling as suggested from other forum with same error.
sudo apt-get install --reinstall `dpkg -l | grep 'ii php7.1' | awk '{ printf($2" "); next}'`
It works for them but not in ours.
I hope I can get help here. Thanks in advance.
By the way, I'm not a Linux and PHP developer. Just starting getting into it.
--reinstall will only reinstall the things that are installed, but it looks like you actually removed a number of modules. The propro, raphf, and http modules are not standard and are not installed by default. If you don't actually need/use them, you can just disable them so that they don't try to load:
phpdismod propro raphf http
However, if your app requires these modules, you'll need to explicitly add them:
apt install php7.1-propro php7.1-raphf php7.1-http

Fatal error: Uncaught Error: Class 'ZipArchive' not found

I have this error.
(I don't use Apache just run php script by CLI)
Fatal error: Uncaught Error: Class 'ZipArchive' not found
However it looks that zip module is installed.
$php -m | grep zip
zip
I have installed php by homebrew on Catalina.
php -v
PHP 7.4.10 (cli) (built: Sep 3 2020 18:21:42) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies
Is there anything I need to check??
For the ZipArchive class to be present, PHP needs to have the zip extension installed.
See this page for installation instructions (both Linux and Windows).
You need to install Zip extension. Depending where you are working on, it is fairly simple to install it.
cPanel:
Head on to 'PHP PEAR Packages' under the Software tab and search Zip and you'll find ZipArchive. You might also need to activate it manually. Head on to Software > Select PHP Version > Extensions, then check the box for Zip.
For EC2 or any other linux hostings/servers:
sudo apt-get install php7.2-zip

composer-php fail to install laravel

I'm trying to move a laravel project to a remote server.
I just copy the folder on the public/html folder, then I've tried to install composer as described here:
https://getcomposer.org/download/
with the very first command I've seen this error:
/federlegno$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
PHP Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in Command line code on line 1
PHP Warning: copy(): Failed to enable crypto in Command line code on line 1
PHP Warning: copy(https://getcomposer.org/installer): failed to open stream: operation failed in Command line code on line 1
as solution I find to run the command without the https: php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
and then it seems thats the others command works, without promt any error (I've tried even to visit the link with the browser and it works!).
Then when I try to run:
composer install
inside the laravel folder this error is raised:
bash: composer: command not found
Some additional information:
/federlegno$ php -r "phpinfo();" | grep OpenSSL SSL Version =>
OpenSSL/1.0.2r OpenSSL support => enabled OpenSSL Library Version =>
OpenSSL 1.1.0j 20 Nov 2018 OpenSSL Header Version => OpenSSL 1.1.1a
20 Nov 2018 Native OpenSSL support => enabled
php version:
ederlegno$ php -v PHP
7.2.15-1+0~20190209065123.16+stretch~1.gbp3ad8c0 (cli) (built: Feb 9 2019 06:51:24) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.15-1+0~20190209065123.16+stretch~1.gbp3ad8c0, Copyright (c) 1999-2018, by Zend Technologies
Laravel version 5.4
You should move the composer.phar file (which is downloaded by the installation scripts) to the /usr/local/bin or /usr/bin directory
sudo mv composer.phar /usr/local/bin/composer
or
sudo mv composer.phar /usr/bin/composer

unable to download dynamic library

I want to install Composer on my Ubuntu 14.04LTS. But during installation I got this:
Some settings on your machine make composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The OpenSSL extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl
Then in php.ini I remove semicolon';' in line ;extension=php_openssl.dll
After this I've got:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.6.2 (cli) (built: Oct 29 2014 06:55:23)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
Where can I get this library?
You use php.ini from windows machine. Use default from package manager. For Ubuntu apt-get.

Error in httpd.conf. Can't locate API module structure `php5_module'

I've recently installed phc, the php compiler. I started out installing LAMP from source with --enable-so for Apache and --enable-embed for PHP5 (among other options these are most relevant to the installation and later configuration).
When I finished installing I realized phc does not yet support PHP5.3 so I uninstalled it and installed PHP5.2. phc works fine now, as does the PHP client application for the commandline. Apache seems to be running fine, too, when I comment out line 193 (see below). It just doesn't parse PHP.
httpd: Syntax error on line 193 of /etc/apache2/conf/httpd.conf: Can't locate API module structure `php5_module' in file /usr/local/lib/libphp5.so: /usr/local/lib/libphp5.so: undefined symbol: php5_module
When I check my version of PHP from the terminal I get the expected output (5.2):
[root#localhost conf]# php -v
PHP 5.2.14 (cli) (built: Sep 7 2010 22:50:25)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
I made sure to move the libphp5.so file from the folder where I built php5.2 (/usr/local/src/php-5.2.14) to /usr/local/lib. I also moved php.ini to /usr/local/lib.
Is there something I'm missing here?
OK!
Apparently when you configure PHP it's important to include the line specifying wehre to find apxs for the proper installation:
--with-apxs2=/etc/apache2/bin/apxs
I did this and the problem vanished :)

Categories