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 Shellhttpd
Process. 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