V
V
Vincent12017-01-23 12:05:06
PHP
Vincent1, 2017-01-23 12:05:06

How to tell apache which version of php to use?

OS Freebsd
Installed the second version of php 70 on the server, but now I can't find where to tell apache which version of PHP to use.
And another question, how can I specify a specific version of php for a separate host?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kpa6uu, 2017-01-23
@kpa6uu

sudo a2dismod php5.6 // отключаем старую версию пыхи в апаче
sudo a2enmod php7.1 // включаем новую версию пыхи в апаче
sudo update-alternatives --set php /usr/bin/php7.1 // выставляем версию cli
sudo service apache2 restart

V
Vitaliy Jakim, 2019-11-05
@Jakim

For Nginx

cd /etc/nginx/sites-available/
sudo nano your_domain.com
 location ~ \.php$ {
       fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # какую версию читать для сайта your_domain.com выбрать можно любую с установленых на серваке
    }

For Apache2
sudo apt install php7.2 php7.2-fpm # установили php версию нужную для определенного домена
###
sudo a2enmod actions fastcgi alias proxy_fcgi # Ubuntu старее 18.04
sudo a2enmod actions fcgid alias proxy_fcgi # Ubuntu 18.04
###
sudo nano /etc/apache2/sites-available/your_domain.com

<VirtualHost *:80>
    ServerName your_domain.com
    DocumentRoot /var/www/your_domain_folder
    <Directory /var/www/your_domain_folder>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/" # версия php которая нужна на этом домене
    </FilesMatch>
</VirtualHost>

S
Sanes, 2017-01-23
@Sanes

Below is a link to the repository with php-fpm+nginx sources

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question