Yêu cầu Dec 21st, 2017 4:35 a.m. 1186 1 3
  • 1186 1 3
0

Cài song song PHP 5.6.x với PHP 7.x như thế nào?

Chia sẻ
  • 1186 1 3

Chào mọi người. Tôi muốn cài song song 2 version php56 và php7 thì nên dùng tool gì để cài đặt. Khi nào dùng version nào thì switch sang. Cám ơn mọi người. Chúc mọi người có mùa giáng sinh vui vẻ. hihi

3 CÂU TRẢ LỜI


Đã trả lời Dec 21st, 2017 6:32 a.m.
Đã được chấp nhận
+3

Bạn có thể sử dụng phpenv để cài đặt nhiều version khác nhau, cũng như switch qua lại giữa các version một cách dễ dàng 😃

Chia sẻ
Avatar Truong Chi Nhan @zhangchinhan
Dec 25th, 2017 3:49 a.m.

Thanks bạn. để mình làm thử. hihi.

Dec 28th, 2017 8:42 p.m.

Bạn cài trên gì. Linux hay windows vậy bạn. WIndows thì dùng laragon có hướng dẫn switch sang. Linux thì xem bài này https://www.tecmint.com/install-different-php-versions-in-ubuntu/

Avatar kopitop @kopitop
Jan 8th, 2018 7:10 a.m.

Phpenv là 1 package đã khá cũ và lâu rồi ko được maintain Giải pháp là sử dụng docker là tốt nhất

Đã trả lời Mar 24th, 2018 11:03 a.m.
+2

Nếu trên ubuntu thì cứ cái bình thường thôi Thêm dòng sau vào file .bashrc alias php_switch='~/sh_ngocnd/php_switch.sh' php_switch.sh

#!/bin/bash

if [ $1 -eq 5 ]
then
    echo "Switch to php5"
    #Apache:-
    sudo a2dismod php7.0
    sudo a2dismod php7.1
    sudo a2enmod php5
    sudo service apache2 restart

    #Command Line:-
    sudo update-alternatives --set php /usr/bin/php5
    sudo update-alternatives --set phpize /usr/bin/phpize5
    sudo update-alternatives --set php-config /usr/bin/php-config5
fi

if [ $1 -eq 7 ]
then
    echo "Switch to php7"
    #Apache:-
    sudo a2dismod php5
    sudo a2dismod php7.1
    sudo a2enmod php7.0
    sudo service apache2 restart

    #Command Line:-
    sudo update-alternatives --set php /usr/bin/php7.0
    sudo update-alternatives --set phar /usr/bin/phar7.0
    sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.0
    sudo update-alternatives --set phpize /usr/bin/phpize7.0
    sudo update-alternatives --set php-config /usr/bin/php-config7.0
fi


if [[ $1 == "7.1" ]]
then
    echo "Switch to php7.1"
    #Apache:-
    sudo a2dismod php5
    sudo a2dismod php7.0
    sudo a2enmod php7.1
    sudo service apache2 restart

    #Command Line:-
    sudo update-alternatives --set php /usr/bin/php7.1
    sudo update-alternatives --set phar /usr/bin/phar7.1
    sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1
    sudo update-alternatives --set phpize /usr/bin/phpize7.1
    sudo update-alternatives --set php-config /usr/bin/php-config7.1
fi

Sau đó ở command chỉ cần chạy

$ php_switch 5

$ php_switch 7

$ php_switch 7.1

Chia sẻ
Nov 14th, 2018 2:29 a.m.

quá hay ạ (like)

Đã trả lời Jan 29th, 2018 8:37 a.m.
0

Đơn giản nhất là cài Wampserver nhé http://www.wampserver.com/en/

Chia sẻ
Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí