Create a local server configuration创建本地服务器配置
In the local server configuration, you do your development, then copy the sources to the server.在本地服务器配置中,进行开发,然后将源代码复制到服务器。
A local server is a server that is running in a local or a mounted folder and whose document root is NOT the parent of the project root.“本地服务器”是在本地或装入的文件夹中运行的服务器,其文档根不是项目根的父级。
To configure access to the server in this set-up, you need to specify the following:要在此设置中配置对服务器的访问,您需要指定以下内容:
-
The server configuration root folder and the URL address to access it.服务器配置根文件夹和访问它的URL地址。 -
Correspondence between the project root folder, the folder on the server to copy the data from the project root folder to, and the URL address to access the copied data on the server.项目根文件夹、将数据从项目根文件夹复制到的服务器上的文件夹以及访问服务器上复制数据的URL地址之间的对应关系。This correspondence is called mapping.这种对应关系称为映射。
Specify the name, type, and visibility of a server configuration指定服务器配置的名称、类型和可见性
-
Open the Deployment page by doing one of the following:通过执行以下操作之一打开部署页面:-
In the Settings/Preferences dialog Ctrl+Alt+S, go to .在“设置/首选项”对话框Ctrl+Alt+S中,进入“部署、执行、部署”|“部署”。 -
From the main menu, select从主菜单中,选择“工具”|“部署”|“配置”。 .
-
-
In the left-hand pane that lists all the existing server configurations, click Add
and select Local or mounted folder in the popup menu.
-
In the Create new server dialog that opens, type the name of the server to create and click OK. The Create new server dialog closes and you return to the Connection tab of the Deployment node.
-
Click the Use as Default
to have IntelliJ IDEA silently apply the current configuration in the following cases:
-
Manual upload and download of files without choosing the target host.
-
Comparing local files and folders with their remote versions.
-
Use the Visible only for this project checkbox to configure the visibility of the server access configuration.
-
Select the checkbox to restrict the use of the configuration to the current project. Such configuration cannot be reused outside the current project. It does not appear in the list of available configurations in other projects.
The server records are stored in the .idea directory together with the project, which allows sharing them between team members through a VCS.
In the server access configurations list in the left-hand pane, the configurations visible only in the current project are marked with the
icon.
-
When the checkbox is cleared, the configuration is visible in all IntelliJ IDEA projects.清除复选框后,配置在所有IntelliJ IDEA项目中可见。Its settings can be reused across several projects.它的设置可以跨多个项目重用。
-
Specify the server configuration root and the URL address to access it指定服务器配置根目录和访问它的URL地址
-
Open the Deployment page by doing one of the following:通过执行以下操作之一打开部署页面:-
In the Settings/Preferences dialog Ctrl+Alt+S, go to .
-
From the main menu, select
.
-
-
Click the Connection tab.
-
In the Folder field, specify the server configuration root.
The server configuration root is the highest folder in the file tree on the server that can be accessed through the server configuration. The easiest way is to use the document root of your Web server as defined in the Web server configuration file. However you can appoint any other existing folder under the document root.
-
In the Web server URL field, specify the URL address of the server configuration root. This URL address will be the starting point for building the URL address of your application. Depending on your choice of the server configuration root, do one of the following:
-
Type the URL address associated with the document root of your Web server as defined in the Web server configuration file.
-
Type the URL address in the following format:
<Server document root URL>/<path to the folder relative to the server document root>
Both the HTTP and the HTTPS protocols are supported.
-
Map project folders to folders on the server and the URL addresses to access them将项目文件夹映射到服务器上的文件夹以及访问它们的URL地址
Configure mappings, that is, set correspondence between the project folders, the folders on the server to copy project files to, and the URL addresses to access the copied data on the server. The easiest way is to map the entire project root folder to a folder on the server. The project folder structure in this case will be repeated on the server, provided that you have selected the Create Empty directories checkbox in the Options dialog. For more details, see Configure synchronization with a Web server and Customize upload and download.
-
Open the Deployment page by doing one of the following:
-
In the Settings/Preferences dialog Ctrl+Alt+S, go to .
-
From the main menu, select
.
-
-
Click the Mappings tab.
-
In the Local Path field, specify the full path to the desired local folder. In the simplest case it is the project root.
-
In the Deployment Path field, specify the folder on the server where IntelliJ IDEA will upload the data from the folder specified in the Local Path field. Type the path to the folder relative to the server configuration root.
If the folder with the specified name does not exist yet, IntelliJ IDEA will create it, provided that you have selected the Create Empty directories checkbox in the Options dialog. For more details, see Customize upload and download.
-
In the Web Path field, type the path to the folder on the server relative to the server configuration root. Actually, type the relative path you typed in the Deployment Path field.
Example of specifying a server configuration root指定服务器配置根目录的示例
For example, the server's default document root is the htdocs folder, and the default URL address to access the data is http://localhost. Let's suppose that you are using the XAMPP package and it is installed in the root of the C:/ drive.
If you decide to copy your project files directly under the server document root, your server configuration root will be C:\xampp\htdocs and its URL will be http://localhost:<port>.
You can establish a more complicated folder structure on the server, for example, to have MySite1 and MySite2 folders under the server document root. In this case the you will have to decide which of these folders you will use in the current configuration, let it be MySite2. Accordingly, the server configuration root will be C:\xampp\htdocs\MySite2 and its URL address will be http://localhost:<port>\MySite2.
Example of mapping project folders with folders on the server将项目文件夹与服务器上的文件夹映射的示例
For example, if your project is located under C:\My_Projects\Mapping_project, the server document root is C:\xampp\htdocs, the server configuration root is C:\xampp\htdocs\MySite2, and its URL address is http://localhost:<port>\MySite2, fill in the fields as follows:
-
In the Local Path field, type C:\My_Projects\Mapping_project.
-
In the Deployment Path field, type
MySite2
. -
In the Web Path field, type
MySite2
.