最近在部署vite的静态项目需要用到apache

docker-compose.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
services:
  apache:
    image: httpd:latest
    container_name: apache_container
    ports:
      - "8888:80"
    volumes:
      - /Users/ll/Desktop/2024/vite-vue-mks/dist:/usr/local/apache2/htdocs
      - ./httpd.conf:/usr/local/apache2/conf/httpd.conf
    restart: always
    command: /bin/bash -c "cat /usr/local/apache2/conf/httpd.conf && httpd-foreground"

httpd.conf

1
2
3
4
5
6
7
8
9
# 包含原始配置
Include conf/original/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so

# 启用 .htaccess
<Directory "/usr/local/apache2/htdocs">
    AllowOverride All
    Require all granted
</Directory>