centos6.8安装编译php7.1.2
安装必要的工具
成都创新互联是一家专注于成都网站设计、做网站、成都外贸网站建设公司与策划设计,延平网站建设哪家好?成都创新互联做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:延平等地区。延平做网站价格咨询:13518219792
rpm -qa|grep libxml2 查看下工具是不是有装
yum list | grep libxml2
yum install libxml2-devel (centos 必须安装)
ubuntu/debian:
apt-get install libxml2-dev
apt-get install autoconf
//yum install libxml2
yum install libtool
yum install gcc-c++
yum install gcc ( centos 必须安装)
yum list|grep pcre
yum install pcre-devel
groupadd www-data
useradd -g www-data www-data
----安装php
php官网下载 wget http://php.net/distributions/php-7.1.2.tar.gz
解压 tar -zvxf php-7.1.2.tar.gz
进入源码目录 cd ./php-7.1.2
./configure --prefix=/usr/local/php --enable-fpm --enable-MySQLnd
make
make install
(1)
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
pid = run/php-fpm.pid (这行前面的分号去掉)
(2)
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
vi /usr/local/php/etc/php-fpm.d/www.conf
pm.start_servers = 10 (启动fpm时子进程数量)
listen = 127.0.0.1:9000 (监听ip和端口 跟nginx 的配置文件里的fastcgi_pass对应上)
user = www-data
group = www-data
(3)
在命令行下执行php或phpize会提示命令找不到,要设置环境变量
export PATH=$PATH:/usr/local/php/bin
(4)
cp ./php.ini-development /usr/local/php/lib
./php -i|grep php.ini 可以查看php.ini在那个哪里目录下,要把上行配置文件cp到这个目录下
php-fpm -c /usr/local/php/php.ini 启动时加载指定php.ini (可以忽略这样默认就是)
支持service php-fpm start
cp /home/skinglzw/php-7.2.5/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
vi /etc/init.d/php-fpm
将
php_fpm_BIN=@sbindir@/php-fpm
php_fpm_CONF=@sysconfdir@/php-fpm.conf
php_fpm_PID=@localstatedir@/run/php-fpm.pid
改成
php_fpm_BIN=/usr/local/php/sbin/php-fpm
php_fpm_CONF=/usr/local/php/etc/php-fpm.conf
php_fpm_PID=/usr/local/php/var/run/php-fpm.pid
执行
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
echo "/usr/local/php/sbin/php-fpm" >> /etc/rc.local (设置成开机启动)
/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf -t (可以忽略这样默认就是)
killall php-fpm 关闭进程
php-fpm 关闭:
kill -INT 'cat /usr/local/php/var/run/php-fpm.pid'(这个会报错不知道为什么,pid文件也是存在的)(这个路径要跟上面php-fpm.conf这个文件设置路径一样)
php-fpm 重启:
kill -USR2 'cat /usr/local/php/var/run/php-fpm.pid'
----安装nginx
wget http://nginx.org/download/nginx-1.11.13.tar.gz
tar -zxvf nginx-1.11.13.tar.gz
./configure --prefix=/usr/local/nginx
make
make install
whereis nginx
echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local (设置成开机启动)
vi /usr/local/nginx/conf/nginx.conf
#include server/demo.com(可以根据项目include配置不同站点)
user www-data;
location / {
root html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME (代码路径)$fastcgi_script_name;
include fastcgi_params;
}
修改完保存,重启
/usr/local/nginx/sbin/nginx -s restart
当前标题:centos6.8安装编译php7.1.2
网站网址:http://pwwzsj.com/article/ppsipd.html