Centos 7 php-7.1.19 编译安装

安装php依赖包

yum install -y epel-release
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel  gcc  libmcrypt-devel -y

下载php7.1.19安装包 

wget http://cn2.php.net/distributions/php-7.1.19.tar.gz

 解压安装

tar -zxvf php-7.1.19.tar.gz

cd php-7.1.19
./configure  --prefix=/opt/php-7.1.19  --with-config-file-path=/opt/php-7.1.19/etc  --with-config-file-scan-dir=/opt/php-7.1.19/etc/conf.d  --enable-fpm  --with-fpm-user=www  --with-fpm-group=www  --enable-inline-optimization  --disable-debug  --disable-rpath  --enable-shared  --enable-soap  --with-xmlrpc  --with-openssl  --with-mcrypt  --with-pcre-regex  --with-sqlite3  --with-zlib  --enable-bcmath  --with-iconv  --with-bz2  --enable-calendar  --with-curl  --with-cdb  --enable-dom  --enable-exif  --enable-fileinfo  --enable-filter  --with-pcre-dir  --enable-ftp  --with-gd  --with-openssl-dir  --with-jpeg-dir  --with-png-dir  --with-freetype-dir  --enable-gd-native-ttf  --enable-gd-jis-conv  --with-gettext  --with-gmp  --with-mhash  --enable-json  --enable-mbstring  --enable-mbregex  --enable-mbregex-backtrack  --with-libmbfl  --with-onig  --enable-pdo  --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd  --with-zlib-dir  --with-pdo-sqlite  --with-readline  --enable-session  --enable-shmop  --enable-simplexml  --enable-sockets  --enable-sysvmsg  --enable-sysvsem  --enable-sysvshm  --enable-wddx  --with-libxml-dir  --with-xsl  --enable-zip  --enable-mysqlnd-compression-support  --with-pear  --enable-opcache  --enable-maintainer-zts

make
make install

修改相关配置

strip /opt/php-7.1.19/bin/php
strip /opt/php-7.1.19/bin/phpdbg
strip /opt/php-7.1.19/sbin/php-fpm 

mkdir -p /opt/php-7.1.19/etc/{fpm,cli}.d
ln -s /opt/php-7.1.19/etc/fpm.d /opt/php-7.1.19/etc/conf.d
cp /opt/php-7.1.19/etc/pear.conf{,.original}
cp php.ini-* /opt/php-7.1.19/etc/
cp /opt/php-7.1.19/etc/php.ini-production /opt/php-7.1.19/etc/php.ini
cp /opt/php-7.1.19/etc/php.ini-production /opt/php-7.1.19/etc/php-cli.ini
cp /opt/php-7.1.19/etc/php-fpm.conf.default /opt/php-7.1.19/etc/php-fpm.conf
cp /opt/php-7.1.19/etc/php-fpm.d/www.conf.default /opt/php-7.1.19/etc/php-fpm.d/www.conf

yes|cp ./sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service 

systemctl daemon-reload
systemctl enable php-fpm

vim /opt/php-7.1.19/etc/php-fpm.conf <<end > /dev/null 2>&1
:17,17s/;pid/pid/
:24,24s/;error_log/error_log/
:85,85s/;rlimit_files = 1024/rlimit_files = 65536/
:wq
end

vim /opt/php-7.1.19/etc/php-fpm.d/www.conf <<end > /dev/null 2>&1
:107,107s/pm.max_children = 5/pm.max_children = 4096/
:112,112s/pm.start_servers = 2/pm.start_servers = 8/
:117,117s/pm.min_spare_servers = 1/pm.min_spare_servers = 8/
:122,122s/pm.max_spare_servers = 3/pm.max_spare_servers = 16/
:133,133s/;pm.max_requests = 500/pm.max_requests = 1024/
:232,232s/;pm.status_path/pm.status_path/
:244,244s/;ping.path/ping.path/
:249,249s/;ping.response/ping.response/
:330,330s/;request_terminate_timeout = 0/request_terminate_timeout = 30s/
:334,334s/;rlimit_files = 1024/rlimit_files = 40960/
:wq
end

#:15,15s/;//

vim /opt/php-7.1.19/etc/php.ini <<EOF > /dev/null 2>&1
:309,309s$;open_basedir =$open_basedir = /www/:/web/:/tmp/:/var/tmp/:/opt/php-7.1.19/lib/php/:/opt/php-7.1.19/bin/$
:374,374s/expose_php = On/expose_php = Off/
:404,404s/memory_limit = 128M/memory_limit = 16M/
:775,775s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/
:939,939s#;date.timezone =#date.timezone = Asia/Hong_Kong#
:1020,1020s#pdo_mysql.default_socket=#pdo_mysql.default_socket=/var/lib/mysql/mysql.sock#
:1355,1355s#;session.save_path = "/tmp"#session.save_path = "/dev/shm"#
:1381,1381s/session.name = PHPSESSID/session.name = JSESSIONID/
:wq
EOF

# PHP 7.1.3 Abandoned disable_functions
#:299,299s/disable_functions =/disable_functions = ini_set,set_time_limit,set_include_path,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket/
#s/max_execution_time = 30/max_execution_time = 300/g
#:706,706s!;include_path = ".:/php/includes"!include_path = ".:/opt/php-7.1.19/lib/php:/opt/php-7.1.19/share"!
#:728,728s!; extension_dir = "./"!extension_dir = "./:/opt/php-7.1.19/lib/php/extensions:/opt/php-7.1.19/lib/php/extensions/no-debug-non-zts-20121212"!
#:804,804s/upload_max_filesize = 2M/upload_max_filesize = 3M/

vim /opt/php-7.1.19/etc/php-cli.ini <<EOF > /dev/null 2>&1
:%s/memory_limit = 128M/memory_limit = 4G/g
:%s:;error_log = php_errors.log:error_log = php_errors.log:g
:%s:;date.timezone =:date.timezone = Asia/Hong_Kong:g
:wq
EOF

启动php7

systemctl start php-fpm

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编译 ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr /i nclude --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=www --with-fpm-group=www --without-gdbm --with-mcrypt=/usr/local/apps/libmcrypt --disable-fileinfo 报错:1, **configure: error: system libzip must be upgraded to version >=**0.11。 使用Yum最新版只到0.10,不足以达到要求。 一、先删除libzip yum remove libzip -y SSH执行以上命令,先删除libzip 和 libzip-devel 二、下载安装并手动编译 wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install 三、(可忽略)另外最新版本请参考官网:https://nih.at/libzip/ 1.5.0的libzip需要cmake wget https://libzip.org/download/libzip-1.5.0.tar.gz tar -zxvf libzip-* cd libzip* mkdir build && cd build && cmake .. && make && make install 报错2: error: off_t undefined; check your library configuration 根据报错信息分析 configure: error: off_t undefined; check your library configuration 未定义的类型 off_t。 off_t 类型是在 头文件 unistd.h中定义的,在32位系统 编程成 long int ,64位系统则编译成 long long int ,这里题主的系统应该是 64位的吧,在进行编译的时候 是默认查找64位的动态链接库,但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。 采用下面的方法。 添加搜索路径到配置文件 echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值