Use CFimagehost source code to build a free PHP image hosting private image bed without database support.

1 Introduction

The image server is also called the image server. It can be said to be one of the most important applications in Internet storage. Not only do websites need the external links provided by the image server to retrieve images, but individuals or businesses also use the image server to store various images for easy access and viewing at any time. . However, because image beds are not very profitable, major Internet companies are gradually shutting down their image bed servers. This has also resulted in users having to find ways to build their own image bed servers. Today, the author will introduce to you how to use Cpolar+ CFImagehost to build a simple and easy-to-use private image bed.

2. CFImagehost website construction

CFImagehost is a very well-known image hosting program abroad, and many people use it in China. Its appearance design and functional layout are simple and easy to use, making it very user-friendly. However, the fly in the ointment is that CFImagehost currently does not have an official Chinese version, resulting in imperfect Chinese display of some pages. In any case, CFImagehost is still an image hosting program worth using.

2.1 CFImagehost download and installation

CFImagehost is an open source program, so we can find it for download on github ( https://github.com/wbbim/cfimagehost-on-openshift ). At the same time, there are also many Chinese-CFImagehost source codes on the Internet, you can choose according to your needs.

20230526091301

After the download of CFImagehost is completed, unzip the downloaded compressed package to get the source code folder of CFImagehost. Paste this folder under the website folder. I am using the phpstudy integrated panel, so paste the CFImagehost folder under phpstudy WWW文件夹.

20230526091302

20230526091303

Then, open phpstudy, click 网站the button on the left side of the main interface of the software to enter the website list page, click the button on the upper left side of the website list page 创建网站, and 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 CFImagehost website locally can be entered at will;
  • 端口- The web page output port of the CFImagehost website can be used as long as it is not occupied;
  • 根目录– That is the location where the CFImagehost website files are stored. In this example, the author places these files in the www folder of phpstudy;
  • 程序类型– Since the CFImagehost website is a lightweight web program and requires php5X or above to run, the author chose php7.2.9 (Note: After actual testing, I feel that php5.6 has better compatibility, you can choose according to the actual situation).
  • 数据库– It is not necessary to configure the database when setting up the CFImagehost website. The database will also be configured during the website installation process. However, in order to save installation time, the author chose to set the database information at this time.

Note: Regarding pseudo-static rules, Apache comes with pseudo-static rules, so there is no need to make additional settings (the author also chose Apache as the web page program). But if you use Nginx as a web page program, you need to write the following code into the pseudo-static rule.

rewrite /pm-(.*)\.(jpg|png|gif|html)$ /index.php?pm=$1;
rewrite /pt-(.*)\.(jpg|png|gif|html)$ /index.php?pt=$1;
rewrite /dt-(.*)\.(jpg|png|gif)$ /index.php?dt=$1;
rewrite /dm-(.*)\.(jpg|png|gif)$ /index.php?dm=$1;
rewrite /di-(.*)\.(jpg|jpeg|png|gif|bmp)$ /index.php?di=$1;
rewrite /gallery/(.*)\/$ /gallery.php?p=$1;

After completing the relevant settings, you can click the button at the bottom 确认to save the settings of the CFImagehost website.

20230526091304

Then we enter it in the browser address bar 本地地址:端口号(here the author enters localhost:82) to enter the installation program of the CFImagehost website. The website installation process is no different from other websites, just follow the prompts on the web page.

20230526091305

20230526091306

Here, CFImagehost will check the installation environment. What we need to pay attention to is that php GDand cURLtwo extensions need to be turned on.

20230526091307

In this step, CFImagehost will check the database. If there is no database set up in pgpstudy, CFImagehost will set up the database in this step.

20230526091308

After the CFImagehost website is installed, we return to the root directory of CFImagehost and installdelete the entire folder. Otherwise, the CFImagehost website installation page will be displayed repeatedly when accessing the CFImagehost website.

20230526091309

2.2 CFImagehost web page test

After completing the installation of the CFImagehost website, we enter (localhost:82) in the browser address bar 本地地址:端口号to open the main page of the CFImagehost website. In the upper right corner of the main page, you can select the website language.

20230526091310

If you want to enter the backend page of the CFImagehost website, you need to add it after the local address of the CFImagehost website admin.php. On the background page, you can make detailed settings for the CFImagehost website. The default background administrator login name of CFImagehost is admin, and the login password is password. After entering the CFImagehost background, the administrator username and password should be modified promptly.

20230526091311

20230526091312

2.3 Installation and registration of cpolar

After completing the CFImagehost website settings, you can move to the cpolar installation. Compared with CFImagehost website deployment, the installation and registration of cpolar is much simpler. You can find the "Download" button directly on cpolar's official website page ( https://www.cpolar.com/ ).

20230526091313

The author is using the Windows operating system, so I chose the Windows version of cpolar 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.

20230526091315

20230526091316

cpolar will create an independent data tunnel for each user to ensure data security with user password and token code. 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.

20230526091317

20230526091318

3. Local web page publishing

At this point, we have completed the deployment of the local CFImagehost website and installed the cpolar intranet penetration program. Next, we can use cpolar to create an intranet penetration data tunnel that can connect to the local CFImagehost website, allowing us to access the local CFImagehost website on the public Internet.

3.1 Cpolar temporary data tunnel

In order to meet the temporary testing function of web pages required by some customers, cpolar can create a temporary data tunnel directly on the cpolar client (the public Internet address is reset every 24 hours). 隧道管理To create a temporary data tunnel, we directly log in to the cpolar client on the local device (enter localhost:9200 in the browser address bar), and click the button under the item on the main interface of the cpolar client to enter the tunnel creation setting page 创建隧道.

20230526091319

On the "Create Tunnel" page, we need to set several information settings, which include:

  • 隧道名称– It can be regarded as the tunnel information annotation of the cpolar client, as long as it is convenient for us to distinguish;
  • 协议– The CFImagehost website is a web program, so the http protocol is selected;
  • 本地地址– The local address is the output port number of the local CFImagehost website, so 82 is also filled in here;
  • 域名类型–Here we can distinguish whether the data tunnel is used temporarily or exists for a long time. Since we are only conducting a temporary test first, we choose "random domain name" (the second-level subdomain name and custom domain name are both long-term stable tunnels and need to reserve a public Internet address in the cpolar cloud).
  • 地区– That is the location of the server, we can fill it in according to the actual location of use;

20230526091320

After completing these settings, you can click 创建the button at the bottom of the page to establish a temporary data tunnel. After the temporary data tunnel is created, the cpolar client will automatically jump to the page 隧道管理under the item 隧道列表, where we can see all cpolar local data tunnels (whether temporary or long-term). We can also manage the data tunnel here, including opening, closing or deleting this tunnel. We can also click the "Edit" button to modify the information of this data tunnel.

20230526091321

The temporary public Internet address we created that can connect to the local CFImagehost website can be found under 状态the item .在线隧道列表

20230526091322

Paste the public Internet address shown here into your browser address bar to access your local CFImagehost website page.

20230526091323

However, at this time, the CFImagehost data tunnel is only a temporary data tunnel, and the public Internet address is reset every 24 hours. If you still want to connect to the local CFImagehost web page, you need to use a new address to connect.

3.2 Cpolar Stable Tunnel (Cloud Settings)

If we want to set up a long-term stable data tunnel for the local CFImagehost website, we need to upgrade cpolar to the VIP version first.

20230526091324

Next, we can log in to cpolar's official website, find 预留the button on the left side of the user's home page, click to enter cpolar's data tunnel reservation page, and generate a public Internet address here (which can be regarded as the entrance to the data tunnel). Because of this At this time, this address is not connected to the local software output port, so it can also be regarded as a blank data tunnel.

20230526091325

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

20230526091326

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 this 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.

20230526091327

Of course, if you no longer plan to use this data tunnel, you can click the "x" on the right to easily delete it and save valuable tunnel quota.

20230526091328

3.3.Cpolar stable tunnel (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 with the local test page.

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

隧道管理Click the button under the item on the left side of the client's main interface 隧道列表to enter the local tunnel page, and then click 编辑the button corresponding to the tunnel.

20230526091329

On the "Edit" page of the local tunnel (the same as the page for creating a local temporary tunnel), we only need to make 域名类型modifications to connect the public Internet address reserved by cpolar cloud to the CFImagehost data tunnel created by local cpolar.

We have reserved the data tunnel of the second-level subdomain name in the cpolar cloud, so we changed it to 二级子域名(if the reserved domain name is a custom domain name, check the custom domain name), and fill Sub Domainin the reserved second-level subdomain name in the next line. Domain name, in this example "CFImagehost".

20230526091330

After completing the change of "Domain Name Type", you can click 更新the button at the bottom of the page to connect the blank data tunnel in the cpolar cloud with the local CFImagehost website, thus generating a CFImagehost website data tunnel that can exist stably for a long time.

4. Public network access test

Finally, we enter 在线隧道列表the page again and paste the updated public Internet address of the CFImagehost website into the browser. We can see that the CFImagehost website can be accessed stably for a long time, achieving the purpose of publishing the local CFImagehost website to the public Internet.

20230526091331

20230526091332

5 Conclusion

The CFImagehost website is just one of many website source codes. We can also install other types of website source codes on local devices and deploy websites with different functions and application scenarios. These websites can also be published to the public Internet using cpolar, allowing our local devices to become private website servers, bringing greater convenience to our lives and work.

Reprinted from cpolar pole cloud article: [PHP Image Hosting] Free CFimagehost image bed source code to build a private image bed – no database support required

Guess you like

Origin blog.csdn.net/2301_76147196/article/details/132874901