Centos+Nginx+PHP7.0缂栬瘧瀹夎(鍜孭HP5.6鑰佺増鏈叡瀛)

鍦烘櫙

LNMP
褰撳墠鐗堟湰锛歅HP 5.5.7
涓轰簡浣撻獙PHP7鐨勯熷害鍜屾ц兘锛屽姞涓婂鏂版妧鏈殑鐑》銆備絾鏄洿鎺ュ垏鎹㈡槸涓嶆槑鏅虹殑锛屽彲鑳戒細瀛樺湪浠g爜涓嶅吋瀹圭瓑绛夐棶棰橈紝鍥犳鍑嗗缂栬瘧瀹夎PHP7锛孨ginx鏍规嵁PHP-FastCGI鐩戝惉绔彛鍚敤鍝釜PHP鐗堟湰銆

浠涔堟槸FastCGI

FastCGI鏄竴涓彲浼哥缉鍦般侀珮閫熷湴鍦℉TTP server鍜屽姩鎬佽剼鏈瑷闂撮氫俊鐨勬帴鍙c
澶у鏁版祦琛岀殑HTTP server閮芥敮鎸丗astCGI锛屽寘鎷珹pache,Nginx鍜宭ighttpd绛
褰撶劧PHP涔熷湪鍏朵腑涔嬪垪浜嗐

FastCGI鎺ュ彛鏂瑰紡閲囩敤C/S缁撴瀯锛屽彲浠ュ皢HTTP鏈嶅姟鍣ㄥ拰鑴氭湰瑙f瀽鏈嶅姟鍣ㄥ垎寮锛屽悓鏃跺湪鑴氭湰瑙f瀽鏈嶅姟鍣ㄤ笂鍚姩涓涓垨澶氫釜鑴氭湰瑙f瀽瀹堟姢杩涚▼銆傚綋HTTP鏈嶅姟鍣ㄦ瘡娆¢亣鍒板姩鎬佺▼搴忔椂锛屽彲浠ュ皢鍏剁洿鎺ヤ氦浠樼粰FastCGI杩涚▼鏉ユ墽琛岋紝鐒跺悗灏嗗叾寰楀埌鐨勭粨鏋滆繑鍥炵粰娴忚鍣ㄣ

PHP鐗堟湰鍏卞瓨鎬濊矾

Nginx鏄氳繃PHP-FastCGI涓嶱HP杩涜浜や簰鐨勩傝孭HP-FastCGI杩愯鍚庝細閫氳繃鏂囦欢銆佹垨鏈湴绔彛涓ょ鏂瑰紡杩涜鐩戝惉锛屽湪Nginx涓厤缃浉搴旂殑FastCGI鐩戝惉绔彛鎴栨枃浠跺嵆瀹炵幇Nginx璇锋眰瀵筆HP鐨勮В閲娿

鏃㈢劧PHP-FastCGI鏄洃鍚鍙e拰鏂囦欢鐨勶紝閭e氨鍙互璁╀笉鍚岀増鏈殑PHP-FastCGI鍚屾椂杩愯锛岀洃鍚笉鍚岀殑绔彛鎴栨枃浠讹紝Nginx涓牴鎹渶姹傞厤缃皟鐢ㄤ笉鍚岀殑PHP-FastCGI绔彛鎴栨枃浠讹紝鍗冲彲瀹炵幇涓嶅悓鐗堟湰PHP鍏卞瓨浜嗐

缂栬瘧瀹夎杩囩▼

涓嬭浇瑙e帇PHP7

wget-c--no-check-certificate-O php7-src-master.zip https://github.com/php/php-src/archive/master.zip unzip-q php7-src-master.zip&&cd php-src-master

缂栬瘧瀹夎

娉ㄦ剰锛氳矾寰勬崲鎴愯嚜宸辩殑銆
鎴戞槸缂栬瘧鍒皊erver/php7涓嬮潰

