# Deployment # 部署 When you are ready to deploy your Angular application to a remote server, you have various options for deployment. 当你准备把 Angular 应用部署到远程服务器上时,有很多关于部署的选项。 {@a dev-deploy} {@a copy-files} ## Simplest deployment possible ## 最简化的部署方式 For the simplest deployment, build for development and copy the output directory to a web server. 最简化的部署方式就是为开发环境构建,并把其输出复制到 Web 服务器上。 1. Start with the development build: 使用开发环境进行构建 ng build 2. Copy _everything_ within the output folder (`dist/` by default) to a folder on the server. 把输出目录(默认为 `dist/`)下的*每个文件*都复制到到服务器上的某个目录下。 3. Configure the server to redirect requests for missing files to `index.html`. Learn more about server-side redirects [below](#fallback). 配置服务器,让缺失的文件都重定向到 `index.html` 上。 欲知详情,参见[稍后](#fallback)的服务端重定向部分。 This is _not_ a production deployment. It's not optimized, and it won't be fast for users. It might be good enough for sharing your progress and ideas internally with managers, teammates, and other stakeholders. For the next steps in deployment, see [Optimize for production](#optimize). 这*不是*生产环境部署。它没有优化过,对最终用户来说也不快。 但是,这足够用来跟管理者、团队成员和其它涉众在内部分享你的进度和想法了。 部署的下一个步骤,参见[为生产环境优化](#optimize)。 {@a deploy-to-github} ## Deploy to GitHub pages ## 发布到 GitHub pages(页面服务) Another simple way to deploy your Angular app is to use [GitHub Pages](https://help.github.com/articles/what-is-github-pages/). 另一种发布 Angular 应用的简单途径是使用 [GitHub Pages](https://help.github.com/articles/what-is-github-pages/)。 1. You need to [create a GitHub account](https://github.com/join) if you don't have one, and then [create a repository](https://help.github.com/articles/create-a-repo/) for your project. Make a note of the user name and project name in GitHub. 你需要[创建一个 GitHub 账号](https://github.com/join)(如果没有的话),然后为你的项目[创建一个仓库](https://help.github.com/articles/create-a-repo/)。记下 GitHub 中的用户名和项目名。 1. Build your project using Github project name, with the Angular CLI command [`ng build`](cli/build) and the options shown here: 使用 Angular CLI 命令 [`ng build`](cli/build) 来构建这个 GitHub 项目,选项如下: ng build --prod --output-path docs --base-href 1. When the build is complete, make a copy of `docs/index.html` and name it `docs/404.html`. 当构建完成时,把 `docs/index.html` 复制为 `docs/404.html`。 1. Commit your changes and push. 提交你的更改,并推送。 1. On the GitHub project page, configure it to [publish from the docs folder](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch). 在 GitHub 的项目页中,把该项目配置为[从 docs 目录下发布](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch)。 You can see your deployed page at `https://.github.io//`. 你可以到 `https://.github.io//` 中查看部署好的页面。