Skip to content

Instantly share code, notes, and snippets.

@UbuntuEvangelist
Last active April 7, 2022 17:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save UbuntuEvangelist/cbfe9d6d8a8c67109d175ec0a74047f8 to your computer and use it in GitHub Desktop.
Save UbuntuEvangelist/cbfe9d6d8a8c67109d175ec0a74047f8 to your computer and use it in GitHub Desktop.
Switch php versions on commandline ubuntu
# Install PHP & check version
apt install software-properties-common
add-apt-repository ppa:ondrej/apache2
apt update -y
apt upgrade -y
# For php7.3 (use any)
apt install -y php7.3
apt install libapache2-mod-php7.3 php7.3 unzip php7.3-xml php7.3-mysql php7.3-imap php7.3-zip php7.3-intl php7.3-curl ntp -y
# For php7.4 (use any)
apt install -y php7.4
apt install php7.4-{cli,fpm,json,common,mysql,zip,gd,mbstring,curl,xml,bcmath,imap,intl}
systemctl status php7.4-fpm
php --version
which php
whereis php
nano /etc/php/7.4/apache2/php.ini
# Find this lines by ctrl+w and change same as below:
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 1024M
upload_max_filesize = 1024M
max_execution_time = 3600
date.timezone = UTC+6
ctrl+s and ctrl+x
apt update -y
apt upgrade -y
# SWITCH PHP VERSION
update-alternatives --config php
# Choose the appropriate version
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/php7.4 74 auto mode
1 /usr/bin/php7.3 73 manual mode
2 /usr/bin/php7.4 74 manual mode
@UbuntuEvangelist
Copy link
Author

Screenshot from 2021-05-10 18-13-16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment