Ubuntu compile and install PHP

1. build environment:

sudo apt-get install \
build-essential \
gcc \
g++ \
autoconf \
libiconv-hook-dev \
libmcrypt-dev \
libxml2-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libjpeg8-dev \
libpng12-dev \
libfreetype6-dev \

2. Compile install php
cd php-5.6.22/
./configure --prefix=/usr/local/php \
--with-config-file-path=/etc/php \
--enable-fpm \
--enable-pcntl \
--enable-mysqlnd \
--enable-opcache \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-shmop \
--enable-zip \
--enable-soap \
--enable-xml \
--enable-mbstring \
--disable-rpath \
--disable-debug \
--disable-fileinfo \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pcre-regex \
--with-iconv \
--with-zlib \
--with-mcrypt \
--with-gd \
--with-openssl \
--with-mhash \
--with-xmlrpc \
--with-curl \
--with-imap-ssl

sudo make
sudo make install
sudo mkdir /etc/php
sudo cp php.ini-development /etc/php/php.ini


Note that the above PHP compiler option to adjust according to the actual situation.

3. Add PHP executable directory to the environment variable, use Vim / Sublime open ~ / .bashrc, add the following content.
export PATH=/usr/local/php/bin:$PATH
export PATH=/usr/local/php/sbin:$PATH
Once saved, the terminal enter the command:
source ~/.bashrc
此时即可通过php --version查看php版本。

Guess you like

Origin www.cnblogs.com/liuqd001/p/12033570.html