Use LightPicture open source to build a private picture bed: detailed tutorial and remote access configuration method

1 Introduction

Today's mobile phones are becoming more and more advanced and have more and more functions. The camera functions of mobile phones are becoming more and more powerful, and the photos taken are getting clearer and clearer, but the size of digital photos has also skyrocketed. For people like me who often take photos, mobile phone capacity often warns, so I transformed my home computer into a picture server that can be uploaded, downloaded and accessed at any time. Today, the author will show you how to use the combination of Cpolar intranet penetration and Lightpicture to transform a personal computer into a picture server that can upload, download or access at any time, and can generate external links.

2. Lightpicture website construction

Lightpicture is an open source lightweight image bed system that not only supports local image storage, but can also configure third-party cloud disks as storage space. Of course, it also supports multi-user registration, making it an independent picture website. The most important thing is that Lightpicture has a very good appearance and is very comfortable to look at. Now, let's get started.

2.1. Lightpicture download and installation

The download website of Lightpicture cannot be opened (I wonder if it is due to lack of maintenance), so the author found a download on the Internet ( https://bbs.liuxingw.com/t/47221.html ). Of course, CSDN members also download it. Anyway, as long as the Lightpicture file is downloaded. After downloading the Lightpicture source code, unzip it.

20230524091301

Paste the entire unzipped folder into the root directory of the website. The author uses the phpstudy integrated panel, so the lightpicture folder is placed under the WWW folder of phpstudy.

20230524091302

Then, open it phpstudy, click the button on the left side of the main interface of the software 网站to enter the website list page, and then click the button on the upper left side of the website list page 创建网站to enter the settings page of the new website.

On the website settings page, there are not many things we need to set. We only need to set

  • 域名- The domain name entered when opening the Lightpicture file manager locally can be entered at will;
  • 端口- The web page output port of the Lightpicture file manager can be used as long as it is not occupied;
  • 根目录– That is the location where the web files of the Lightpicture file manager are stored. In this example, the author places these files under the www folder of phpstudy; it should be noted that the root directory cannot only point to the lightpicture folder, but must point it to The public folder under the lightpicture folder.
  • 程序类型– Since the Lightpicture file manager is a lightweight web program and requires php7.2.5 and above to run, the author chose php7.2.9. Note: Lightpicture needs to enable PDO, fileinfo, and curl extensions of PHP, otherwise it may cause website errors.
  • 数据库– Lightpicture requires database support when running, so you can check the “Create Database” field during website settings to create a database used by lightpicture.

After completing the relevant settings, you can click the button at the bottom 确认to save the settings of the Lightpicture web page.

20230524091303

After the basic settings of the web page are completed, we still need to modify it 重写规则(Rewrite), otherwise when we log in to the website, a user login error will be displayed. Apache and Nginx are as follows:

  • Apache:
<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
  RewriteCond %{
    
    REQUEST_FILENAME} !-d
  RewriteCond %{
    
    REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
  • Nginx:
location / {
    
     
   if (!-e $request_filename) {
    
    
       rewrite  ^(.*)$  /index.php?s=/$1  last;
    }
}

Since the author is using Nginx, in the public folder under the lightpicture website folder, find nginx.htaccessthe file named and paste the above Nginx code into it.

20230524091304

Then, enter it in the browser 域名:installto start the installation process. The installation process is simple, just 下一步go all the way.

20230524091305

20230524091306

20230524091307

After completing the installation, if you log in directly to the lightpicture website, it will be displayed未设置默认文档

20230524091308

Here we only need to click on the right side of the lightpicture website entry in phpstudy 管理and 网站首页设置paste index.phpit in index.htmlto modify the weight of the index.html document. At the same time, the PHP extension can also be opened in the management button on the right side of the website entry.

20230524091309

20230524091310

2.2. Lightpicture web page test

After completing the above steps, enter it in the browser address bar again 域名+端口号(笔者输入的是localhost:82)to access the local lightpicture web page.

20230524091311

It should be noted that lightpicture comes with a default administrator account (user name admin, password 123456). After we log in with the administrator account, we must remember to modify it.

20230524091312

2.3.cpolar installation and registration

After completing the construction of the lightpicture image bed, you can move to the installation of cpolar intranet penetration. Compared with lightpicture website settings, the installation and registration of cpolar intranet penetration is much simpler. We directly visit cpolar’s ​​official website page ( https://www.cpolar.com/ ) to find 下载the button.

20230524091313

The author is using the Windows operating system, so I chose the Windows version to download.

After the Cpolar download is completed, unzip the downloaded file and double-click the unzipped .msifile to automatically execute the installation program. Then it only takes one step Nextto complete the installation.

20230524091315

20230524091316

cpolar will create an independent data tunnel for each user, and add the user password and token code to ensure data security. Therefore, user registration is required before using cpolar. The registration process is very simple. Just click on the upper right corner of the cpolar homepage 用户注册and fill in the necessary information on the registration page to complete the registration.

20230524091317

20230524091318

3. Local web page publishing

At this point, we have completed the local test of lightpicture and installed the cpolar intranet penetration program. Next, we can use cpolar to create a public Internet address that can connect to the local lightpicture, so that we can access lightpicture on the public Internet. Image bed website.

3.1.Cpolar cloud settings

Since the picture bed website needs to be online for a long time, and the data tunnel created by the free version of cpolar will be reset every 24 hours, the author does not want to reset the data tunnel every day, so I upgraded cpolar to the VIP version so that I can have long-term and stable access to the lightpicture website. Next, we can start penetrating the LAN at home and penetrating the local lightpicture bed into the intranet.

To achieve the purpose of intranet penetration, you need to log in to cpolar's official website first, find the 预留button on the left side of the user's home page, and click to enter cpolar's data tunnel reservation page. A public Internet address is generated here (it can also be regarded as the entrance of the data tunnel). Since this address has not yet connected to the local lightpicture website, it can also be regarded as a blank data tunnel.

20230524091319

On the reservation page, you can see many types of data tunnels that can be reserved. Here we select 保留二级子域名the field.

20230524091320

In 保留二级子域名the fields, several simple settings of information need to be made, namely

  • 地区(Select the area where the server is located)
  • 二级域名(will eventually appear in the generated public Internet address as one of the identifiers of the network address)
  • 描述(It can be regarded as a description of the data tunnel, as long as it can be distinguished from other tunnels).

After completing these settings, you can click 保留the button on the right to retain this data tunnel.

20230524091321

Of course, if the data tunnel is not going to be used, you can click the "x" on the right to easily delete it, saving valuable data tunnel quota.

20230524091322

3.2.Cpolar local settings

After completing the settings of the cpolar cloud and retaining the blank data tunnel, we returned to the local cpolar client and connected the blank data tunnel generated by the cloud to the local lightpicture page, allowing us to access the local lightpicture website on the public Internet.

Open and log in to the cpolar client locally (you can enter localhost:9200 in the browser to access it directly, or you can click the cpolar client shortcut in the start menu).

20230524091323

Click the button under the item on the left side of the client's main interface to enter the local tunnel creation page (if you want to create a temporary data tunnel that resets the address every 24 hours, you can make the same settings directly on the cpolar local client instead of setting a blank on the cpolar 隧道管理official website 创建隧道data tunnel).

On this page, you also need to make several information settings, which include:

  • 隧道名称– It can be regarded as cpolar’s ​​local tunnel information annotation, which is convenient for us to distinguish;
  • 协议– Since lightpicture is a web program, the http protocol is selected;
  • 本地地址– The local address is the output port number of the lightpicture image bed, and the port we set is 82, so fill in 82 here;
  • 域名类型– In this example, we have reserved the data tunnel of the second-level subdomain name in the cpolar cloud, so check "Second-level subdomain name" (if the reserved domain name is a custom domain name, check the custom domain name). And fill in the reserved second-level subdomain name in the "Sub Domain" column on the next line, which is "lightpicweb" in this example. If you plan to create a temporary data tunnel, directly check "Random domain name" and let the cpolar client generate the network address by itself;
  • 地区– Just like the information reserved in cpolar cloud, we can fill it in according to the actual place of use;

After completing these settings, you can click 创建the button at the bottom of the page to connect the blank data tunnel on the cpolar cloud with the local lightpicture page, thus generating an intranet penetration data tunnel that can access the local lightpicture image bed on the public Internet.

20230524091324

We can manage this data tunnel on the page 隧道管理under the item 隧道列表, including opening, closing, or deleting this tunnel. We can also click the "Edit" button to modify the information of this data tunnel.

20230524091325

4. Public network access test

Finally, we click the button 状态under the left item 在线隧道列表to find the public Internet address of the lightpicture page. Paste this address into the browser to see the lightpicture page on the local computer.

20230524091326

20230524091327

5 Conclusion

As an indispensable auxiliary website for modern websites, the image bed is of self-evident significance for self-built websites. However, since this business is not profitable, major Internet companies have gradually shut down this business, making self-built image beds an inevitable choice. Of course, there are thousands of picture-sharing software, and we can use the same method to publish other picture-sharing websites to the public Internet.

Reprinted from cpolar pole cloud article: [Build a private picture bed] Use LightPicture open source to build a picture management system and access it remotely

Guess you like

Origin blog.csdn.net/bushibrnxiaohaij/article/details/132672159