Ubuntu16.04 php环境搭建

安装Nginx

  1. 安装
sudo apt-get install nginx -y
  1. 启动
sudo service nginx start
  1. 修改配置文件
sudo vim /etc/nginx/sites-available/default
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
fastcgi_pass 127.0.0.1:9000;
root /home/parallels/PhpstormProjects/test;
# With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}

安装PHP

  1. 安装
sudo apt-get install php -y
  1. 启动
/etc/init.d/php7.0-fpm start
  1. 修改配置文件
sudo vim /etc/php/7.0/fpm/pool.d/www.conf

使用tcp的方式与nginx通信

listen = /var/run/php/php7.0-fpm.sock 改为 listen = 127.0.0.1:9000

下载xdebug扩展

  1. 安装
sudo apt-get install php-xdebug
  1. 修改配置文件
sudo vim /etc/php/7.0/mods-available/xdebug.ini
zend_extension=xdebug.so
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "/tmp"
xdebug.remote_enable = 1
xdebug.remote_port = 9001
xdebug.remote_host = "www.paper.com"
  1. 重启
/etc/init.d/php7.0-fpm restart

配置phpstorm

  1. Settings -> Languages & Frameworks -> PHP -> PHP language level: 7 -> CLI Interpreter 点击…
  2. 点击+ -> PHP executable: /usr/bin/php
  3. 出现Debugger: Xdebug 2.4.0即配置完成

浏览器安装

chrome插件商店搜索xdebug安装