banner
L,.G

L,.G

读书|新知|生活禅

Deploying Lan Kong Image Hosting & uPic

image

After trying many image hosting services, the best one is still Lankong, just as described on their official website:

Build your own cloud photo album, simple and practical.

Preparation#

Before deploying Lankong Image Bed to the server, some checks need to be done.

According to the official documentation, first, make sure that the PHP version of the server is ≥ 8.0.2, and then check if all the required PHP extensions are installed and if some functions are disabled.

The required PHP extensions and functions for Lankong Image Bed include:

  • BCMath PHP extension
  • Ctype PHP extension
  • DOM PHP extension
  • Fileinfo PHP extension
  • JSON PHP extension
  • Mbstring PHP extension
  • OpenSSL PHP extension
  • PDO PHP extension
  • Tokenizer PHP extension
  • XML PHP extension
  • Imagick extension
  • exec, shell_exec functions
  • readlink, symlink functions
  • putenv, getenv functions

For the database, you can choose:

  • Mysql 5.7+
  • PostgreSQL 9.6+
  • SQLite 3.8.8+
  • SQL Server 2017+

Create Website#

  1. In the Baota panel, create a new website.
  2. Upload and unzip the downloaded version from GitHub to the website's files (you can also choose to download remotely - download from URL).

image

  1. Change the permissions, user group, and owner of all folders, subfolders, and files in the program directory to www, and the permissions to 0755.

image

image

  1. Set the running directory of the website to the public folder of the program.

image

  1. Set up rewrite rules.

    location / {
      try_files $uri $uri/ /index.php?$query_string;
    }
    

image

  1. Enter the website address you created in the browser to complete the installation.

Image Bed Configuration#

After the installation is complete, enter the email and password you set in step 6 above to log in to the management interface.

image

I recommend turning off registration and guest uploads in the System Settings to avoid misuse of your image bed and negative impact.

image

In the Storage Strategy, you can set the location for image storage. Lankong Image Bed supports ten storage locations, including local storage, AWS S3, Alibaba Cloud OSS, Tencent Cloud COS, Qiniu Cloud Kodo, Upyun USS, SFTP, FTP, WebDAV, and Minio.

As shown in the figure, I added Tencent Cloud Object Storage as the default storage location for images.

image

uPic Configuration#

uPic is a macOS image hosting tool that allows us to quickly upload images to the image bed. To configure Lankong Image Bed in uPic, you need to obtain the token for Lankong Image Bed.

You can use the curl command in the server's SSH to get it.

curl -X POST -F "email=your_email@address" -F "password=your_passwd" https://your.domain/api/v1/tokens

Then go to the preferences of uPic and select Custom for the image bed.

image

  • API URL is your.domain/api/v1/upload
  • Request method is POST
  • File field name is file
  • URL path is ["data", "links", "url"]
  • Save path is {year}/{month}/{day}/{filename}{suffix}

10.png

Then click on other fields to add the Header field.

  • Content-Type: multipart/form-data
  • Accept: application/json
  • Authorization: Bearer + token, for example, Bearer 1|2zxF05em0J2UcFxxxxxxxxxxxxxx

After completing all the configurations, click Verify. At this time, an image will appear on the image bed, indicating that the configuration is successful.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.