標籤:php7
安裝必要的工具
rpm -qa|grep libxml2 查看下工具是不是有裝
yum list | grep libxml2
yum install libxml2-devel
//yum install libxml2
yum install libtool
yum install gcc-c++
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
(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
user = www-data
group = www-data
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)
php-fpm -c /usr/local/php/php.ini 啟動時載入指定php.ini
/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 重啟:
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
whereis nginx
echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local (設定成開機啟動)
vi /usr/local/nginx/conf/nginx.conf
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
本文出自 “我是程式我最大” 部落格,請務必保留此出處http://skinglzw.blog.51cto.com/10729606/1913020
centos 6.8 安裝編譯php7.1.2