Linux CentOS 7 安装配置 Php5.4.45
1 安装依赖包
yum install -y gcc gcc-c++ \ libxml2 libxml2-devel \ openssl openssl-devel \ bzip2 bzip2-devel \ curl curl-devel \ libjpeg libjpeg-devel \ freetype freetype-devel \ gmp gmp-devel \ icu libicu libicu-devel \ php-mcrypt libmcrypt libmcrypt-devel \ unixODBC unixODBC-devel \ libpng libpng-devel \ libxslt-devel gettext zlib pcre
2 编译安装
2.1 下载 Php5.4.45
cd /opt wget http://sg2.php.net/distributions/php-5.4.45.tar.gz tar zxf php-5.4.45.tar.gz cd php-5.4.45
2.2 编译安装
./configure \ --prefix=/opt/web_engine/php \ --with-config-file-path=/opt/web_engine/php/etc \ --with-gettext \ --with-gmp \ --with-mysql \ --with-openssl \ --with-pdo-mysql \ --with-bz2 \ --with-curl \ --with-mcrypt \ --with-mhash \ --with-freetype-dir \ --with-unixODBC=/usr/ \ --with-pdo-odbc=unixODBC,/usr/ \ --with-libxml-dir \ --with-zlib \ --with-pcre-dir \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-xmlrpc \ --with-libxml-dir \ --with-xsl \ --enable-soap \ --enable-sysvmsg \ --enable-wddx \ --enable-zip \ --enable-exif \ --enable-intl \ --enable-bcmath \ --enable-calendar \ --enable-mbstring \ --enable-shmop \ --enable-fpm \ --enable-sockets make && make install
3 Php 配置
3.1 配置文件
cp /opt/php-5.4.45/php.ini-production /opt/web_engine/php/etc cd /opt/web_engine/php/etc && cp php.ini-production php.ini cd /opt/web_engine/php/etc && cp php-fpm.conf.default php-fpm.conf
3.2 配置环境变量
vi /etc/profile # 文件末尾添加 PHP_BIN=/opt/web_engine/php/bin PATH=$PATH:$PHP_BIN
3.3 检查版本
php -v # 查看详细信息 php -i
输出为下:
php -v PHP 5.4.45 (cli) (built: Sep 12 2020 23:54:49) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
4 Systemd 配置
4.1 添加服务单元文件
vim /usr/lib/systemd/system/php-fpm.service [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=simple PIDFile=/opt/web_engine/php/var/run/php-fpm.pid ExecStart=/opt/web_engine/php/sbin/php-fpm --nodaemonize --fpm-config /opt/web_engine/php/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPIDe [Install] WantedBy=multi-user.target
4.2 启动并配置开机启动
systemctl enable --now php-fpm.service