陈永鹏的博客园地址:http://www.cnblogs.com/Yoperchen/
闲来没事安装个php7玩。
0.下载php7.
1.解压.
tar xzvf php-7.tar.gz
2.进入解压后的目录
cd php-7.0.1
3.
./configure --prefix=/usr/local/php7 \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-MySQL \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
4.make && make install
第4步要花比较久的时间
5.
cp -R ./sapi/fpm/php-fpm.conf /usr/local/php7/etc/php-fpm.conf
6.
cp php.ini-development /usr/local/php7/lib/php.ini
7.
cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm7
8创建软连接,这样以后php-v 显示的是原来的PHP,php7 -v显示的是php7的相关信息
ln -s /usr/local/php7/bin/php /usr/bin/php7
9.修改端口
php默认端口是9000,原来的php5.4就用了9000端口,所以修改php7监听端口为9007
大概在这个位置
复制.conf文件
cp /usr/local/php7/etc/php-fpm.d/www.conf.default www.conf
vim www.conf 修改如下,我的在第36行。
没有复制成.conf的话会报错,如下
WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf' from /usr/local/php7/etc/php-fpm.conf at line 125.
ERROR: No pool defined. at least one pool section must be specified in config file
ERROR: failed to post process the configuration
ERROR: FPM initialization failed
9.启动:
/etc/init.d/php-fpm7
看看是否有启动
ps -aux|grep php
我的
nginx 配置.
原先我已经有了一个php5.3版本,现在多了一个php7。所以要分别配置
一个server指向php5.3,一个server指向php7.0
如下,使用project2.test.com访问的是project2项目,调用的是php7
#默认使用原来的php运行
server {
listen 80;
server_name *.test.com;
location / {
root /usr/nginx/html/my_project;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/nginx/html/my_project;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#project2使用php7运行
server {
listen 80;
server_name project2.test.com;
location / {
root /usr/nginx/html/project2;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/nginx/html/project2;
fastcgi_pass 127.0.0.1:9007;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
如图
如有问题,可以在下面留言~
新建php文件,phpinfo();
命令解释
configure --prefix=/
指定安装路径
不指定prefix,则可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc。其它的资源文件放在/usr /local/share。你要卸载这个程序,要么在原来的make目录下用一次make uninstall(前提是make文件指定过uninstall),要么去上述目录里面把相关的文件一个个手工删掉。
指定prefix,直接删掉一个文件夹就够了
--prefix指的是安装路径,--with指的是安装本文件所依赖的库文件。
本文作者:陈永鹏
邮箱:chen.yong.peng@foxmail.com