./buildconf 鈥揻orce./configure \ 鈥損refix=/alidata/server/php7 \ 鈥揺xec-prefix=/alidata/server/php7 \ 鈥揵indir=/alidata/server/php7/bin \ 鈥搒bindir=/alidata/server/php7/sbin \ 鈥搃ncludedir=/alidata/server/php7/include \ 鈥搇ibdir=/alidata/server/php7/lib/php \ 鈥搈andir=/alidata/server/php7/php/man \ 鈥搘ith-config-file-path=/alidata/server/php7/etc \ 鈥搘ith-mysql-sock=/tmp/mysql.sock \ 鈥搘ith-mcrypt=/usr/include \ 鈥搘ith-mhash \ 鈥搘ith-openssl \ 鈥搘ith-mysql=shared,mysqlnd \ 鈥搘ith-mysqli=shared,mysqlnd \ 鈥搘ith-pdo-mysql=shared,mysqlnd \ 鈥搘ith-gd \ 鈥搘ith-iconv \ 鈥搘ith-zlib \ 鈥揺nable-zip \ 鈥揺nable-inline-optimization \ 鈥揺nable-sockets \ 鈥揺nable-soap \ 鈥揺nable-session \ 鈥搘ith-curl \ 鈥揺nable-opcache \ 鈥揺nable-fpm \ 鈥揺nable-fastcgi \ 鈥搘ith-fpm-user=www \ 鈥搘ith-fpm-group=www \ 鈥揹isable-fileinfo

鎵ц鍚庣粨鏋滃涓(鎳掞紝灏变笉鎴浘浜嗐傚搱鍝)锛
娉細鍥犱负涔嬪墠瀹夎杩嘝HP5鐗堟湰锛屾墍浠ヤ緷璧栧叧绯诲氨涓嶉渶瑕佷簡銆

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺+
Thank you for using PHP.
config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/www.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
configure: WARNING: unrecognized options: 鈥搘ith-mysql, 鈥揺nable-fastcgi

缂栬瘧&&瀹夎

make clean&&make&&make install

鎵ц缁撴灉濡備笅锛

nstalling shared extensions: /alidata/server/php7/lib/php/extensions/no-debug-non-zts-20151012/
Installing PHP CLI binary: /alidata/server/php7/bin/
Installing PHP CLI man page: /alidata/server/php7/php/man/man1/
Installing PHP FPM binary: /alidata/server/php7/sbin/
Installing PHP FPM config: /alidata/server/php7/etc/
Installing PHP FPM man page: /alidata/server/php7/php/man/man8/
Installing PHP FPM status page: /alidata/server/php7/php/php/fpm/
Installing phpdbg binary: /alidata/server/php7/bin/
Installing phpdbg man page: /alidata/server/php7/php/man/man1/
Installing PHP CGI binary: /alidata/server/php7/bin/
Installing PHP CGI man page: /alidata/server/php7/php/man/man1/
Installing build environment: /alidata/server/php7/lib/php/build/
Installing header files: /alidata/server/php7/include/php/
Installing helper programs: /alidata/server/php7/bin/
program: phpize
program: php-config
Installing man pages: /alidata/server/php7/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /alidata/server/php7/lib/php/php/

璁剧疆PHP7鐨勯厤缃枃浠

php.ini銆乸hp-fpm.conf銆亀ww.conf鍜宲hp-fpm鑴氭湰

cp php.ini-production/璺緞/php7/etc/php.ini #澶嶅埗php.ini閰嶇疆 cp sapi/fpm/init.d.php-fpm/etc/init.d/php7-fpm #澶嶅埗php-fpm鍚姩鑴氭湰 ##鍏朵粬閰嶇疆閮藉湪php7/etc/鐩綍涓嬶紝鑷淇敼閰嶇疆

鍚姩php7-fpm

chmod755/etc/init.d/php-fpm/etc/init.d/php7-fpm start

php-fpm鏀寔鐨勬搷浣滐細

  • start锛屽惎鍔≒HP鐨凢astCGI杩涚▼銆
  • stop锛屽己鍒剁粓姝HP鐨凢astCGI杩涚▼銆
  • quit锛屽钩婊戠粓姝HP鐨凢astCGI杩涚▼銆
  • restart锛 閲嶅惎PHP鐨凢astCGI杩涚▼銆
  • reload锛 閲嶆柊鍔犺浇PHP鐨刾hp.ini銆
  • logrotate锛 閲嶆柊鍚敤log鏂囦欢銆

娣诲姞PHP鐜鍙橀噺

echo-e'\nexport PATH=/璺緞/php7/bin:/璺緞/php7/sbin:$PATH\n'>>/etc/profile&&source/etc/profile

淇敼Nginx閰嶇疆锛屼娇鐢≒HP7

location~.*.(php|php5)?${fastcgi_pass127.0.0.1:9001;#娉ㄦ剰锛屽洜涓哄凡缁忔湁涓9000绔彛鏈嶅姟浜嶱HP5鐗堟湰浜嗭紝鎵浠HP7灏辩敤9001浜嗐 fastcgi_index index.php;include fcgi.conf;}

杩欓噷鍐欏浘鐗囨弿杩


浠ヤ笂灏辨槸Centos+Nginx+PHP7.0缂栬瘧瀹夎(鍜孭HP5.6鑰佺増鏈叡瀛)鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=142