Please give me solutions/code for the following.
Due to a drupal drush error as solved here https://github.com/tripal/tripal_blast/issues/46, I am trying to check and configure my PHP .
My drupal 7 website phpinfo() is showing that 8.1 is loaded. But when I check version in cli
php -v
PHP 8.2.17 (cli) (built: Mar 16 2024 08:42:08) (NTS)
Copyright (c) The PHP Group
When I try to change it
sudo a2dismod php8.2
sudo a2enmod php8.1
sudo a2enmod php8.1-fpm
I am getting error
ERROR: Module php8.2 does not exist!
sudo systemctl status php8.1-fpm
is showing output
● php8.1-fpm.service – The PHP 8.1 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-04-12 12:28:21 IST; 10min ago
Docs: man:php-fpm8.1(8)
Process: 22877 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, status=0/SUCCESS)
Main PID: 22873 (php-fpm8.1)
Status: "Processes active: 0, idle: 2, Requests: 1, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 38239)
Memory: 35.4M
CPU: 433ms
CGroup: /system.slice/php8.1-fpm.service
├─22873 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─22875 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >
└─22876 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >
Apr 12 12:28:21 localhost systemd[1]: Starting The PHP 8.1 FastCGI Process Manager…
Apr 12 12:28:21 localhost systemd[1]: Started The PHP 8.1 FastCGI Process Manager.
Apr 12 12:30:01 localhost drupal[22875]: http://teak-wood-genes-drupal7|1712905201|file system|127.0.0.1|http://teak-wood-genes-drupal7/cron.php?cron_key=h9ONgYDBf7EQoWKzxKbDNSNmzkTSny7Ao7Zzzr_cDHg||0||D>
Apr 12 12:30:01 localhost drupal[22875]: http://teak-wood-genes-drupal7|1712905201|cron|127.0.0.1|http://teak-wood-genes-drupal7/cron.php?cron_key=h9ONgYDBf7EQoWKzxKbDNSNmzkTSny7Ao7Zzzr_cDHg||0||Cron run>
I have also attached apache2 error log file
[Fri Apr 12 12:41:43.212523 2024] [proxy_fcgi:error] [pid 24037:tid 129450045863488] [client 127.0.0.1:41388] AH01071: Got error ‘PHP message: PHP Deprecated: Optional parameter $acc declared before required parameter $hit_name is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal_blast/api/blast_ui.api.inc on line 541PHP message: PHP Deprecated: Optional parameter $form_state declared before required parameter $mode is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc on line 23PHP message: PHP Deprecated: Optional parameter $job_id declared before required parameter $node_type is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_core/api/tripal_core.chado_nodes.api.inc on line 1082PHP message: PHP Deprecated: Optional parameter $input declared before required parameter $form_state is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_core/includes/tripal_core.form_elements.inc on line 104PHP message: PHP Deprecated: Optional parameter $input declared before required parameter $form_state is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_core/includes/tripal_core.form_elements.inc on line 202PHP message: PHP Deprecated: Optional parameter $analysis_id declared before required parameter $property is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 15PHP message: PHP Deprecated: Optional parameter $feature_id declared before required parameter $property is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 15PHP message: PHP Deprecated: Optional parameter $analysisfeature_id declared before required parameter $property is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 15PHP message: PHP Deprecated: Optional parameter $analysis_id declared before required parameter $value is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 63PHP message: PHP Deprecated: Optional parameter $feature_id declared before required parameter $value is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 63PHP message: PHP Deprecated: Optional parameter $analysisfeature_id declared before required parameter $value is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 63PHP message: PHP Deprecated: Optional parameter $analysis_id declared before required parameter $value is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 116PHP message: PHP Deprecated: Optional parameter $feature_id declared before required parameter $value is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 116PHP message: PHP Deprecated: Optional parameter $analysisfeature_id declared before required parameter $value is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 116PHP message: PHP Deprecated: Optional parameter $analysis_id declared before required parameter $property is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 200PHP message: PHP Deprecated: Optional parameter $feature_id declared before required parameter $property is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 200PHP message: PHP Deprecated: Optional parameter $analysisfeature_id declared before required parameter $property is implicitly treated as a required parameter in /var/www/html/teak-wood-genes-drupal7/sites/all/modules/tripal/legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc on line 200’ [Fri Apr 12 12:45:20.729129 2024] [mpm_event:notice] [pid 24035:tid 129450146842496] AH00492: caught SIGWINCH, shutting down gracefully [Fri Apr 12 12:45:20.774331 2024] [mpm_event:notice] [pid 39857:tid 126212069377920] AH00489: Apache/2.4.52 (Ubuntu) mod_wsgi/4.9.0 Python/3.10 configured — resuming normal operations [Fri Apr 12 12:45:20.774420 2024] [core:notice] [pid 39857:tid 126212069377920] AH00094: Command line: ‘/usr/sbin/apache2’ [Fri Apr 12 12:47:36.063235 2024] [mpm_event:notice] [pid 39857:tid 126212069377920] AH00493: SIGUSR1 received. Doing graceful restartAH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1. Set the ‘ServerName’ directive globally to suppress this message
[Fri Apr 12 12:47:36.068960 2024] [mpm_event:notice] [pid 39857:tid 126212069377920] AH00489: Apache/2.4.52 (Ubuntu) mod_wsgi/4.9.0 Python/3.10 configured — resuming normal operations [Fri Apr 12 12:47:36.068987 2024] [core:notice] [pid 39857:tid 126212069377920] AH00094: Command line: ‘/usr/sbin/apache2’ [Fri Apr 12 13:00:01.784640 2024] [proxy_fcgi:error] [pid 40227:tid 126211808278080] [client 127.0.0.1:40216] AH01071: Got error ‘PHP message: nNote: The PHP error_log at is not writable! Errors will be written to STDERR. Fix the permissions problem or correct the error_log path.PHP message: PHP Warning: Trying to access array offset on value of type null in /var/www/html/teak-wood-genes-drupal7/sites/all/libraries/PHP-Daemon/Core/error_handlers.php on line 118 pid 39307’
I have installed php 8.1 (for drupal 7) and php 8.2 (for drupal 10) as follows:
sudo apt-get -y install php8.1-fpm
sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath php8.1-pgsql
for module in /etc/php/8.1/mods-available/*.ini; do sudo phpenmod -v 8.1 $(basename $module .ini); done
sudo gedit /etc/php/8.1/fpm/pool.d/www.conf
sudo systemctl restart php8.1-fpm
sudo a2dismod mpm_prefork
sudo a2enmod mpm_event
sudo a2enmod proxy proxy_fcgi
sudo a2enconf php8.1-fpm
sudo systemctl restart apache2
cd /etc/apache2/sites-available/
sudo gedit teak-wood-genes-drupal7.conf
and have checked the following php port
listen = /run/php/php8.1-fpm.sock
<VirtualHost *:80>
ServerName teak-wood-genes-drupal7
DocumentRoot /var/www/html/teak-wood-genes-drupal7
<Directory /var/www/html/teak-wood-genes-drupal7>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<FilesMatch .php$>
SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
I have repeated the same for v8.2.
I will be able to solve the drush daemon error and hence run Drupal Tripal-blast tool only when the php/apache error is solved. In addition, it should also help to solve all the "deprecated" errors.
2
Answers
Well,
Maybe it’s not what you want to hear, but start using docker – and your live will be much easier.
Use
https://phpdocker.io
for generating environment configuration .
Works great on windows/Mac/linux
With this solution I have more than 10 projects with php from 5.6 to 8.2 on the same system, and it’s all works
The Drupal PHP uses the standard PHP while the shell uses a different PHP as well, namely
phpx.x-cli
To change versions on what CLI you should use, you need to run:
sudo update-alternatives --set php /usr/bin/phpx.x
where x.x is your PHP Version.Additionally, running multiversion PHP is feasible using
php-fpm
, However, you must ensure that you are usingphp-fpm
for all versions of php. For example, you want to run a PHP 8.2 site and a PHP 7.4 site in one server. You need to use bothphp8.2-fpm
andphp7.4-fpm
in your server, and then setup the appropriate configurations in Apache.This tutorial might help.