首先推荐一篇文章PHP 7 Release Date Arrived: Will Developers Adopt PHP 7? - PHP Classes blog。
里面说到是否会去使用PHP7,就个人而言,我是毫不犹豫地使用的,但是生产环境就不是我说了算,所以只能自己在自己的开发环境里更新PHP的版本。那么,你呢?
笔者使用的是Linux的openSUSE42.1发行版,Yast里面还没有PHP7的安装包,于是乎只能自己手动编译安装了。作为一个PHP开发者,我是非常希望能够学会编译安装PHP7的,之前试过几次,但是每次安装都要上网找各种资料,于是乎,这次安装成功后就想把自己的安装过程以及遇到的问题记录下来,方便以后查阅和分享给需要的人。
下载源码并解压
进入正题,要编译安装PHP7,首先当然要下载PHP7的源码。你可以到github上clone,也可以到PHP官网下载。下载后解压到 /usr/local/src 目录,并将目录重命名为php7。进入目录。
配置编译参数
生成配置文件
./buildconf
配置
./configure \ --prefix=/usr/local/php7 \ --exec-prefix=/usr/local/php7 \ --bindir=/usr/local/php7/bin \ --sbindir=/usr/local/php7/sbin \ --includedir=/usr/local/php7/include \ --libdir=/usr/local/php7/lib/php \ --mandir=/usr/local/php7/php/man \ --with-config-file-path=/usr/local/php7/etc \ --with-mysql-sock=/var/run/mysql/mysql.sock \ --with-mcrypt=/usr/include \ --with-mhash \ --with-openssl \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-gd \ --with-iconv \ --with-zlib \ --enable-zip \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-curl \ --with-jpeg-dir \ --with-freetype-dir \ --enable-opcache \ --enable-fpm \ --disable-cgi \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --without-gdbm \ --disable-fileinfo
参数说明
prefix PHP7安装的根目录
with-config-file-path PHP7的配置文件目录
执行完上面的配置命令后的结果如下图所示:
执行上面命令的过程中会遇到一些依赖缺少的提示,下面列出我遇到的依赖问题:
错误:
configure: error: xml2-config not found. Please check your libxml2 installation.
解决:
zypper install libxml2-devel
错误:
configure: WARNING: unrecognized options: --with-mysql
解决:
取消这个选项,这个选项是不存在的
错误:
configure: error: jpeglib.h not found.
解决:
zypper install libjpeg-devel
错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:
zypper install libmcrypt-devel
错误:
checking for recode support... yes
configure: error: Can not find recode.h anywhere under /usr /usr/local /usr /opt.
解决:
zypper install librecode-devel
总的来说,在配置的时候遇到没有的就打开Yast搜一下,如果有的话就安装,然后重新编译看还需要那些,如果在Yast找不到,那就上网找一下Google。
编译和安装PHP7
make && make install
其中,make之后可以选择make test。只是一个可选步骤,不执行不知道有什么问题,不过笔者暂时还没遇到。
查看安装成功后的PHP7目录
编译安装成功后,查看PHP7的安装目录`ls /usr/local/php7`:
设置PHP7的配置文件
cp /usr/local/src/php7/php.ini-production /usr/local/php7/etc/php.ini
cp /usr/local/src/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
设置环境变量
在/etc/profile 文件的最后一行加上
export PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH
然后执行 source /etc/profile
设置PHP日志目录和php-fpm进程文件(php-fpm.sock)目录
mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm
将PHP设置为开机启动
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on
可以用chkconfig命令查看开机启动服务列表。
启动PHP服务
service php-fpm start
通过ps aux | grep 'php'查看PHP是否启动成功
至此,PHP7就安装成功了,你也开始使用PHP7吧!
以上所述给大家介绍了在openSUSE42.1下编译安装PHP7 的方法,希望大家喜欢。

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools