1、安装依赖包
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp gmp-devel expat-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libcurl libcurl-devel curl curl-devel libmcrypt libmcrypt-devel libxslt libxslt-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmemcached-devel libzip readline readline-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
2、下载php并解压
wget https://www.php.net/distributions/php-7.4.1.tar.gz
tar -zvxf php-7.4.1.tar.gz
cd php-7.4.1/
3、编译
./configure --enable-inline-optimization --enable-debug --disable-rpath --enable-shared --enable-cgi --enable-sockets --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-bz2 --enable-soap --with-openssl --with-openssl-dir --with-curl --enable-mbstring --with-zlib --with-zlib-dir --enable-opcache --with-gd --enable-gd-jis-conv --with-gettext --with-pcre-dir --with-pcre-regex --with-pcre-dir --with-png-dir --with-freetype-dir --enable-calendar --enable-ftp --with-xml --with-xmlrpc --with-mhash --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-readline --with-iconv --enable-pcntl --enable-zip --with-pear --enable-bcmath --enable-ctype --enable-tokenizer --with-libxml --with-libxml-dir
执行./configure出现的问题(部分)
##########
问题1:
问题1方法:安装sqlite-devel
问题2:能安装oniguruma,却没法安装oniguruma-devel
问题2方法:重新安装oniguruma,具体方法见" 附 "
问题3:configure: error: Please reinstall readline - I cannot find readline.h
方法:yum install -y readline-devel
#############
make && make install
php -v
4、设置php
cp php.ini-production /usr/local/lib/php.ini
注:php --ini默认哪个目录就放哪个目录,不然扩展加到php.ini没效果
cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
5、设置/etc/init.d/php-fpm启动
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
6、设置systemctl启动
vi /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/var/run/php-fpm.pid
ExecStart=/usr/local/sbin/php-fpm
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
同时开启php-fpm.conf中的pid=/var/run/php-fpm.pid
systemctl enable php-fpm (设置开机自启)
注意:将/usr/local/etc/php-fpm.conf的最后一行include=NONE/etc/php-fpm.d/*.conf的NONE去掉,改成 include=/usr/local/etc/php-fpm.d/*.conf的
附:
安装oniguruma出现的问题1、下载并解压
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gztar -zxf oniguruma-6.9.4.tar.gzcd oniguruma-6.9.4
2、编译
./autogen.sh && ./configure --prefix=/usr
make && make install
注意:编译onigurum的过程中需安装automake和libtool
参考地址:
https://blog.csdn.net/uisoul/article/details/86631469
https://www.24kplus.com/linux/1614.html
https://stackoverflow.com/questions/18978252/error-libtool-library-used-but-libtool-is-undefined
网友评论