Skip to content

Instantly share code, notes, and snippets.

@rahilwazir
Last active September 22, 2021 19:32
Show Gist options
  • Save rahilwazir/74c6be0a452f505da8e1 to your computer and use it in GitHub Desktop.
Save rahilwazir/74c6be0a452f505da8e1 to your computer and use it in GitHub Desktop.
Quick guide to setup Nginx with PHP7-FPM and XDebug

PHP7

  • Ubuntu 16.04+
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install nginx php7.1-fpm php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-phpdbg php7.1-mbstring php7.1-gd php7.1-imap php7.1-ldap php7.1-pgsql php7.1-pspell php7.1-recode php7.1-soap php7.1-tidy php7.1-dev php7.1-intl php7.1-curl php7.1-zip php7.1-xml php-xdebug
  • Centos 7.x / Fedora 25.x
$ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
$ sudo yum/dnf install nginx php71w-fpm php71w-cli php71w-common php71w-json php71w-opcache php71w-mysql php71w-phpdbg php71w-mbstring php71w-gd php71w-imap php71w-ldap php71w-pgsql php71w-pspell php71w-recode php71w-soap php71w-tidy php71w-devel php71w-intl php71w-curl php71w-zip php71w-xml php71w-pecl-xdebug

# For remi repo
# Source: https://blog.remirepo.net/post/2016/12/05/Install-PHP-7.1-on-CentOS-RHEL-or-Fedora

$ wget http://rpms.remirepo.net/fedora/remi-release-25.rpm
$ sudo dnf install remi-release-25.rpm
$ dnf install dnf-plugins-core
$ dnf config-manager --set-enabled remi-php71
$ sudo dnf install -y php php-fpm php-cli php-common php-json php-opcache php-mysql php-mbstring php-gd php-imap php-ldap php-pgsql php-pspell php-recode php-soap php-tidy php-devel php-intl php-curl php-zip php-xml php-intl php-pecl-xdebug

Change PHP socket in www.conf or php-fpm.conf file to

/var/run/php/php7.1-fpm.sock

Paste the following to /etc/php/7.1/mods-available/xdebug.ini:

zend_extension=xdebug.so # If not already

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
xdebug.idekey = "PHPSTORM"

All done.

@rvaliev
Copy link

rvaliev commented May 31, 2016

Thanks! The php7.0-snmp gave me a lot of errors when executing php command in command line, so I've deleted it

@rahilwazir
Copy link
Author

@rvaliev Yes you are right, it does generate alot of warnings to the console. I have removed it.

@JeremyHutchings
Copy link

php7.1-gd twice ?

@rahilwazir
Copy link
Author

@rwhirn
Copy link

rwhirn commented Jan 13, 2019

Change PHP socket to

is kinda vague - what? where?

@rahilwazir
Copy link
Author

Change PHP socket to

is kinda vague - what? where?

See edit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment