Publish project to Apache by phpstorm under Ubuntu 16.04


What I found on the Internet is not reliable. After a long time, I finally found the right posture QAQ, which is just for backup.

By the way, JetBrains is a magic company. Their entire series of ides are the best ones, which are highly recommended for learning. The official Android studio like Google is also based on their ide. I think it’s much better than eclipse. The most important thing is that it’s beautiful and easy to interact
1、 New project

1. New project

File – > new project. Select PHP empty project
2. Determine the project directory

In the location column, you can click the… Button on the right to select the directory or manually type
3. Determine the PHP version

PHP language level bar
4. Determine the PHP interpreter

CLI interpreter bar

Partial layout of new project
Publish project to Apache by phpstorm under Ubuntu 16.04

2、 Edit project

You can output anything in index.php by calling phpinfo()

3、 Deployment configuration

Tools – > deployment – > configuration in the top menu

Open the following figure

Publish project to Apache by phpstorm under Ubuntu 16.04

Click the green plus sign + in the upper left corner, select local or mounted folder as the type, and click OK

In the following figure, the folder under the upload / download project files column is the project upload directory. Here you need to select your Apache root directory under Ubuntu, which I set as / var / www

The web server root URL below is the root link when starting the browser. Here, I set it to http://localhost. When I run index.php of my project root directory under phpstorm, phpstorm will automatically open the web page with the URL of http://localhost/index.php for me in the browser

Publish project to Apache by phpstorm under Ubuntu 16.04

Select the mapping tab

Local path is your local project directory

Deployment path on server is the relative directory of the upload directory set in the previous step. For example, if I don’t fill in anything here, or just fill in a /, then all the projects will be put into the / var / www directory after I publish. The index.php path of the project is / var / www / index.php. If I fill in / test, the subdirectory test will be created in / var / www before publishing, and then the project file will be published to this tes Under directory T, the path of index.php is / var / www / test / index.php

WebPath on server is the relative access path. Previously, we set the root URL of web server. Here, we set the path of the relative URL. For example, if it is set as test, the browser will automatically open the URL “http: / / localhost / test / the file name you want to run” after publishing. If you don’t fill in anything, the URL will be “http: / / localhost / the file name you want to run”

So here we should pay attention to the following points: Apache’s Web service directory, web access root path web server root URL, project publishing directory deployment path on server, and relative access path WebPath on server. These four must be configured correctly
Publish project to Apache by phpstorm under Ubuntu 16.04

Click OK

For convenience, you can also select Tools > deployment > automatic upload from the top menu, so that when you edit and save, phpstorm will automatically publish the project to the directory you just specified.

Four, operation

Put the mouse on the edit page of index.php, and a row of browser icons will pop up in the upper right corner. Click the browser you want to run, PHP will open the browser for you and automatically open the URL you set previously

Publish project to Apache by phpstorm under Ubuntu 16.04
Publish project to Apache by phpstorm under Ubuntu 16.04
You can also try to use the shortcut key Ctrl + Shift + F10 to run. Under firfox, you can use Ctrl + w to close the current window and ALT + tab to switch between windows.

Learn more and use the shortcut key to look more professional = 3=