Docker locally deploys Drupal and achieves public network access

Preface

Dupal is a powerful CMS suitable for a variety of different website projects, from small personal blogs to large enterprise-level portals. It may have a relatively steep learning curve, but once familiar with how it works, users will be able to take full advantage of its functionality and flexibility. In this article, we will introduce how to use Docker to quickly deploy Drupal, and combine it with the cpolar intranet penetration tool to achieve remote access to the public network

First, you need to install Docker on your machine and start it. You can install it according to the instructions in the official Docker documentation.

1. Docker installation of Drupal

Before docker deploys Drupal, you need to install a database first. Select mysql for the database. If mysql is already installed locally, you can skip it. The following command uses docker to start a mysql database.

docker run --network host -e MYSQL_ROOT_PASSWORD=自己设置密码 \
-v /etc/mysql/data:/var/lib/mysql \
-v /etc/mysql/conf.d:/etc/mysql/conf.d \
--name mysql \
-d mysql:latest

After deploying and starting the database, deploy Drupal, execute the following command, and run the container directly. In order to facilitate database connection, specify the host network:

docker run --network host  --name my-drupal  -d drupal:latest

After executing and waiting for docker to start, enter docker ps to see the running Drupal container, and also see the mysql container running.

image-20231010103211359

2. Local LAN access

After the installation is running, access port 80 in the browser and you will see the Drupal installation interface. Drupal will be deployed and installed successfully. Next, we will continue to install the cpolar tool, complete remote access, and then configure Drupal.

image-20231010095146640

3. Linux installation cpolar

Above we successfully installed Drupal in docker, and the LAN access is ok. Next we install the cpolar intranet penetration tool on Linux, and forward the http public network address mapped by the local port through cpolar. We can easily achieve remote access without having to do it ourselves. Register a domain name and purchase a cloud server. The following are the steps to install cpolar

cpolar official website address: https://www.cpolar.com

  • Use one-click script installation command
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
  • Add services to the system
sudo systemctl enable cpolar
  • Start cpolar service
sudo systemctl start cpolar

After cpolar is successfully installed, access Linux port 9200 on an external browser: [http://LAN ip:9200]. Log in using your cpolar account. After logging in, you can see the cpolar web configuration interface, which is connected to the web management interface. Just configure

image-20230831171159175

4. Configure Drupal public network access address

Click Tunnel Management - Create Tunnel on the left dashboard to create a Drupal cpolar public network address tunnel!

  • Tunnel name: The name can be customized. Be careful not to duplicate the existing tunnel name.
  • Protocol: Select http
  • Local address: 80 (port for LAN access)
  • Domain name type: Choose a random domain name for free
  • Region: Select China

Click创建

image-20231010103555887

After the tunnel is successfully created, click the status on the left - online tunnel list to view the generated public network access address. There are two access methods, one is http and https

image-20231010103648807

5. Remote access to Drupal via public network

Use the above cpolar https public network address to access it in the browser of any device, and you can successfully see our Drupal interface. Such a public network address that can be accessed remotely is created. Next, set up Drupal, select Simplified Chinese as the language, and select click afterSave and continue

image-20231010103755055

Then choose standard installation

image-20231009160519704

Next, set the database, select mysql database as the database type, then enter the database name (can be customized), then fill in the database user name, default: root, then fill in the database password, then open the advanced options, fill in the Linux device LAN IP address for the host parameter ( means connecting to a local database), after filling in, click the button at the bottom保存并继续

image-20231010104413275

Then wait for the installation to complete

image-20231009162221138

After the installation is completed, we can successfully see the Drupal interface and use cpolar's public domain name. We can publish it to the public network for access without purchasing a cloud server ourselves. For subsequent Drupal gameplay, you can refer to the official documentation to learn!

image-20231010104804477

6. Fixed Drupal public network address

Since the tunnel created using cpolar above uses a random public network address, it will change randomly within 24 hours, which is not conducive to long-term remote access. Therefore, we can configure a second-level subdomain name for it. This address is a fixed address and will not change randomly [ps: cpolar.cn has been filed]

Note that you need to upgrade the cpolar package to a basic package or above, and the bandwidth corresponding to each package is different. [cpolar.cn has been registered]

Log in to the cpolar official website, click Reserve on the left, select to reserve the second-level subdomain name, set a second-level subdomain name, click Reserve, and copy the reserved second-level subdomain name after the reservation is successful. Level subdomain name

image-20231010105350522

After the reservation is successful, copy the name of the second-level subdomain name that was successfully reserved.

image-20231010105414475

Return to the cpolar web UI management interface, click Tunnel Management - Tunnel List on the left dashboard, find the tunnel you want to configure, and click Edit on the right

image-20231010105511687

Modify the tunnel information and configure the successfully reserved second-level subdomain name into the tunnel.

  • Domain name type: Select a second-level subdomain name
  • Sub Domain: Fill in the successfully reserved second-level subdomain name

Click更新(Note, click once to update, no need to submit again)

image-20231010105622801

After the update is completed, open the online tunnel list. At this time, you can see that the public network address has changed and the address name has become a fixed second-level subdomain name.

image-20231010105652875

Finally, we use a fixed public network address to access, and we can see that the access is successful. In this way, a fixed and permanent public network address is set.

image-20231010105722014

Guess you like

Origin blog.csdn.net/st200112266/article/details/134320633