Ubuntu安装PHP和PHP Nginx配置方法
最近接手了一个 PHP 项目,之前没做过 PHP,于是从搭建PHP环境开始学习下,同时写篇 Ubuntu 安装 PHP 的教程。
一、删除遗留的PHP包
sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "` sudo apt autoremove
二、添加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
三、安装PHP
PHP 5.6 版本
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 版本
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
四、Nginx配置
# 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) { return 404; } 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; }
相关推荐
Phplayers 2020-09-05
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23