系统版本:Ubuntu 16.04.2 LTS
软件版本:PHP-5.6
硬件要求:无
APT存储库由PPA提供。
root@localhost:~# apt-get install python-software-propertiesroot@localhost:~# add-apt-repository ppa:ondrej/phproot@localhost:~# apt-get update
root@localhost:~# apt-get -y install php5.6 php5.6-bcmach php5.6-fpm php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip php5.6-soap php5.6-xml
root@localhost:~# systemctl start php5.6-fpm
root@localhost:~# vim /etc/nginx/conf.d/php56server { listen 80; server_name _php; root "/var/www/html/"; location / { index index.php index.html; if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } } location ~ ^.*\.php(.*)$ { fastcgi_pass unix:/run/php/php7.2-fpm.sock; #连接到PHP-FPM,这里采用UNIX套接字的连接方式,设置由PHP-FPM提供的UNIX套接字文件路径。 fastcgi_index index.php; #设置PHP默认首页文件。 fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name; #设置FastCGI的一个环境变量"SCRIPT_FILENAME",设置FastCGI服务器读取的PHP入口文件完整路径。 include fastcgi_params; #包含当前配置目录下"fastcgi_param"文件中的所有配置,该文件中存储了一些默认配置FastCGI服务器的一些环境变量,这些变量都有特殊的作用,一般情况下无需修改。 }}