资讯详情

多版本PHP环境在nginx运行(php+nginx)及解决办法

多版本PHP环境在nginx运行(php nginx)

下载原基本环境

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

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

php-5.4.44版

 #wget http://cn2.php.net/get/php-5.4.44.tar.gz/from/this/mirror #tar zxvf php-5.4.44.tar.gz #cd php-5.4.44 #./configure --prefix=/usr/local/php5.4.44 \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysql \ --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-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip #make &&  make install #cp -R ./sapi/fpm/php-fpm.conf /usr/local/php5.4.44/etc/php-fpm.conf #cp php.ini-development /usr/local/php5.4.44/lib/php.ini #cp -R ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm5.4.44 

php-7.3.3版

安装编译php所需的依赖包: yum install -y php-devel gcc libXpm-devel 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  #wget http://cn2.php.net/distributions/php-7.3.3.tar.gz #tar -xzvf php-7.3.3.tar.gz 此处安装目录/usr/local/php7.3.3  

//安装php无论是否安装,依赖库和安装编译工具都可以执行

#yum -y install gcc gcc-c   #yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel #freetype-devel openldap-devel openldap openldap-devel #yum -y install libtool  进入php目录 cd php-7.3.3 #./configure --prefix=/usr/local/php7.3.3 --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl2 --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --disable-fileinfo --enable-opcache 

安装

make && make install #cp -R ./sapi/fpm/php-fpm.conf /usr/local/php7.3.3/etc/php-fpm.conf #cp php.ini-development /usr/local/php7.3.3//lib/php.ini #cp -R ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm733      

遇到这样的错误:/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to libiconv ’'/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to 'libiconv_close’ collect2: ld returned 1 exit status make: *** [sapi/cli/php] ?.. 1

vi Makefile 找到以下行: EXTRA_LIBS = -lcrypt ... 在最后添加-liconv 

安装完成后记得验证

您安装的目录/bin/php -v 

多版本安装的修改PHP的php-fpm.conf9001的侦听端口是9001

PHP5.4.4的路径在/usr/local/php5.4.4/etc/php-fpm.conf ; Note: This value is mandatory.   listen = 127.0.0.1:9001    PHP7.3.3修改方法# 编辑 php-fpm 配置文件,如果找不到可用的 `find / -name php-fpm.conf` 命令 vim /usr/local/php7.3.3/etc/php-fpm.conf # 去掉 `; pid = run/php-fpm.pid` 前面的分号注释,打开 pid 配置 vim /usr/local/php7.3.3/etc/php-fpm.d/www.conf  # (www.conf.default重命名或复制新名称www.conf)输入 /9000 回车,找到 listen = 127.0.0.1:9000 这一行将 9000 修改为 9074 

启动php-fpm

授权先复制给你的。php-fpm chmod  x /etc/init.d/php-fpm5.4.4 或 chmod  x /etc/init.d/php-fpm7.3.3 启动 #/etc/init.d/php-fpm5.4.44 或 #/etc/init.d/php-fpm7.3.3 

php成功检查安装过程

#ps aux|grep php 

配置Nginx(nginx的配置文件nginx.conf在/usr/local/nginx/conf) 将新的端口8054配置添加到9001(您配置的端口)和指定目录:

 server {         listen       8054;         server_name  localhost;         location / {             #root   html;   root /usr/www5.4.44;             index  index.html index.htm;         }  error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   html;         }  location ~ \.php$ {  root html;  fastcgi_pass 127.0.01:9074;
	fastcgi_index index.php;
	include fastcgi_params;
	fastcgi_param SCRIPT_FILENAME /usr/www5.4.44$fastcgi_script_name;
	}
    }

重启nginx

#/usr/local/nginx/sbin/nginx -s reload

问题:

依赖库错误:configure: error: xml2-config not found. Please check your libxml2 installation
解决办法:
yum install libxml2
yum install libxml2-devel -y

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
CentOS
yum install freetype-devel
Debian
apt-get install libfreetype6-dev

**yum install 安装出错错误...Setting up Install Process**
解决办法:yum install libxslt-devel* -y

可能出现的错误
configure: error: xml2-config not found. Please check your libxml2 installation.
解决办法是:yum install -y libxml2-devel

还有错误:configure: error: Cannot find OpenSSL’s <evp.h>
解决办法是:yum install -y openssl openssl-devel

错误:checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution
解决办法:yum install -y bzip2 bzip2-devel

错误:configure: error: png.h not found.
解决办法:yum install -y libpng libpng-devel

错误:configure: error: freetype.h not found.
解决办法:yum install -y freetype freetype-devel

错误:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法:
yum install -y epel-release
yum install -y libmcrypt-devel
因为 centos6 默认的 yum 源没有 libmcrypt-devel 这个包,只能借助 epel 的 yum 源。

错误:
configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:
Requested 'libxml-2.0 >= 2.9.0' but version of libXML is 2.7.6
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LIBXML_CFLAGS
and LIBXML_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决办法:




标签: oke继电器底座

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台