如何全面掌握PHP7在开发机上的安装与使用技巧?

2026-04-03 11:311阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计627个文字,预计阅读时间需要3分钟。

如何全面掌握PHP7在开发机上的安装与使用技巧?

以下是对原文的简化

如何全面掌握PHP7在开发机上的安装与使用技巧?

下载并安装PHP 7.0.7:

1.创建目录:$ mkdir php7test

2.进入目录:$ cd php7test

3.下载PHP:$ wget http://cn2.php.net/get/php-7.0.7.tar.gz/from/this/mirror

4.解压:$ tar -zxvf php-7.0.7.tar.gz

5.进入安装目录:$ cd php-7.0.7

6.安装依赖:$ yum -y install libjpeg libpng freetype libxml2 libxml2-devel openssl

下载7:

$ cd $ mkdir php7test $ cd php7test $ wget cn2.php.net/get/php-7.0.7.tar.gz/from/this/mirror $ tar -zxvf php-7.0.7.tar.gz $ cd php-7.0.7

安装一些依赖:

$ yum -y install libjpeg libpng freetype libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel curl-devel libxslt-devel lib2 lib2-devel

配置configure

$ ./configure --prefix=/data/php7 --with-config-file-path=/data/php7/etc --with-config-file-scan-dir=/data/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=xxxxxxxxxx --with-fpm-group=xxxxxxxxxx --with-gd --with-iconv --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --with-zlib --enable-bcmath --enable-sockets

然后:

$ make $ make install

默认安装好之后,你会发现/data/php7/etc下面没有php.ini文件,这个去哪里要呢?在php7的源码安装包都有。

进入源码安装包的目录

$ cd $ cd php7test/php-7.0.7 $ ls

可以看到有两个php.ini-xxx的文件

$ cp php.ini* /data/php7/etc/ $ cp php.ini-production /data/php7/etc/php.ini

启用php-fpm

先配置config文件

$ cd /data/php7/etc $ cp php-fpm.conf.default php-fpm.conf $ cp php-fpm.d/www.conf.default php-fpm.d/www.conf

在编译之前./configure的时候,我们都已经确定了一些配置,比如运行fpm的用户和用户组之类的,所以默认配置应该不会存在路径问题和权限问题。

搞定php-fpm的服务载入

我们希望使用service php-fpm start|stop|restart这些操作来实现服务的重启,但没有像nginx那么复杂,php编译好之后,给我们提供了一个php-fpm的程序,不需要我再编写分享了。这个文件放在php编译源码目录中:

$ cd $ cd php7test/php-7.0.7/sapi/fpm $ cp init.d.php-fpm /etc/init.d/php-fpm $ chmod +x /etc/init.d/php-fpm $ chkconfig --add php-fpm $ chkconfig php-fpm on

通过上面这个操作,我们就可以使用sevice php-fpm start来启用php-fpm了。用ps -ef | grep php-fpm看看进程吧。

或者通过使用/data/php7/sbin/php-fpm来启动php7.

Finish & Success

推荐教程:《PHP7》

本文共计627个文字,预计阅读时间需要3分钟。

如何全面掌握PHP7在开发机上的安装与使用技巧?

以下是对原文的简化

如何全面掌握PHP7在开发机上的安装与使用技巧?

下载并安装PHP 7.0.7:

1.创建目录:$ mkdir php7test

2.进入目录:$ cd php7test

3.下载PHP:$ wget http://cn2.php.net/get/php-7.0.7.tar.gz/from/this/mirror

4.解压:$ tar -zxvf php-7.0.7.tar.gz

5.进入安装目录:$ cd php-7.0.7

6.安装依赖:$ yum -y install libjpeg libpng freetype libxml2 libxml2-devel openssl

下载7:

$ cd $ mkdir php7test $ cd php7test $ wget cn2.php.net/get/php-7.0.7.tar.gz/from/this/mirror $ tar -zxvf php-7.0.7.tar.gz $ cd php-7.0.7

安装一些依赖:

$ yum -y install libjpeg libpng freetype libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel curl-devel libxslt-devel lib2 lib2-devel

配置configure

$ ./configure --prefix=/data/php7 --with-config-file-path=/data/php7/etc --with-config-file-scan-dir=/data/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=xxxxxxxxxx --with-fpm-group=xxxxxxxxxx --with-gd --with-iconv --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --with-zlib --enable-bcmath --enable-sockets

然后:

$ make $ make install

默认安装好之后,你会发现/data/php7/etc下面没有php.ini文件,这个去哪里要呢?在php7的源码安装包都有。

进入源码安装包的目录

$ cd $ cd php7test/php-7.0.7 $ ls

可以看到有两个php.ini-xxx的文件

$ cp php.ini* /data/php7/etc/ $ cp php.ini-production /data/php7/etc/php.ini

启用php-fpm

先配置config文件

$ cd /data/php7/etc $ cp php-fpm.conf.default php-fpm.conf $ cp php-fpm.d/www.conf.default php-fpm.d/www.conf

在编译之前./configure的时候,我们都已经确定了一些配置,比如运行fpm的用户和用户组之类的,所以默认配置应该不会存在路径问题和权限问题。

搞定php-fpm的服务载入

我们希望使用service php-fpm start|stop|restart这些操作来实现服务的重启,但没有像nginx那么复杂,php编译好之后,给我们提供了一个php-fpm的程序,不需要我再编写分享了。这个文件放在php编译源码目录中:

$ cd $ cd php7test/php-7.0.7/sapi/fpm $ cp init.d.php-fpm /etc/init.d/php-fpm $ chmod +x /etc/init.d/php-fpm $ chkconfig --add php-fpm $ chkconfig php-fpm on

通过上面这个操作,我们就可以使用sevice php-fpm start来启用php-fpm了。用ps -ef | grep php-fpm看看进程吧。

或者通过使用/data/php7/sbin/php-fpm来启动php7.

Finish & Success

推荐教程:《PHP7》