首先安装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
####################################
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; } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。