php7源码安装

安装php7的过程:
1.tar zxf php-x.x.x
2.Configure and build PHP. This is where you customize PHP with various options,
like which extensions will be enabled. Run ./configure --help for a list of available options.
In our example we‘ll do a simple configure with PHP-FPM and MySQL support.
cd ../php-x.x.x
./configure --enable-fpm --with-mysql
make
sudo make install

3.
Obtain and move configuration files to their correct locations

cp php.ini-development /usr/local/php/php.ini
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
cp sapi/fpm/php-fpm /usr/local/bin

4.
It is important that we prevent Nginx from passing requests to the PHP-FPM backend
 if the file does not exists, allowing us to prevent arbitrarily script injection.
 vim /usr/local/php/php.ini
 cgi.fix_pathinfo=0
5.
php-fpm.conf must be modified to specify that
php-fpm must run as the user www-data and the group www-data before we can start the service:
vim /usr/local/etc/php-fpm.conf
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user‘s group
;       will be used.
user = www-data
group = www-data

6.
The php-fpm service can now be started:
/usr/local/bin/php-fpm

7.
Nginx must now be configured to support the processing of PHP applications:
vim /usr/local/nginx/conf/nginx.conf
Modify the default location block to be aware it must attempt to serve .php files:

location / {
    root   html;
    index  index.php index.html index.htm;
}

8. The next step is to ensure that .php files are passed to the PHP-FPM backend.
 Below the commented default PHP location block, enter the following:
location ~* \.php$ {
    fastcgi_index   index.php;
    fastcgi_pass    127.0.0.1:9000;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
}

9.Restart Nginx.
sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx

10.Create a test file

错误一、在配置的时候会报错,需要安装libxml2-dev和libxml2包

错误二、另外启动的时候报错:
cp /root/php-7.0.0alpha1/sapi/fpm/php-fpm.conf /usr/local/etc/php-fpm.conf
错误三、
ERROR: Unable to globalize ‘/usr/local/NONE/etc/php-fpm.d/*.conf‘ (ret = 2) from /usr/local/etc/php-fpm.conf at line 125.
ERROR: failed to load configuration file ‘/usr/local/etc/php-fpm.conf‘
ERROR: FPM initialization failed

Edit /usr/local/etc/php-fpm.conf document introduced * .conf part,
change to the correct path include = / usr / local / etc / php-fpm.d / *. Conf
If there is no /usr/local/etc/php-fpm.d directory, create the directory.

错误四:
WARNING: Nothing matches the include pattern ‘/usr/local/etc/php-fpm.d/*.conf‘ from /usr/local/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

cp www.conf.default www.conf

错误五:
ERROR: [pool www] can not get gid for group ‘nobody‘
ERROR: FPM initialization failed

Www.conf open files, user and group users into nginx default settings, usually the default is www-data.

增加配置:
php-fpm.conf中:
[global]
; Note: the default prefix is /usr/local/php/var
error_log = log/php_error_log
[www]
catch_workers_output = yes

php.ini中:

log_errors = On
error_log = "/usr/local/php/var/log/error_log"
error_reporting=E_ALL&~E_NOTICE

时间: 2024-12-20 01:01:22

php7源码安装的相关文章

搭建LNAMP环境(五)- PHP7源码安装Redis和Redis拓展

上一篇:搭建LNAMP环境(四)- 源码安装PHP7 一.安装Redis 1.创建redis用户组和用户 groupadd redis useradd -r -g redis -s /sbin/nologin -M redis 2.下载redis源码包,将源码包放到/usr/local/src/目录下 下载页面:http://redis.io/download这里用的是redis-3.2.5.tar.gz下载地址:http://download.redis.io/releases/redis-3

搭建LNAMP环境(六)- PHP7源码安装MongoDB和MongoDB拓展

上一篇:搭建LNAMP环境(五)- PHP7源码安装Redis和Redis拓展 一.安装MongoDB 1.创建mongodb用户组和用户 groupadd mongodb useradd -r -g mongodb -s /sbin/nologin -M mongodb 2.下载mongodb源码包,并将源码包放到/usr/local/src/目录下下载页面:https://www.mongodb.com/download-center?jmp=nav这里用的是 mongodb-linux-x

搭建LNAMP环境(七)- PHP7源码安装Memcached和Memcache拓展

上一篇:搭建LNAMP环境(六)- PHP7源码安装MongoDB和MongoDB拓展 一.安装Memcached 1.yum安装libevent事件触发管理器 yum -y install libevent-devel 2.创建memcached用户组和用户 groupadd memcached useradd -r -g memcached -s /sbin/nologin -M memcached 3.下载memcached源码包,并将源码包放到/usr/local/src/目录下下载页面

在ubuntu下,进行php7源码安装

作为一名php的攻城师,如果没有玩php源码安装是说不过去的.我们知道php之所以这么流行,跟它的开源文化和lamp配套有很大关系.由于PHP7废弃了很多功能,所以一些依赖这些功能的程序可能无法运行,尝鲜前请三思.比如很多国产软件都在依赖的mysql相关函数,如果自己开发php应用请用mysqli代替.不过WordPress是没有问题的,尽情使用吧. 下面进入正题,第一步,当然是下载源码和解压 $ cd ~ $ wget http://cn2.php.net/distributions/php-

PHP7源码安装MongoDB和MongoDB拓展

一.安装MongoDB 1.创建mongodb用户组和用户 groupadd mongodb useradd -r -g mongodb -s /sbin/nologin -M mongodb 2.下载mongodb源码包,并将源码包放到/usr/local/src/目录下下载页面:https://www.mongodb.com/download-center?jmp=nav这里用的是 mongodb-linux-x86_64-rhel62-3.2.10.tgz下载地址:https://fast

搭建LNAMP环境(四)- 源码安装PHP7

上一篇:搭建LNAMP环境(三)- 源码安装Apache2.4 一.安装PHP7 1.yum安装编译php需要的包 yum -y install libxml2 libxml2-devel curl-devel libpng-devel freetype-devel libmcrypt-devel libjpeg-devel 2.创建php用户组和用户 groupadd php useradd -r -g php -s /sbin/nologin -M php 3.下载php源码包,将源码包放到

centos7.2源码安装php7.0.9和nginx1.10.3服务器

下载nginx-1.10.3.tar.gz,php-7.0.9.tar.gz.也可以去nginx官网,php官网下载想要的版本.我选择nginx1.10.3稳定版和php7.0.9最新版.php源码包下载速度可能会很慢,建议使用迅雷等工具,下载完成后通过stfp工具把源码包上传到服务器上,为方便测试,我直接放置在root家目录下: 使用源码安装要确保服务器安装好gcc(编辑工具)和make(安装工具),若没安装可以执行命令安装: # yum install gcc # yum install m

图解Linux下源码安装PHP7.0.9 +Nginx

上一次,在<Linux下源码安装php7.0.6>,安装过PHP7.0.3,本文将记录安装PHP7.0.9过程. 测试环境 Linux 2.6.32-279.el6.i686 nginx-1.9.15.tar http://nginx.org/download/nginx-1.9.15.tar.gz php-7.0.9.tar.gz http://am1.php.net/distributions/php-7.0.9.tar.gz 安装Nginx wget http://nginx.org/d

源码安装CentOs7下的PHP7

首先安装APACHE环境,直接用yum安装 yum install httpd httpd-devel /etc/httpd/ systemctl start httpd.service #启动apache systemctl stop httpd.service #停止apache systemctl restart httpd.service #重启apache 然后安装mysql(mariadb) yum install mariadb mariadb-server cp /usr/sha