Ubuntu install PHP and PHP Nginx configuration method

I recently took over a PHP project. I haven't done PHP before, so I started to learn from building a PHP environment and wrote a tutorial on how to install PHP on Ubuntu.

1. Delete the legacy PHP package

sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
sudo apt autoremove

Two, add PPA

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update

Three, install PHP

PHP 5.6 version

sudo apt-get install php5.6 php5.6-cli
sudo apt-get install php5.6-dev php5.6-fpm php5.6-cgi
sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-gd php5.6-curl php5.6-memcache

PHP 7.1 version

sudo apt-get install php7.1 php7.1-cli
sudo apt-get install php7.1-dev php7.1-fpm php7.1-cgi
sudo apt-get install php7.1-mysql php7.1-gd php7.1-curl php7.1-memcache

Four, Nginx configuration

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~[^/]\.php(/|$){
 fastcgi_split_path_info ^(.+?\.php)(/.*)$;if(!-f $document_root$fastcgi_script_name){return404;}
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 # fastcgi_pass unix:/run/php/php5.6-fpm.sock;
 fastcgi_pass unix:/run/php/php7.1-fpm.sock;
 fastcgi_index index.php;
 include fastcgi_params;}

The above is the whole content of this article, I hope it will be helpful to everyone's study.

Recommended Posts

Ubuntu install PHP and PHP Nginx configuration method
Ubuntu16.04 install SVN and configuration
Nginx installation and configuration load (ubuntu12.04)
How to compile and install PHP and Nginx in Ubuntu environment
ubuntu install nginx server
[Linux] ubuntu install configuration vsftpd and lock the directory
CentOs7.3 compile and install Nginx 1.9.9
ubuntu18.04 compile and install python3.8
Ubuntu16.04 installation and simple configuration
Ubuntu16.04 install and uninstall VMware-Workstation 14
Ubuntu PostgreSQL installation and configuration
[Daily] Install php pdo extension and import database under ubuntu
CentOS 8 install Git and basic configuration
Ubuntu environment variables and ADB configuration
How to install Nginx on Ubuntu 20.04
CentOS 7 install Nginx, PHP, MySQL packages
Install and configure MySQL on Ubuntu
Ubuntu 18.04 install Sogou input method notes
CentOS 6.x compile and install Nginx
Install and configure Docker in Ubuntu
CentOS7.2 and Nginx configuration virtual host
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Install and deploy Gerrit under Ubuntu
Install nodejs and npm under Ubuntu 16.04
Install Sogou input method on Ubuntu 16
How to install Nginx on Ubuntu 20.04
Ubuntu 19.1 installation and configuration Chinese environment
How to install Nginx on Ubuntu 16.04
Configuration and beautification after Ubuntu installation (1)
Centos install php73 fast cgi + nginx
Nginx-ubuntu install Nginx and configure https
Ubuntu configuration source and installation software
Compile and install QEMU under Ubuntu
[Daily] Win10 open and install ubuntu subsystem
Ubuntu install Elasticsearch and elasticsearch-analysis-ik word segmentation
JDK environment variable configuration method under ubuntu
Install docker on ubuntu and basic usage
Installation and deployment of Nginx in Ubuntu
Install fonts on Ubuntu and switch default fonts
Ubuntu 18.04 source code compile and install ffmpeg4.1
Ubuntu17.04 configuration method to replace domestic sources
Install Sogou input method on Ubuntu Kylin 14.04
Install and uninstall CUDA and CUDNN on Ubuntu
Deploy python3 and nginx projects on ubuntu18.04
Linux install Docker and run Ubuntu system
Ubuntu install ftp server and possible problems
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
How to install Ubuntu20.04 and install NVIDIA driver
Configure Nginx + PHP 7.0 + MySQL environment under Ubuntu 16.04
How to install Pycharm and Ipython on Ubuntu 16.04/18.04
Install JDK and configure environment variables on Ubuntu 16.04
ubuntu 18.04 early configuration
How to install and configure Gogs on Ubuntu 18.04
Centos7.3 install nginx
ubuntu18.04 install python2
How to install and configure Cyberpanel on Ubuntu 18.04
ubuntu18.04 install docker
How to install and secure phpMyAdmin on Ubuntu 16.04
How to install and configure ownCloud on Ubuntu 16.04
How to install and configure ownCloud on Ubuntu 16.04
ubuntu12.04 install python3