Home > Article > Backend Development > How 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.
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
nginx has been installed and can access
When accessing the .php file, it will be downloaded by default, or it will prompt "File not found.”
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
You can run the command
service php-fpm start
. If it shows that it cannot be recognized, it means it is not installed.
You can execute the installation command:
yum install php-fpm
and then run the commandservice php-fpm start
(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
(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!