search
HomeBackend DevelopmentPHP ProblemHow to solve centos nginx php error problem

centos nginx php error solution: 1. Analyze whether php-fpm is installed, if not, install php-fpm; 2. Modify the nginx.conf file or default.conf; 3. Save the file and restart Just nginx.

How to solve centos nginx php error problem

The operating environment of this article: centOS6.8 system, PHP7.1 version, DELL G3 computer

How to solve centos nginx php error question?

CentOS6.10 Nginx cannot parse php files

1. Problem description:

1). Prerequisite:

nginx has been installed and can access

2). Problem:

When accessing the .php file, it will be downloaded by default, or it will prompt "File not found.”

3). Local environment

PHP 版本:
 # php -v
PHP 5.3.3 (cli) (built: Mar 22 2017 12:27:09) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Nginx 版本:[root@bogon sbin]# ./nginx -v
nginx version: nginx/1.11.6

2. Solution

1). Analyze whether php-fpm is installed

You can run the command service php-fpm start. If it shows that it cannot be recognized, it means it is not installed.

2). If php-fpm is not installed

You can execute the installation command: yum install php-fpm and then run the command service php-fpm start

3). If it is already installed I have installed php-fpm and still cannot parse the .php file

(1). Modify the nginx.conf file or default.conf, as shown in the figure below, and modify several pieces of information. For example, "root" refers to my nginx root directory, which can be configured according to your own situation

How to solve centos nginx php error problem

(2). Save the file and restart nginx, command: service nginx restart (3). At this time, the browser can access the .php file (if it is not accessed locally, be sure to turn off the firewall)


server{
        listen 80;
        server_name app-hpoption-admin-test.azfaster.com;
        root   /data/wwwroot/blog/public;
        charset utf-8;

        location / {
                index index.php index.html ;
                try_files $uri $uri/ /index.php?$query_string;

        }

        #location ~ .php$ {
        #       fastcgi_pass 127.0.0.1:9000;
        #       fastcgi_index index.php;
        #       fastcgi_param SCRIPT_FILENAME /var/www/test/public$fastcgi_script_name;
        #       include  fastcgi_params;
        #}

         location ~ .*\.(php|php5)?$ {
                # fastcgi_pass  unix:/dev/shm/php-cgi.sock;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /data/wwwroot/blog/public$fastcgi_script_name;
                include fastcgi_params;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root html;
        }
}

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to solve centos nginx php error problem. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor