周梦康 发表于 2016-11-09 6580 次浏览

因为我早就升级到 PHP7 了,但是最近又有之前09年的程序需要挪够来跑,发现很多函数都删了,根本不支持,所以我得重新装个 PHP5 ,所以有了下面的笔记哈。就不做注释了。自己分析下。

# wget -c --progress=bar:force http://cn2.php.net/get/php-5.3.29.tar.gz/from/this/mirror
# tar zxf php-5.3.29.tar.gz

# cd php-5.3.29

# ./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=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-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo

# make ZEND_EXTRA_LIBS='-liconv'
# make install

# cp php.ini-production /usr/local/php5/etc/php.ini
# sed -i 's/post_max_size =.*/post_max_size = 50M/g' /usr/local/php5/etc/php.ini
# sed -i 's/upload_max_filesize =.*/upload_max_filesize = 50M/g' /usr/local/php5/etc/php.ini
# sed -i 's/;date.timezone =.*/date.timezone = PRC/g' /usr/local/php5/etc/php.ini
# sed -i 's/;cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/g' /usr/local/php5/etc/php.ini
# sed -i 's/max_execution_time =.*/max_execution_time = 300/g' /usr/local/php5/etc/php.ini
# sed -i 's/magic_quotes_gpc =.*/;magic_quotes_gpc = On/g' /usr/local/php5/etc/php.ini
# sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /usr/local/php5/etc/php.ini

# cp sapi/fpm/init.d.php-fpm /etc/init.d/php5-fpm
# chmod +x /etc/init.d/php5-fpm

# cd /usr/local/php5/etc
# vim php-fpm.conf
[global]
pid = /usr/local/php5/var/run/php-fpm.pid
error_log = /data/log/php5-fpm.log
log_level = notice

[www]
listen = /tmp/php5-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = /data/log/php5-slow.log

最后我就可以使用/etc/init.d/php5-fpm start 来启动了

# netstat -lanp|grep php
unix  2      [ ACC ]     STREAM     LISTENING     478466602 717/php-fpm         /tmp/php5-cgi.sock  # php5
unix  2      [ ACC ]     STREAM     LISTENING     443683763 9207/php-fpm        /tmp/php-cgi.sock   # php7



如果没有liconv

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure -prefix=/usr/local
make
make install


评论列表