Home  >  Article  >  Backend Development  >  A quick way to install PHP on Ubuntu or CentOS

A quick way to install PHP on Ubuntu or CentOS

藏色散人
藏色散人forward
2022-10-14 14:27:382952browse

Install PHP

  • 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-apcu
If 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

The following is how to install PHP on CentOS 7

$ 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.service

If 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!

Statement:
This article is reproduced at:p2hp. If there is any infringement, please contact admin@php.cn delete