apache2 安装与配置

 者之梦  2019-08-26T14:43:13.697Z  其他  0

apache2

安装

apt install apache2
cd /ect/apache2

主配置文件 apache2.conf

vi /ect/apache2/apache2.conf ## 主配置文件
line:160 左右 配置站点 推荐创建 www 用户 下面放项目

  1. <Directory /home/www/xxx>
  2. Options Indexes FollowSymLinks
  3. AllowOverride None
  4. Require all granted
  5. </Directory>

line:189 AccessFileName .htaccess ## 路由重写文件

间这段 添加进入 配置 重要 安全

  1. <DirectoryMatch .*\.svn|.git|_svn/.*>
  2. RewriteEngine On
  3. RewriteRule ^(.*)(\.svn|.git|_svn)(/.*)$ /index.php [R=301]
  4. </DirectoryMatch>

监听端口

vi /ect/apache2/ports.conf
Listen 80
Listen 8080

配置站点

  1. <VirtualHost *:2030>
  2. # The ServerName directive sets the request scheme, hostname and port that
  3. # the server uses to identify itself. This is used when creating
  4. # redirection URLs. In the context of virtual hosts, the ServerName
  5. # specifies what hostname must appear in the request's Host: header to
  6. # match this virtual host. For the default virtual host (this file) this
  7. # value is not decisive as it is used as a last resort host regardless.
  8. # However, you must set it for any further virtual host explicitly.
  9. #ServerName www.example.com
  10. ServerAdmin webmaster@localhost
  11. DocumentRoot /var/www/html
  12. DocumentRoot /home/www/ams/www
  13. # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
  14. # error, crit, alert, emerg.
  15. # It is also possible to configure the loglevel for particular
  16. # modules, e.g.
  17. #LogLevel info ssl:warn
  18. ProxyPass /ahgraphql http://127.0.0.1:7200
  19. ProxyPassReverse /ahgraphql http://127.0.0.1:7200
  20. ErrorLog ${APACHE_LOG_DIR}/error.log
  21. CustomLog ${APACHE_LOG_DIR}/access.log combined
  22. # For most configuration files from conf-available/, which are
  23. # enabled or disabled at a global level, it is possible to
  24. # include a line for only one particular virtual host. For example the
  25. # following line enables the CGI configuration for this host only
  26. # after it has been globally disabled with "a2disconf".
  27. #Include conf-available/serve-cgi-bin.conf
  28. Alias /api "/home/www/ams/webpage/api"
  29. </VirtualHost>
  30. # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

反向代理&Alias

link : https://www.jianshu.com/p/47eca94680aa
加载 模块 重启
a2enmod proxy proxy_balancer proxy_http

  1. ProxyPass /ahgraphql http://127.0.0.1:7200
  2. ProxyPassReverse /ahgraphql http://127.0.0.1:7200
  3. Alias /api "/home/lhz/wwwroot/ams/webpage/api"
  4. 反向代理 / , Alias 将无效

运行用户

link:
https://blog.csdn.net/huangwu_188/article/details/78213153
ubuntu 18.10
vi /etc/apache2/envvars

gzip压缩

  1. <IfModule deflate_module>
  2. AddOutputFilterByType DEFLATE application/json application/javascript text/css text/html text/javascript text/plain text/xml
  3. </IfModule>

重启 apache2

/etc/init.d/apache2 restart

者之梦
文章分类
列表内容 1
列表内容 2
列表内容 3
列表内容 4
热门标签
标签一(11) 标签二(21) 标签三(24) 标签四(21) 标签五(31)