Built-in web server
IntelliJ IDEA has a built-in web server that can be used to preview and debug your application. This server is always running and does not require any manual configuration. All the project files are served on the built-in server with the root URL http://localhost:<built-in server port>/<project root>, with respect to the project structure.
Integration with the built-in Web server is supported in IntelliJ IDEA 11.1 and later.
Open a file in a web browser
To open a file that is intended to be rendered by a web browser (HTML, XML, JSP, and so on), do one of the following:
Right-click a file and select Open in Browser.
From the main menu, select View | Open in Browser.
Use the browser popup in the top right part of the editor window. Click the browser button to open the web server file URL, or Shift+Click it to open the local file URL.
The Open in Browser action is not available for other file types. However, you can still execute it using Find Action Ctrl+Shift+A.
If a Deployment server is defined for this project and marked as default, the file will be served from this server instead. If necessary, you can still open the page via the IntelliJ IDEA built-in web server. To do this, open the desired browser and type the URL of the file with respect to the project structure, using http://localhost:<built-in server port>/<project root> as the root URL.
Configuring the built-in web server
Use the PHP built-in web server on macOS
On macOS, you may get the php-cgi not found error when trying to use the built-in server. This indicates that IntelliJ IDEA is configured to use the PHP interpreter bundled with macOS, which does not contain the php-cgi module.
To be able to use the PHP built-in web server, do the following: