Tag Archives: php

[Solved] Primary script unknown in nginx configuration PHP

Cause

In the past two days, when building the virtual host, the environment is basically configured. There is no problem in accessing the HTML file, but there is a file not found error when accessing the PHP file

Solution

When there is a problem, first open the log to find the error message

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

Well, if you don’t understand it, you can go directly to Baidu, and then according to the various results of Baidu, the attempt is failed, such as this one

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
change to
SCRIPT_FILENAME $document_root$fastcgi_script_name; 

But my nginx configuration file is already like this, and then I started to compare the nginx configuration of the server running normally with my current nginx configuration. After comparison, the two are the same, so the problem is not nginx

Then continue to search by chance, try all kinds of things, and finally find a solution

/etc/selinux/config  mid
SELINUX=enforcing
to
SELINUX=disabled

If it hasn’t been solved, consider the issue of permissions

It’s over

If problems are not solved, they will come back again

<?php
  echo 'How can't this input box be removed?';

PHP regular matching H1 datagram error preg_ match(): Unknown modifier ‘h’ in

Question:

$str = "<h1>this is test msg</h1>";
$ruler = "/^<h1>(.*?)</h1>$/";
$res = preg_match($ruler,$str,$v);
var_dump($v);

Error:
Warning: preg_match(): Unknown modifier 'h' in /usr/local/var/www/test.php on line 36
NULL

Why is it wrong?The reason is because of my delimiter

in regular rules, the/do delimiter is used, while in </ h1> There are also /, so such errors will be reported

Solution:

1. Will < h1> I’d like to change it to </ h1> It’s OK

$ruler = "/^<h1>(.*?)<\/h1>$/";

2. Change the delimiter

PHP Error: The use statement with non-compound name

1.1 The use statement with non-compound name

1.1.1 phenomenon

After debugging the program, it is found that running the following code will make the program run away:

require_ once __ DIR__ . ‘/ actions/’ . $refectClass . ‘.php’;

1.1.2 reasons

is debugged in PHPStorm. DIR__ Variable, found that it has always been Xdebug, so thought it was this problem, online search a lot of information, there is no solution

Later, I checked the error log and found the following error information:
2014-05-12 16:41:53: < E> [ php ]: The use statement with non-compound name 'CommonUtils' has no effect (D:\ProjectWork\SourceCode\Server\i2goods\protected\components\clientapi\actions\BookEditAction. php:9 )
Open the bookeditaction.php file and look at line 9 of the code

use CommonUtils
Looking for information on the Internet, we found that this use syntax error

1.1.3 solution

Consult the relevant developers, this code is garbage code, forget to delete, delete it

Complete failure: http request failed!

 

        When using PHP5’s own file_ get_ Content method to get remote files (in my

There are similar call requirements in the automated test framework, and sometimes the file will appear_ get_ contents(): failed to open stream: HTTP request failed! This is a warning message.

 

       The solution is to modify php.ini Let_ url_ Fopen is enabled and changed to allow_ url_ fopen = On

 
      This can solve some people’s problems. Some people say that in China php.ini In, there are two options: allow_ url_ Fopen = on (indicates that the remote file can be opened through URL), user_ Agent = “PHP” (indicates which script is used to access the network. By default, there is a “;” Remove it.) Restart the server.

       But some will still have this warning message. If you want to use the perfect solution, you still need to set it php.ini User in it_ Agent, PHP’s default user_ The agent is PHP, we changed it to Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)_ agent=”Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)”

php_network_getaddresses: getaddrinfo failed

In general, when calling external service requests, sometimes due to configuration problems, PHP will report a PHP_ network_ Error in getaddresses: getaddrinfo failed: name or servicenot known:

 

reason:

PHP host cannot connect to DNS server

Analysis: for example, what is your access request www.leyangjuntestxxxx.com Our services

You can: Ping or   Telnet to see whether the domain can be accessed, whether there is a response

If you can’t Ping, your service is connected to a DNS server with problems

 

General solution:

1: You need to check whether the requested remote host is in/etc/hosts of the local machine

2: Need to check the rules of the firewall, is it blocked by the response

3: You can manually bind the host in the/etc/hosts file

When laravel is uploaded to the server, whoops, looks like something went wrong appears

1. When laravel, which can run well locally, uploads to the server, this problem appears: “whoops, looks like something wet wrong.”

2. Step one/ app.php ‘debug ‘= &> env (‘app’) in file_ Debug ‘, false), change to’ debug ‘= &> env (‘app’)_ DEBUG’, true),

3. A lot of information is displayed now

We notice that no supported encryption found.The Cipher and/or key length are invalid_ Copy the key value and modify it/ app.php Inside

‘key’ =&> env(‘APP_ KEY’,’base64:R+8tyPpcbK6ELMheXa4D8hsxdVvXDilVUSFCFqaH8vY=’),

This app_ Key can also be accessed through PHP artisan key:generate Generation

Now report another mistake

The description here is database connection error, modify config/ database.php File database connection problem ‘MySQL’ = & gt[

‘driver’ =&> ‘mysql’,

‘host’ =&> env(‘DB_ HOST’, ‘localhost’),

‘port’ =&> env(‘DB_ PORT’, ‘3306’),

‘database’ =&> env(‘DB_ DATABASE’, ‘forge’),

‘username’ =&> env(‘DB_ USERNAME’, ‘forge’),

‘password’ =&> env(‘DB_ PASSWORD’, ”),

‘charset’ =&> ‘utf8’,

‘collation’ =&> ‘utf8_ unicode_ ci’,

‘prefix’ =&> ‘pty_ ‘,

‘strict’ =&> false,

‘engine’ =&> null,

],

Modify the corresponding database configuration

5. There is no problem when logging in to the background administrator, but an error is reported when logging in to the added administrator

This problem is a cache problem. Modify the config/ cache.php File, put ‘default’ = &> env (‘cache ‘)_ Driver ‘,’File’), change to

‘default’ =&> env(‘CACHE_ DRIVER’, ‘array’),

This is because this error occurred when adding roles using the zizaco/enter permission package.

Need to communicate with small partners can click here to add my QQ: Luke

How to Solve PHP error “Zend”_ mm_ heap corrupted”

I: Environment Introduction
Ali cloud  
[machao@gksn]$ cat /etc/redhat-release 
CentOS Linux release 7.0.1406 (Core) 
There is a local test environment and an online environment, the online environment is placed in svn
[machao@iZ233xdnwmfZ ~]$ php -v
PHP 5.6.20 (cli) (built: Apr 9 2016 20:40:37) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies


Link: https://stackoverflow.com/questions/2247977/what-does-zend-mm-heap-corrupted-mean

2: Content of error report

A function of the website suddenly fails to work. Click in to display “502 bad gateway”, but the test environment is normal

At that time, the first reaction was that the problem with nginx was due to the network. After looking at the nginx status, it was still not possible to refresh the browser page. PHP page, and then think of other sites to check- fpm.log Error file for

tail -f /usr/local/php56/var/log/php- fpm.log

[16-May-2018 11:30:28] WARNING: [pool www] child 32494 said into stderr: “zend_ mm_ heap corrupted”
[16-May-2018 11:30:28] WARNING: [pool www] child 32494 exited with code 1 after 534.670302 seconds from start
[16-May-2018 11:30:32] WARNING: [pool www] child 32521, script ‘/web/zwbi/admin/public/ index.php ‘ (request: “GET/index.php “) executing too slow (5.745961 sec), logging

3: Solutions

1. Memory problem

Open php.ini File to find the next two lines to increase the output_ The buffering value either turns off this option or executes export use on the command line_ ZEND_ Alloc = 0 PS: no use_ ZEND_ Alloc performance will decline sharply, which is PHP’s own memory management mechanism

vim /usr/local/php56/etc/ php.ini

output_ buffering = On
output_ buffering = 25600

Restart PHP FPM

Sudo systemctl restart/usr/local/php56/SBIN/PHP FPM

2. chown -R www.www filename && chmod 777 filename

But it’s still 502

 

3. Check nginx error log and PHP- fpm.log Log

[06-Mar-2018 15:54:57] WARNING: [pool www] child 30396 said into stderr: "zend_mm_heap corrupted" [06-Mar-2018 15:54:57] WARNING: [pool www] child 30396 exited with code 1 after 239.805753 seconds from start

 

Baidu and Google inquired about some links and “determined that it was the problem of opcache module”. At that time, they thought it could be basically solved. But it’s useless to comment out the whole opcache module. Link posted below, did not solve my problem, may be helpful to friends.

https://stackoverflow.com/questions/2247977/what-does-zend-mm-heap-corrupted-mean
https://github.com/websharks/comet-cache/issues/705

4. I think it is a problem of some dependent components, so I update the composer package of the test environment to the formal environment, and the test still fails. After the test fails, restore the component (do these operations must remember to backup, restore at any time).

5. There are differences with development. I think there may be a problem with the code operation, such as a bug or the associated file permissions. I think it’s my environment problem. Do as you say, set the authority of all files in the formal environment at one time.

sudo chown -R www.www /web/xxx

At this point, the problem remains unsolved

6. Code problems

Develop the code version before rollback, and solve the problem

 

The solution of error: XZ compression not available

Check the PHP version after entering the terminal
PHP – V
the output may be as follows:
PHP 5.4.35 (CLI) (build: Nov 14 2014 07:04:10) Copyright (c) 1997-2014 the PHP group Zend engine v2.6.0, copyright (c) 1998-2015 Zend technologies with Zend opcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend technologies

Execute the following command to upgrade the software warehouse

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Execute the following command to delete PHP (pay attention to the packages unloaded when unloading)
Yum remove PHP common

Then ask you if you want to continue like the installation, enter yes to
install PHP 5.6 (php56w devel is not required) (you can use Yum search php56w to check the missing dependent packages)
Yum install – y php56w php56w opcache php56w XML php56w mcrypt php56w GD php56w devel php56w MySQL php56w Intl php56w mbstring php56w FPM

Restart httpd
Service httpd restart
view the latest version
PHP – V
now it should be 5.6!


solution:
so, through the following three steps, delete the 7 version of EPEL, and then install the appropriate version of epel6:
1. Yum remove EPEL release
2. RM – RF/var/cache/Yum/x86_ 64/6/epel/*
3.rpm – Uvhhttp://mirrors.ustc.edu.cn/epel/epel-release-latest-6.noarch.rpm
4.rpm – Uvhhttp://mirror.webtatic.com/yum/el6/latest.rpm


Execute the installation command to install php7 again, and this error is still prompted. Most of the solutions to search on the Internet are the same as above, and the problems have not been effectively solved after repeated operations.


After carefully reading the error prompt, the content is “XZ compression is not available”, XZ is a compression tool, and my system is minimal installation, it should be that this tool is not installed.
Next, perform the following steps to install XZ:
Yum clean all
Yum – y install XZ
rpm- Uvhhttp://mirror.webtatic.com/yum/el6/latest.rpm
Then execute Yum install – y php7 success!

Linux: apt get install build essential and Yum groupinstall “development tools”

Ubuntu’s apt install build essential

Function: to configure the Debian system compilation environment is to download and install the dependencies/packages that support the compilation of Debian packages, such as GCC.

Direct execution

#apt install build-essential

You can view log/var/log/apt after execution/ history.log , see the following.

Start-Date: 2019-06-08  07:54:24
Commandline: apt install build-essential
Requested-By: satou (1000)
Install: libmpc3:amd64 (1.1.0-1, automatic), libgcc-7-dev:amd64 (7.4.0-1ubuntu1~18.04, automatic), libmpx2:amd64 (8.3.0-6ubuntu1~18.04, automatic), linux-libc-dev:amd64 (4.15.0-51.55, automatic), libfakeroot:amd64 (1.22-2ubuntu1, automatic), libc6-dev:amd64 (2.27-3ubuntu1, automatic), cpp-7:amd64 (7.4.0-1ubuntu1~18.04, automatic), libalgorithm-diff-perl:amd64 (1.19.03-1, automatic), libalgorithm-merge-perl:amd64 (0.08-3, automatic), binutils:amd64 (2.30-21ubuntu1~18.04.1, automatic), cpp:amd64 (4:7.4.0-1ubuntu2.2, automatic), libitm1:amd64 (8.3.0-6ubuntu1~18.04, automatic), g++:amd64 (4:7.4.0-1ubuntu2.2, automatic), gcc-7-base:amd64 (7.4.0-1ubuntu1~18.04, automatic), gcc:amd64 (4:7.4.0-1ubuntu2.2, automatic), libcilkrts5:amd64 (7.4.0-1ubuntu1~18.04, automatic), libasan4:amd64 (7.4.0-1ubuntu1~18.04, automatic), libquadmath0:amd64 (8.3.0-6ubuntu1~18.04, automatic), libisl19:amd64 (0.19-1, automatic), build-essential:amd64 (12.4ubuntu1), libfile-fcntllock-perl:amd64 (0.22-3build2, automatic), binutils-x86-64-linux-gnu:amd64 (2.30-21ubuntu1~18.04.1, automatic), libstdc++-7-dev:amd64 (7.4.0-1ubuntu1~18.04, automatic), libtsan0:amd64 (8.3.0-6ubuntu1~18.04, automatic), libubsan0:amd64 (7.4.0-1ubuntu1~18.04, automatic), g++-7:amd64 (7.4.0-1ubuntu1~18.04, automatic), make:amd64 (4.1-9.1ubuntu1, automatic), fakeroot:amd64 (1.22-2ubuntu1, automatic), gcc-7:amd64 (7.4.0-1ubuntu1~18.04, automatic), liblsan0:amd64 (8.3.0-6ubuntu1~18.04, automatic), libgomp1:amd64 (8.3.0-6ubuntu1~18.04, automatic), manpages-dev:amd64 (4.15-1, automatic), binutils-common:amd64 (2.30-21ubuntu1~18.04.1, automatic), libc-dev-bin:amd64 (2.27-3ubuntu1, automatic), libbinutils:amd64 (2.30-21ubuntu1~18.04.1, automatic), libatomic1:amd64 (8.3.0-6ubuntu1~18.04, automatic), libcc1-0:amd64 (8.3.0-6ubuntu1~18.04, automatic), libdpkg-perl:amd64 (1.19.0.5ubuntu2.1, automatic), libalgorithm-diff-xs-perl:amd64 (0.04-5, automatic), dpkg-dev:amd64 (1.19.0.5ubuntu2.1, automatic)
Upgrade: gcc-8-base:amd64 (8.2.0-1ubuntu2~18.04, 8.3.0-6ubuntu1~18.04), libgcc1:amd64 (1:8.2.0-1ubuntu2~18.04, 1:8.3.0-6ubuntu1~18.04), libstdc++6:amd64 (8.2.0-1ubuntu2~18.04, 8.3.0-6ubuntu1~18.04)
End-Date: 2019-06-08  07:55:01

Note: (1) execute apt get update or apt update to update the package index before running, otherwise it may fail. (2) It is suggested to use apt instead of apt get

CentOS’s Yum - y groupinstall "development tools"

Function: to configure the compilation environment of CentOS is to download and install the package/dependency that enables CentOS to compile the source code package on the platform

You can use the command Yum grouplist to check which groups there are. Development tools is in available groups.

[root@localhost ~]# yum grouplist
Loaded plugins: fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Compatibility Libraries
   Console Internet Tools
   <span style="color: red;"&><Development Tools</span&>
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
Done

Before executing Yum groupinstall "development tools" , execute Yum clean all to clear Yum cache and force Yum to read some configuration files again

[root@localghost ~]# yum clean all
Loaded plugins: fastestmirror, priorities, remove-with-leaves
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@localghost ~]#

List of dependency packages included in the content tools

bison
byacc
cscope
ctags
cvs
diffstat
doxygen
flex
gcc
gcc-c++
gcc-gfortran
gettext
git
indent
intltool
libtool
patch
patchutils
rcs
redhat-rpm-config
rpm-build
subversion
swig
systemtap

Perform the demo

[root@localghost ~]# yum groupinstall "Development tools"


Install      86 Package(s)
Upgrade       0 Package(s)

Total download size: 77 M
Installed size: 234 M
Is this ok [y/N]:

Enter y to confirm the installation and N to cancel. Or Yum - y groupinstall "development tools" confirm in advance.

If you encounter the following error no packages in any requested group available to install or update , you need to configure the data source

cd /etc/yum.repos.d
sudo wget http://public-yum.oracle.com/public-yum-el5.repo
cd /etc/pki/rpm-gpg/
sudo wget https://public-yum.oracle.com/RPM-GPG-KEY-oracle-el5

Reference article

https://support.eapps.com/index.php?/Knowledgebase/Article/View/438/55/user -guide—installing-the-centos-development-tools-gcc-flex-etc

Expand

Lamp one click installation – in fact, with docker container technology, I feel that lamp (Linux + Apache + MySQL/MariaDB/percona + PHP) production environment is unnecessary