ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

在CentOS7上同时安装php704和php734

2022-06-05 01:04:25  阅读:275  来源: 互联网

标签:enable -- CentOS7 fpm php704 php734 php local usr


首先安装php704

1、安装依赖包

yum install libxml2 libxml2-devel openssl openssl-devel zip bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel ncurses-base ncurses-libs ncurses-devel libxslt libxslt-devel libgpg-error-devel libgcrypt-devel -y

 

2、下载php-7.0.4.tar.gz

cd /usr/local/src
wget http://cn2.php.net/distributions/php-7.0.4.tar.gz

 

3、编译安装

tar xf php-7.0.4.tar.gz
cd php-7.0.4
./configure --prefix=/usr/local/php704 --with-config-file-path=/etc --enable-fpm --with-fpm-user=nobody --with-fpm-group=nobody --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --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-zlib-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
make && make install

 

4、配置

cp /usr/local/src/php-7.0.4/php.ini-production /etc/php.ini
cp /usr/local/php704/etc/php-fpm.conf.default /usr/local/php704/etc/php-fpm.conf
cp /usr/local/php704/etc/php-fpm.d/www.conf.default /usr/local/php704/etc/php-fpm.d/www.conf
cp /usr/local/src/php-7.0.4/sapi/fpm/php-fpm.service /etc/systemd/system/
vim /etc/systemd/system/php-fpm.service
# 这里要修改php-fpm.service中的路径
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/usr/local/php704/var/run/php-fpm.pid
ExecStart=/usr/local/php704/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php704/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

注意,php-fpm的默认监听端口是9000,在配置文件/usr/local/php704/etc/php-fpm.d/www.conf中有写明。

 

5、启动php-fpm

systemctl start php-fpm

 

6、如果需要安装redis扩展

yum install autoconf -y
cd /usr/local/src
wget https://codeload.github.com/phpredis/phpredis/zip/develop
unzip develop
cd phpredis-develop/
/usr/local/php704/bin/phpize
./configure --with-php-config=/usr/local/php704/bin/php-config
make && make install


# 然后在/etc/php.ini中最底部加入redis.so
extension=redis.so

 

7、重启php-fpm即可

 

注意看:

编译时,指定的用户为nobody,那么你的php程序代码目录权限也要改为nobody,否则无法使用。

 

然后安装php734

1、下载php-7.3.4.tar.gz

cd /usr/local/src
wget http://cn2.php.net/distributions/php-7.3.4.tar.gz

 

2、安装libzip(如果需要zip压缩,则安装,否则可以跳过安装libzip)

cd /usr/local/src
wget https://nih.at/libzip/libzip-1.2.0.tar.gz --no-check-certificate
tar xf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure && make && make install
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64' >> /etc/ld.so.conf
ldconfig -v

 

3、编译安装php734

./configure --prefix=/usr/local/php734 --with-config-file-path=/etc --enable-fpm \
--with-fpm-user=nobody --with-fpm-group=nobody --enable-inline-optimization \
--disable-debug --disable-rpath --enable-shared --enable-soap --with-libxml-dir \
--with-xmlrpc --with-openssl --with-mcrypt --with-mhash --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-zlib-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
make && make install

 

4、配置

cp /usr/local/php734/etc/php-fpm.conf.default /usr/local/php734/etc/php-fpm.conf
cp /usr/local/php734/etc/php-fpm.d/www.conf.default /usr/local/php734/etc/php-fpm.d/www.conf
cp /usr/local/src/php-7.3.4/sapi/fpm/php-fpm.service /etc/systemd/system/php734-fpm.service

# 很奇怪,这次不用修改php734-fpm.service中的路径,路径已经自动填上了

注意,由于机器上的9000端口已经被占用了,所以要换个端口。

vim /usr/local/php734/etc/php-fpm.d/www.conf

 

5、启动

systemctl start php734-fpm

 

####################################

nginx配置文件

server {
    listen       8080;
    server_name  192.168.0.109;

    index index.html index.php;
    access_log /var/log/php/nginx_access.log;
    error_log  /var/log/php/nginx_error.log;
    client_max_body_size    500m;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        root /data/public;
        add_header Access-Control-Allow-Origin *;
        add_header X-debug-message "hey2";
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

 

标签:enable,--,CentOS7,fpm,php704,php734,php,local,usr
来源: https://www.cnblogs.com/t-road/p/16343164.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有