Yêu cầu thg 12 21, 2017 4:35 SA 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 thg 12 21, 2017 6:32 SA
Đã đượ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
thg 12 25, 2017 3:49 SA

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

thg 12 28, 2017 8:42 CH

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
thg 1 8, 2018 7:10 SA

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 thg 3 24, 2018 11:03 SA
+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ẻ
thg 11 14, 2018 2:29 SA

quá hay ạ (like)

Đã trả lời thg 1 29, 2018 8:37 SA
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í