Teach you step by step how to use phpstudy to quickly build a website locally and access it from the outside [no public IP]


This tutorial is to quickly build a web website in a local environment and make it accessible in an external network environment! !


use tools

  • phpstudy (build a web website locally)
  • cpolar intranet penetration (publish the website to the public network for access)

1. Build a local web website

1.1 Download phpstudy, unzip and install it

Official website download:https://www.xp.cn/download.html

The effect after installation, as shown in the figure:

1

Click the 启动 button next to WNMP to start nginx and MYSQL 5.7 by default. During the startup process, if there is a firewall prompt, just allow it.

2

1.2 Open the default site and test

In the PHPStudy panel –网站–select the default site of localhost 80, click 管理, a drop-down menu will pop up, select 打开网站, the browser will pop up and open the local default site http://localhost

3

As shown in the picture below, the installation is successful.

4

1.3 Download static demo site

下载:https://www.cpolar.com/static/downloads/meditation-app-master.zip

After downloading, unzip and copy all files in the directory, as shown below

5

1.4 Open the site root directory

We find and open the root directory of the website

6

defaults to D:\phpstudy_pro\WWW, we will delete all files in the directory, as shown below

7

1.5 Copy the demo site to the root directory of the site network

Copy all the files of our demo site to this directory, as shown below after copying:

8

1.6 In the browser, view the demonstration effect.

This website can only be accessed within the local LAN at this time and cannot be accessed from the public network yet.

9

2. Publish the local web website to the public network

To publish a locally built website to the public network for access, you can use intranet penetration to achieve this. I choose to use cpolar intranet penetration here, which supports http/https/tcp protocols, does not limit traffic, and can be used for free. No need There is no need to set up a router for public IP, so it is relatively simple to use.

2.1 Install cpolar intranet penetration

cpolar intranet penetration official website:https://www.cpolar.com/

Click to enter the cpolar official website, click免费使用 to register an account and download the latest version of cpolar

  • Download the zip compressed package on Windows system, unzip it to get the cpolar installation package, and then double-click the installation package to install it by default;
  • The Linux system supports one-click automatic installation script;
  • Download the zip package on macOS system, unzip it to get cpolar, and then run it with parameters through the command line.

To install cpolar on Linux systems and macOS systems, please refer to the official website documentation tutorial————→https://www.cpolar.com/docs

2.2 Mapping intranet ports

After the cpolar installation is completed, access 127.0.0.1:9200 on the browser and log in to the web UI using the cpolar account.

web ui

After successfully logging in and entering the main interface, click隧道管理—— on the left dashboard创建隧道

  • Tunnel name: Customizable name, be careful not to repeat it
  • Protocol: Selecthttp
  • Local address: 80 (fill in the intranet port you want to map)
  • Domain name type: free user choice随机域名, paying users can configure a fixed second-level subdomain name or a custom domain name
  • Region: SelectChina vip

then click创建

Insert image description here

2.3 Enable public network access to local web sites

After the tunnel is successfully created, you can view the public network address of the tunnel just created in 状态——在线隧道列表 on the left dashboard. Two lines, one for http protocol and one for https protocol.

Insert image description here

Just copy the public network address to the browser to access it, and successfully access the local website from the public network.

13

PS: It should be noted that since we are using free cpolar this time, the generated public network address is a random temporary address, which will change every 24 hours, and the bandwidth is small, which is more suitable for development and testing. If you want to set the access address to a fixed one, you can upgrade the cpolar package configuration to support a 21-day money-back guarantee. For details, please refer to the next article tutorial.

Reprinted from cpolar pole cloud article:phpstudy quickly builds a website locally and accesses it from the outside [no public IP]

Guess you like

Origin blog.csdn.net/fq157856469/article/details/133706706