windows apache部署vue项目
时间: 2023-12-12 18:54:36 浏览: 152
要在 Windows 上部署 Vue 项目,你需要使用一个 Web 服务器,例如 Apache,来托管 Vue 应用程序的静态文件。
以下是步骤:
1. 确保你已经使用 `npm run build` 命令在 Vue 项目中生成了生产环境的静态文件。
2. 将 `dist` 文件夹中的所有文件复制到 Apache 的 Web 根目录(例如 `C:\xampp\htdocs`)下。
3. 配置 Apache 以服务于 Vue 应用程序的静态文件。首先,打开 Apache 的配置文件 `httpd.conf`,找到以下行并取消注释:
```
LoadModule rewrite_module modules/mod_rewrite.so
```
4. 在 `httpd.conf` 文件中添加以下配置:
```
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
```
修改上述代码中的 `C:/xampp/htdocs` 为你的 Web 根目录所在的路径。
5. 重启 Apache,然后在浏览器中输入 `http://localhost` 查看 Vue 应用程序是否已经成功部署。
希望这可以帮助你在 Windows 上成功部署 Vue 项目!
阅读全文
相关推荐
















