centos 7 php 安装
第一步,下载 php 安装包
第二步 ,安装编译时的依赖包
在安装之前,我们需要安装编译时所依赖的软件包。如下:
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
第三步
./configure –prefix=/usr/local/php \
–with-curl \
–with-freetype-dir \
–with-gd \
–with-gettext \
–with-iconv-dir \
–with-kerberos \
–with-libdir=lib64 \
–with-libxml-dir \
–with-mysqli \
–with-openssl \
–with-pcre-regex \
–with-pdo-mysql \
–with-pdo-sqlite \
–with-pear \
–with-png-dir \
–with-xmlrpc \
–with-xsl \
–with-zlib \
–enable-fpm \
–enable-bcmath \
–enable-libxml \
–enable-inline-optimization \
–enable-gd-native-ttf \
–enable-mbregex \
–enable-mbstring \
–enable-opcache \
–enable-pcntl \
–enable-shmop \
–enable-soap \
–enable-sockets \
–enable-sysvsem \
–enable-xml \
–enable-zip
报错:
mcrypt.h not found. Please reinstall libmcrypt
解决方法:
yum install php-mcrypt libmcrypt libmcrypt-devel
make
make test
make install
配置文件:
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp/usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
启动:
/etc/init.d/php-fpm
配置文件
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
参考博客:
linux 下安装 php 7.0