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中文網其他相關文章!