Created
June 18, 2020 13:53
-
-
Save vanduc1102/3b6449a9112442ee28f1e73b9c75bac5 to your computer and use it in GitHub Desktop.
PHP .htaccess environment variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_security.c> | |
SecFilterEngine Off | |
SecFilterScanPOST Off | |
</IfModule> | |
# BEGIN WordPress | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [L] | |
</IfModule> | |
# END WordPress | |
SetEnv DB_NAME test | |
SetEnv DB_USER root | |
SetEnv DB_PASSWORD test | |
SetEnv DB_HOST db | |
php_value upload_max_filesize 12800M | |
php_value post_max_size 12800M | |
php_value memory_limit 2560M | |
php_value max_execution_time 30000 | |
php_value max_input_time 30000 | |
Any apache custom file: custom.conf
Listen 7001
<VirtualHost *:7001>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/site-a
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv DB_NAME site-a
</VirtualHost>
Listen 7002
<VirtualHost *:7002>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/site-b
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv DB_NAME site-b
</VirtualHost>
Listen 7003
<VirtualHost *:7003>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/site-c
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
SetEnv DB_USER root
SetEnv DB_PASSWORD test
SetEnv DB_HOST db
can be access via $_SERVER['DB_HOST']
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ref: https://stackoverflow.com/questions/17550223/set-an-environment-variable-in-htaccess-and-retrieve-it-in-php