Configure database information under nginx and Apache servers

Source: Internet
Author: User

Configure the Database Configuration directly under Apache:

1) first, in httpd. conf under Apache

# Secure (SSL/TLS) connections
Include CONF/extra/httpd-ssl.conf

Introduce below (Database profile db-info.conf)
Include CONF/extra/db-info.conf

2) configure the database configuration file db-info.conf (no ";" after each sentence)

Where

Setenv is the configuration method below Apache:

Official manual:

Setenv command

Note: Set Environment Variables
Syntax: SETENV  name value
Background: Server configuration, virtual host, directory ,. Htaccess File
Overwrite: Fileinfo
Status: Base
Module: Mod_env

This module allows Environment Control for CGI scripts and SSI pages. Environment variables can be called from ShellhttpdProcess. In addition, it may be environment variable setting or not set during configuration.

3) test phpinfo ()

The configured system variables indicate that the configuration is successful.


Configuration Under nginx

1) first


Add the include db-info.conf; Introduce the configuration file

2) configure the db-info.conf file (note that each sentence is followed by a semicolon, Apache does not have this)



Fastcgi_param

Syntax: fastcgi_param Parameter
Value
Default Value: None
Field used: HTTP, server, location

Specify parameters passed to the FastCGI server.

You can use strings, variables, or their combinations. The settings here do not inherit from other fields. The settings in the current field will clear any previous definitions.

Below are the minimum parameters required for a PHP:

fastcgi_param  SCRIPT_FILENAME  /home/www/scripts/php$fastcgi_script_name;fastcgi_param  QUERY_STRING     $query_string;

PHP uses the script_filename parameter to determine which script to execute. QUERY_STRING contains some parameters in the request.

To process a POST request, you need to add three other parameters:

fastcgi_param  REQUEST_METHOD   $request_method;fastcgi_param  CONTENT_TYPE     $content_type;fastcgi_param  CONTENT_LENGTH   $content_length;

If PHP has-enable-force-CGI-redirect during compilation, the redirect_status parameter with a value of 200 must be passed:

fastcgi_param  REDIRECT_STATUS  200;

An official instance:

location / {  fastcgi_pass   localhost:9000;  fastcgi_index  index.php;   fastcgi_param  SCRIPT_FILENAME  /home/www/scripts/php$fastcgi_script_name;  fastcgi_param  QUERY_STRING     $query_string;  fastcgi_param  REQUEST_METHOD   $request_method;  fastcgi_param  CONTENT_TYPE     $content_type;  fastcgi_param  CONTENT_LENGTH   $content_length;}

3) phpinfo () is successfully used to test the configuration ()


See Add yourself
Variable successful


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.