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