Skip to content

Instantly share code, notes, and snippets.

@alpipego
Forked from hollodotme/Install-php7.md
Last active August 31, 2018 08:24
Show Gist options
  • Save alpipego/9f353c8d19c7652b528a to your computer and use it in GitHub Desktop.
Save alpipego/9f353c8d19c7652b528a to your computer and use it in GitHub Desktop.
Server Setup

Install packages

sudo apt-get -y install nginx curl libcurl3 libcurl3-dev git redis-server

Install php7.2

Ubuntu

# add php-7.x source list by [Ondřej Surý](https://github.com/oerdnj)
sudo add-apt-repository ppa:ondrej/php

Debian

sudo apt install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Step 2

# Update index
sudo apt-get update
# Install php7.2-fpm with needed extensions
sudo apt-get install php7.2-fpm php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-mysql php7.2-recode php7.2-tidy php7.2-dev php7.2-intl php7.2-snmp php7.2-curl php7.2-phpdbg php7.2-mbstring php7.2-zip php7.2-soap php7.2-xml

Install composer

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

Install imagick/imagemagick

sudo apt-get install libmagickwand-dev imagemagick
sudo pecl install imagick

You should add extension=imagick.so to php.ini (/etc/php/7.2/fpm/php.ini)

Install Xdebug

sudo pecl install xdebug

You should add "zend_extension=/usr/lib/php/XXXXXXXX/xdebug.so" to php.ini

Add to php.ini (/etc/php/7.2/fpm/php.ini):

[xdebug]
zend_extensions={$PATH_ABOVE}
xdebug.default_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_enable=1
xdebug.remote_port=18000
xdebug.remote_connect_back=1

Restart services

@alpipego
Copy link
Author

alpipego commented Sep 8, 2017

If there are problems with the locale

Set the correct language locale

sudo apt-get update; sudo apt-get install -y language-pack-en-base
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8

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