系统相关
首页 > 系统相关> > 安装PHP到Ubuntu(APT)

安装PHP到Ubuntu(APT)

作者:互联网

运行环境

系统版本:Ubuntu 16.04.2 LTS
软件版本:PHP-5.6
硬件要求:无

安装过程

1、安装APT存储库

APT存储库由PPA提供。

root@localhost:~# apt-get install python-software-properties
root@localhost:~# add-apt-repository ppa:ondrej/php
root@localhost:~# apt-get update

2、安装PHP5.6和常用扩展库

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 

3、启动PHP-FPM服务

root@localhost:~# systemctl start php5.6-fpm

4、配置Nginx反代PHP

root@localhost:~# vim /etc/nginx/conf.d/php56
server {
        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.0-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /home/mk/wstmart$fastcgi_script_name;
            include        fastcgi_params;
        }
}

标签:index,PHP,APT,fastcgi,localhost,Ubuntu,php5.6,root,php
来源: https://www.cnblogs.com/network-ren/p/12378268.html