php7源码安装
admin
2023-06-19 18:01:54
0

安装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




 
 
 

相关内容

热门资讯

伊媒公布对美备忘录草案,白宫:... 在伊朗媒体披露美伊“初步非正式备忘录”,称美将解除海上封锁并换取霍尔木兹通航后,白宫方面迅速予以否认...
吴思瑶批蒋万安又翻车?游淑慧举... 海峡导报综合报道 英伟达进驻台北北投士林科技园区(北士科),用电问题引发台北市长选战攻防。民进党民代...
俄军空袭强度骤升,泽连斯基紧急... 在俄罗斯加大对乌克兰空袭力度,并威胁打击基辅决策中心之际,乌克兰总统泽连斯基紧急致信特朗普。《基辅独...
禁止中国厂商参与欧盟电信网络?... 【文/观察者网 熊超然】当地时间5月27日,彭博社援引知情人士报道称,德国和西班牙正带头反对欧盟委员...
男子为方便上下班两次拆除路中隔... 道路中央隔离护栏是规范行车秩序、守护出行安全的重要公共设施,但是有人为了一己私利,故意破坏交通设施,...
女子称车祸住院遭男医生侵犯,警... 极目新闻记者 马浩然近日,河北的王女士向极目新闻反映,今年3月,她开车经过辽宁葫芦岛时,在高速遭遇汽...
美军的“眼中钉”,伊朗岸舰导弹... 澎湃新闻特约撰稿 邰丰顺据中国新闻社报道,当地时间5月25日,美军中央司令部称,美军在伊朗南部实施了...
张雪峰因病去世,其江苏省人大代... 5月27日,江苏省人民代表大会常务委员会发布公告:江苏省人民代表大会常务委员会公告由无锡市选出的陈大...
电热水器一加热就跳闸 可能跟安装电热水器有关,如果是家里安装电热水器,最好要找专业人士,安装不仔细或者是安装不到位,比如在...
家里电热水器通电就跳闸 这种情况可能是电热水器漏电,解决方法建议检测电热水器加热管是否漏电、温控器有无问题,发现问题及时处理...