今天看到鸟哥发微博说php7 beta1测试版发布了,于是赶紧就去抢先下载,把自己的开发环境也升级到PHP7去,话不多少,下面就一起来搞起吧。。。
首先你得去官网下载php7 beta1的版本
这里由于我是在mac上安装,所以就去下载linux相关的版本,地址也直接附上了
php7 beta1
windows版的官方也有发布详情猛戳:这里
解压安装包,进入源代码目录
tar -zxvf php-7.0.0beta1.tar.gz
cd php-7.0.0beta1
建立配置
./buildconf --force
./configure --prefix=/usr/local/php7 --with-apxs2=/usr/sbin/apxs --enable-fpm --with-fpm-user=www--with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr--enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
这里列出以下我编译过程遇到的错误和解决办法:
configure: error: Cannot locate header file libintl.h
安装 gettext
sudo brew install gettext
编辑 configure 文件,找到 $PHP_GETTEXT /usr/local /usr 在后面加上gettext的路径
重新配置即可【后面参数和上面一样,这里省略了】
我这里可能是因为之前就装过php7 alpha版本,所以错误会少一点,不过大家过程中有什么错误的话,直接贴出来大家一起研究了。
编译
make
#
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
directorygraphiterator.inc
directorytreeiterator.inc
invertedregexiterator.inc
pharcommand.inc
phar.inc
Build complete.
Don't forget to run 'make test'.
#
这里会持续一段时间,一般是不会出现什么错误的,除非你人品的问题了。。。
安装
sudo make install
上面的步骤都顺利的话,这一步做起来就是那么的简单了,但是安装过程的信息要记得留意一下,后面配置会需要。。。
命令行测试
/usr/local/php7/bin7 -v
#为了以后事业方便,直接替换系统默认的php命令
#当人你也可以备份一下,我这里直接覆盖算求了。。。
sudo cp /usr/local/php7/bin/ph* /usr/bin/
毫无违和感,运行的如此流程,哈哈!
配置apache
打开apache的配置文件httpd.conf,找到原来的LoadModule php5_module这里,直接注释掉,下面加入LoadModule php7_module /usr/libexec/apache2/libphp7.so,最后如下:
sudo vim /etc/apache2/httpd.conf
...
#LoadModule php5_module libexec/apache2/libphp5.so
LoadModule php7_module /usr/libexec/apache2/libphp7.so
...
重启apache,然后测试一把看看
惊奇的发现,php文件直接输出到浏览器了。。。
感觉是apache不知道要解析php文件了!!!
这里我排查了好久,发现切换成php5版本就没问题,php7就无法解析???
最后才发现apache在解析php的适合是判断了模块的,例如ifModule php5_module这样,在httpd.conf里面找到这一句:Include /private/etc/apache2/other/*.conf,进入到该目录一看,你就明白了...
里面有一个php5.conf文件,那是不是php7的就该对应一个php7的文件呢,于是赶紧复制一份,打开这个文件,看到类似php5_module的字样,直接替换成php7_module即可,相关内容如下:
#httpd.conf改动 ... <IfModule php5_module> Include /private/etc/apache2/other/php5.conf </IfModule> <IfModule php7_module> Include /private/etc/apache2/other/php7.conf </IfModule> #Include /private/etc/apache2/other/*.conf ... #php7.conf内容 <IfModule php7_module> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> </IfModule>
最后再次重启apache,测试一下
sudo apachectl restart
久违的画面出现了。。。
以上所述就是本文的全部内容了,希望大家能够喜欢。

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

PHPisusedforsendingemailsduetoitsbuilt-inmail()functionandsupportivelibrarieslikePHPMailerandSwiftMailer.1)Usethemail()functionforbasicemails,butithaslimitations.2)EmployPHPMailerforadvancedfeatureslikeHTMLemailsandattachments.3)Improvedeliverability

PHP performance bottlenecks can be solved through the following steps: 1) Use Xdebug or Blackfire for performance analysis to find out the problem; 2) Optimize database queries and use caches, such as APCu; 3) Use efficient functions such as array_filter to optimize array operations; 4) Configure OPcache for bytecode cache; 5) Optimize the front-end, such as reducing HTTP requests and optimizing pictures; 6) Continuously monitor and optimize performance. Through these methods, the performance of PHP applications can be significantly improved.

DependencyInjection(DI)inPHPisadesignpatternthatmanagesandreducesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itallowspassingdependencieslikedatabaseconnectionstoclassesasparameters,facilitatingeasiertestingandscalability.

CachingimprovesPHPperformancebystoringresultsofcomputationsorqueriesforquickretrieval,reducingserverloadandenhancingresponsetimes.Effectivestrategiesinclude:1)Opcodecaching,whichstorescompiledPHPscriptsinmemorytoskipcompilation;2)DatacachingusingMemc


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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools
