Nginx Configuration PHP environment, and test whether PHP can connect MySQL

Source: Internet
Author: User
Tags configuration php php and mysql

Nginx configuration file:

server {        listen        80;            root       /var/www/html;        server_name  localhost;         charset utf-8;         index  index.html index.htm index.php;         location ~ .*. (PHP|PHP5)?${            fastcgi_pass  127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param   script_filename   $document _root$fastcgi_script_name;             include fastcgi.conf;             }}

The parameters of the $document _root are defined by the root/var/www/html line.

View Log found error: mysql_connect ()

Call to undefined function mysql_connect () in/var/www/html/test.php on line 2 "while reading response headers from Upstrea M

May be due to a lack of php-mysql plug-ins, you can install Yum, and then restart the PHP-FPM service

Test whether Nginx and PHP are connected successfully:

Vim test.php<?php phpinfo ();?>

Test whether PHP and MySQL are connected successfully:

Vim testdb.php<?php $link =mysql_connect (' 127.0.0.1 ', ' root ', ' 123456 ');  if (! $link) echo "fail";  else echo "Success"; ?>




Nginx Configuration PHP environment, and test whether PHP can connect MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.