root@iZ25fm7iewtZ:/php-7.0.6# make install Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20151012/ Installing PHP CLI binary: /usr/local/bin/ Installing PHP CLI man page: /usr/local/php/man/man1/ Installing PHP FPM binary: /usr/local/sbin/ Installing PHP FPM config: /usr/local/etc/ Installing PHP FPM man page: /usr/local/php/man/man8/ Installing PHP FPM status page: /usr/local/php/php/fpm/ Installing phpdbg binary: /usr/local/bin/ Installing phpdbg man page: /usr/local/php/man/man1/ Installing PHP CGI binary: /usr/local/bin/ Installing PHP CGI man page: /usr/local/php/man/man1/ Installing build environment: /usr/local/lib/php/build/ Installing header files: /usr/local/include/php/ Installing helper programs: /usr/local/bin/ program: phpize program: php-config Installing man pages: /usr/local/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/lib/php/ [PEAR] Archive_Tar - already installed: 1.4.0 [PEAR] Console_Getopt - already installed: 1.4.1 [PEAR] Structures_Graph- already installed: 1.1.1 [PEAR] XML_Util - already installed: 1.3.0 [PEAR] PEAR - already installed: 1.10.1 Wrote PEAR system config file at: /usr/local/etc/pear.conf You may want to add: /usr/local/lib/php to your php.ini include_path /php-7.0.6/build/shtool install -c ext/phar/phar.phar /usr/local/bin ln -s -f phar.phar /usr/local/bin/phar Installing PDO headers: /usr/local/include/php/ext/pdo/
報錯 [18-May-2016 18:07:58] ERROR: failed to open configuration file '/usr/local/etc/php-fpm.conf': No such file or directory (2) [18-May-2016 18:07:58] ERROR: failed to load configuration file '/usr/local/etc/php-fpm.conf' [18-May-2016 18:07:58] ERROR: FPM initialization failed
到/usr/local/etc/目錄下,將php-fpm.conf.default拷貝一份成php-fpm.confphp
root@iZ25fm7iewtZ:/# cd /usr/local/php/etc/ root@iZ25fm7iewtZ:/usr/local/etc# cp php-fpm.conf.default php-fpm.conf
而後在編輯php-fpm.conf配置文件html
;最後一行改爲以下
include=/usr/local/etc/php-fpm.d/*.conf
進入到/usr/local/etc/php-fpm.d/目錄下,將www.conf.default拷貝一份成www.confnginx
root@iZ25fm7iewtZ:/usr/local/etc# cd php-fpm.d/ root@iZ25fm7iewtZ:/usr/local/etc/php-fpm.d# cp www.conf.default www.conf
編輯www.conf文件,將user和group改爲和nginx.conf中的user和group一致c#
user = www group = www
再次啓動瀏覽器
/usr/local/sbin/php-fpm
root@iZ25fm7iewtZ:/usr/local/etc# ps -ef | grep php-fpm root 3691 1 0 18:49 ? 00:00:00 php-fpm: master process (/usr/local/etc/php-fpm.conf) www-data 3692 3691 0 18:49 ? 00:00:00 php-fpm: pool www www-data 3693 3691 0 18:49 ? 00:00:00 php-fpm: pool www root 4982 29553 0 18:59 pts/1 00:00:00 grep --color=auto php-fpm root@iZ25fm7iewtZ:/usr/local/etc# netstat -tnl | grep 9000 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
開機啓動php-fpm,開機啓動的配置文件是:/etc/rc.local
,加入 /usr/local/sbin/php-fpm
便可php7
vi /etc/rc.local
添加 /usr/local/sbin/php-fpm
修改nginx的配置文件,支持php文件的解析,找到location的添加位置,在後面添加下面這個locationtcp
location ~ \.php$ { root /var/www; #指定php的根目錄 fastcgi_pass 127.0.0.1:9000;#php-fpm的默認端口是9000 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
測試nginx.conf是否修改爲功php-fpm
/usr/sbin/nginx -t測試
重起nginxui
/usr/sbin/nginx -s reload
進入到/var/www目錄(若是該目錄不存在的話,就使用mkdir命令建立)
vi index.php 添加 <?php phpinfo(); ?>
最後在瀏覽器中輸入:localhost/index.php便可