Home >Backend Development >PHP Tutorial >A quick way to install PHP on Ubuntu or CentOS
Install PHP on Ubuntu
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:ondrej/php $ sudo apt-get update $ sudo apt-get install php8.1 $ sudo apt-get install php8.1-mysql php8.1-curl php8.1-json php8.1-dev php8.1-mbstring php8.1-ctype php8.1-dom php8.1-gd php8.1-openssl php8.1-simplexml php8.1-xml php8.1-fpm php8.1-opcache php8.1-cli php8.1-apcuIf you need to install other extensions, execute sudo apt-get install php8.1-xxxx (extension). If you install PHP7.3, please replace the above php8.1 with php7.3.
Installing PHP on CentOS
$ sudo yum install epel-release $ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm $ sudo yum install yum-utils $ sudo yum-config-manager --enable remi-php81 $ sudo yum update $ sudo yum install php81 $ sudo yum install php81-php-fpm php81-php-gd php81-php-json php81-php-mbstring php81-php-mysqlnd php81-php-xml php81-php-xmlrpc php81-php-opcache php81-php-devel php81-php-cli php81-php-apcu php81-php-curl php81-php-dom $ sudo systemctl enable php81-php-fpm.service $ sudo systemctl start php81-php-fpm.serviceIf you need to install other extensions, just execute sudo yum install php81-php-xxxx (extension). If you install PHP7.3, please replace the above php81 with php73. Recommended learning: "
PHP Video Tutorial"
The above is the detailed content of A quick way to install PHP on Ubuntu or CentOS. For more information, please follow other related articles on the PHP Chinese website!