与Apache配合使用

  1. LoadModule proxy_module /yyypath/modules/mod_deflate.so
  2. <IfModule deflate_module>
  3. SetOutputFilter DEFLATE
  4. DeflateCompressionLevel 2
  5. AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml
  6. </IfModule>
  7.  
  8. <VirtualHost *:80>
  9. # 别忘了绑Host哟
  10. ServerName www.laravels.com
  11. ServerAdmin hhxsv5@sina.com
  12.  
  13. DocumentRoot /xxxpath/laravel-s-test/public;
  14. DirectoryIndex index.html index.htm
  15. <Directory "/">
  16. AllowOverride None
  17. Require all granted
  18. </Directory>
  19.  
  20. LoadModule proxy_module /yyypath/modules/mod_proxy.so
  21. LoadModule proxy_module /yyypath/modules/mod_proxy_balancer.so
  22. LoadModule proxy_module /yyypath/modules/mod_lbmethod_byrequests.so.so
  23. LoadModule proxy_module /yyypath/modules/mod_proxy_http.so.so
  24. LoadModule proxy_module /yyypath/modules/mod_slotmem_shm.so
  25. LoadModule proxy_module /yyypath/modules/mod_rewrite.so
  26.  
  27. ProxyRequests Off
  28. ProxyPreserveHost On
  29. <Proxy balancer://laravels>
  30. BalancerMember http://192.168.1.1:5200 loadfactor=7
  31. #BalancerMember http://192.168.1.2:5200 loadfactor=3
  32. #BalancerMember http://192.168.1.3:5200 loadfactor=1 status=+H
  33. ProxySet lbmethod=byrequests
  34. </Proxy>
  35. #ProxyPass / balancer://laravels/
  36. #ProxyPassReverse / balancer://laravels/
  37.  
  38. # Apache处理静态资源,LaravelS处理动态资源。
  39. RewriteEngine On
  40. RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
  41. RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
  42. RewriteRule ^/(.*)$ balancer://laravels/%{REQUEST_URI} [P,L]
  43.  
  44. ErrorLog ${APACHE_LOG_DIR}/www.laravels.com.error.log
  45. CustomLog ${APACHE_LOG_DIR}/www.laravels.com.access.log combined
  46. </VirtualHost>