首页 >后端开发 >PHP问题 > 正文

php5.6.27安装教程

原创2021-06-24 10:06:100755

php5.6.27安装方法:首先安装编译工具,并添加php组和用户;然后安装依赖,添加扩展包,更新yum源;接着下载php并解压安装;最后配置PHP即可。

本文操作环境:centos7系统、php5.6.27版,DELL G3电脑

php5.6.27安装教程

centos7 编译安装php5.6.27

安装编译工具

yum -y install gcc gcc-c++

添加php组和用户,不创建home目录,不允许登陆系统

#-M, --no-create-home        不创建用户的主目录
#-g, --gid GROUP        新账户主组的名称或 ID
#-s, --shell SHELL        新账户的登录 shell
groupadd web
useradd -M -s /sbin/nologin -g web php

安装依赖,没有libmcrypt libmcrypt-devel mcrypt mhash的话,添加扩展包,更新yum源

yum -y install epel-release
yum -y update
yum -y install libmcrypt libmcrypt-devel mcrypt mhash
yum -y install libxml2-devel libpng-devel libjpeg-devel zlib bzip2 bzip2-devel \
libtool-ltdl-devel pcre-devel openssl-devel freetype-devel libcurl-devel icu \
perl-libintl postgresql libicu-devel

下载php解压

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

安装php

./configure \
--prefix=/usr/local/php5.6.27 \
--with-config-file-path=/usr/local/php5.6.27/etc/ \
--enable-inline-optimization \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=php \
--with-fpm-group=web \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--enable-intl \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--enable-xml \
--with-pcre-dir \
--with-gd \
--enable-static \
--enable-wddx \
--with-xmlrpc \
--with-libdir=/usr/lib64 \
--with-jpeg-dir=/usr/lib64 \
--with-freetype-dir=/usr/lib64 \
--with-png-dir=/usr/lib64
make && make install

配置 PHP

cp php.ini-development /usr/local/php5.6.27/etc/php.ini
cp /usr/local/php5.6.27/etc/php-fpm.conf.default /usr/local/php5.6.27/etc/php-fpm.conf

创建开机启动

vi /lib/systemd/system/php-fpmd.service
[Unit]
Description=The PHP FastCGI Process Manager
After=network.target
[Service]
Type=forking
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php5.6.27/sbin/php-fpm --daemonize -g /run/php-fpm.pid
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

PS:如果yum安装,php-fpm.service文件的内容

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=notify
PIDFile=/run/php-fpm.pid
EnvironmentFile=/etc/sysconfig/php-fpm
ExecStart=/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]

WantedBy=multi-user.target

添加运行权限

chmod +x /lib/systemd/system/php-fpmd.service

设置开机自启动

systemctl enable php-fpmd.service

运行

systemctl start php-fpmd.service

停止

systemctl stop php-fpmd.service

重新加载

systemctl daemon-reload

删除开机启动

systemctl disable php-fpmd.service

推荐学习:《PHP视频教程

以上就是php5.6.27安装教程的详细内容,更多请关注php中文网其它相关文章!

php中文网最新课程二维码

声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理

  • 相关标签:php5.6.27
  • 相关文章

    相关视频


    网友评论

    文明上网理性发言,请遵守 新闻评论服务协议

    我要评论
  • 专题推荐

    作者信息
    推荐视频教程
  • php8,我来也php8,我来也
  • 细说PHP(2021版)第一季细说PHP(2021版)第一季
  • 细说PHP(2021版)第二季细说PHP(2021版)第二季
  • 细说PHP(2021版)第三季细说PHP(2021版)第三季
  • 细说PHP(2021版)第四季细说PHP(2021版)第四季
  • 视频教程分类