mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
607 words
3 minutes
AMH Panel Website Building Practice: Deploying a High-Performance WordPress Blog from Scratch
2023-12-25

“A man is not old until his regrets take place of his dreams.”

Phase 1: Basic Server Environment Configuration#

Before installing the panel, we need to do some necessary initialization on the Linux server. This tutorial uses Azure B1s (CentOS/AlmaLinux based) as an example; other VPS operations are similar.

1. Update System and Install Basic Tools#

# Install YUM utilities and update the system
yum install -y yum-utils
yum update -y

2. Configure Swap Virtual Memory (Crucial)#

For servers with small memory (like 1GB on Azure B1s), enabling Swap is key to preventing database crashes. It is recommended to configure 4GB - 8GB of Swap.

# 1. Stop and remove Azure's default temporary Swap (if any)
swapoff /mnt/resource/swapfile
rm -rf /mnt/resource/swapfile
sed -i "/'\/mnt/resource/swapfile swap swap defaults 0 0'//" /etc/fstab
# 2. Create a new Swap file (8GB)
dd if=/dev/zero of=/swapfile bs=1024 count=8388608
# 3. Set permissions and format
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
# 4. Set to mount automatically on boot
echo '/swapfile swap swap sw 0 0' | tee -a /etc/fstab
# 5. Verify
free -m

3. System Optimization Configuration#

# Set timezone to Shanghai
timedatectl set-timezone Asia/Shanghai
# Disable system firewall (Recommended to manage ports via Cloud Provider's security groups)
systemctl stop firewalld
systemctl disable firewalld

Phase 2: Installing AMH Hosting Panel#

AMH is a veteran domestic open-source hosting panel, characterized by being modular, minimalist, and having low resource consumption.

1. Execute Installation Script#

Visit the AMH Official Installation Page to get the latest command, or directly use the following customized command (Nginx 1.20 + MySQL 5.6 + PHP 8.0):

wget http://dl.amh.sh/amh.sh && bash amh.sh nginx-1.20,mysql-5.6,php-8.0

Tip: If it prompts wget: command not found, execute yum install -y wget first. The installation process takes about 15-30 minutes.

2. Login to the Panel#

After installation is complete, access http://YourIP:8888 or https://YourIP:9999 via a browser. Use the default account and password outputted in the terminal to log in.

AMH Login Interface

3. Install Necessary Software Extensions#

After logging into the panel, go to the App Store (软件商店). It is recommended to install the following extensions to support WordPress:

  • amrewrite: Pseudo-static rule management.
  • amssl: Automatic SSL certificate application.
  • pecl_redis / redis: Cache support (Optional, for performance optimization).
  • php-generic: PHP generic extension management.

Phase 3: Deploying the WordPress Website#

1. Create Virtual Host (LNMP Environment)#

Go to Website -> Virtual Host -> Add Virtual Host:

  • Main Domain: Fill in your domain (e.g., example.com).
  • Runtime Environment: Select lnmp01.
  • Network: Check HTTPS, port will automatically set to 443.
  • URL Rewrite Rule: Select the wordpress2 rule here (Very important, otherwise post pages will return 404).

WordPress Nginx Pseudo-static Rule Reference:

location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

Add Virtual Host

2. Apply for SSL Certificate#

Go to Website -> SSL Certificate -> AMSSL:

  • Select the virtual host you just created.
  • Check One-click automatic configuration (Let’s Encrypt recommended).
  • Click create, and wait for the certificate to be issued and deployed automatically.

SSL Configuration

3. Install PHP Extensions#

WordPress and its plugins usually require the following PHP extensions. Go to Website -> PHP Extensions, and install for the lnmp01 environment:

  • fileinfo
  • exif
  • imagick (Image processing)
  • opcache (Performance acceleration)
  • curl

Phase 4: Installing the WordPress Application#

1. Download and Extract#

Click on File Management in the panel, and navigate to the website root directory (usually /home/wwwroot/lnmp01/domain/your_domain/web/).

Use the Remote Download feature:

https://wordpress.org/latest.tar.gz

(Changed to English package link instead of zh_CN)

After the download is complete, select the file and click Smart Extract. After extracting, move all files inside the wordpress folder to the web root directory, and delete the default index.html.

2. Configure Database Connection#

  1. Rename wp-config-sample.php to wp-config.php.
  2. Edit this file online and fill in the database information:
define( 'DB_NAME', 'wordpress_db' ); // Your database name
define( 'DB_USER', 'root' ); // Your database username
define( 'DB_PASSWORD', 'Your Password' ); // Your database password
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8' );
// Performance optimization parameters
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'FS_METHOD', 'direct' );
  1. Go back to the panel’s Database Management, and create an empty database named wordpress_db (The name must match the config file).

3. Correct Permissions#

This step is crucial: In File Management, check the web directory, click Permissions, change the owner to www, the user group to www, and check Recursive processing.

Permissions Settings


Phase 5: Complete Installation#

Open a browser and visit your domain. You should see the WordPress installation welcome screen. Set up your site title, administrator account, and password, then click Install!

Advanced Optimization Suggestion: WWW Redirect#

If you want visits to www.example.com to automatically redirect to example.com (or vice versa):

  1. Create a Subdomain Host www.example.com in AMH.
  2. Add a 301 redirect rule in the Pseudo-static rules.
  3. Or directly use the AMRewrite module in the AMH panel to set up a domain 301 redirect.
Share

If this article helped you, please share it with others!

AMH Panel Website Building Practice: Deploying a High-Performance WordPress Blog from Scratch
https://blog.levifree.com/posts/amh-wordpress-installation-guide/
Author
LeviFREE
Published at
2023-12-25
License
CC BY-NC-SA 4.0

Some information may be outdated

Table of Contents