1. Initial Setup
Run the Alpine setup and configure repositories:
setup-alpine
setup-apkrepos -c
Update the system:
apk update && apk upgrade
2. Install Required Packages
Install the necessary packages for WordPress, PHP, MariaDB, and Nginx:
apk add mariadb mariadb-client nginx php php-fpm php-mysqli php-json php-curl php-dom php-exif php-fileinfo php-imagick php-mbstring php-zip php-gd php-iconv php-intl php-opcache
Enable services at boot:
rc-update add qemu-guest-agent
rc-update add mariadb default
rc-update add nginx default
rc-update add php-fpm83 default
Start services:
rc-service qemu-guest-agent start
rc-service php-fpm83 start
rc-service nginx start
3. Disable IPv6 (Optional)
For better performance or troubleshooting, you may want to disable IPv6. See the Alpine Linux Sysctl documentation.
4. Configure MariaDB
Edit the MariaDB configuration to comment out skip-networking:
vi /etc/my.cnf.d/mariadb-server.cnf
Initialize the database:
/etc/init.d/mariadb setup
rc-service mariadb start
Run the secure installation script:
mariadb-secure-installation
During this process, follow these recommended steps:
- Press Enter if no root password is set.
- Switch to unix_socket authentication:
n - Change root password:
n(if already secure) - Remove anonymous users:
Y - Disallow root login remotely:
Y - Remove test database:
Y - Reload privilege tables:
Y
5. Create WordPress Database and User
Log in to MariaDB:
mysql
Inside MariaDB, run:
CREATE DATABASE wordpress;
CREATE USER wordpress IDENTIFIED BY 'XXXXXXXX';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress';
FLUSH PRIVILEGES;
\quit
Replace 'XXXXXXXX' with a strong password.
6. Download and Set Up WordPress
cd /var/www/
wget https://wordpress.org/latest.zip
unzip latest.zip
chown -R nginx:nginx wordpress
7. Configure Nginx
Backup the default config and create a new one:
cd /etc/nginx/http.d/
cp default.conf default.conf.disabled
vi default.conf
Paste the following configuration (replace your.domain.comwith your domain):
server {
listen 80;
server_name your.domain.com;
root /var/www/wordpress;
index index.php index.html;
access_log /var/log/nginx/wordpress.access.log;
error_log /var/log/nginx/wordpress.error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
}
location ~ /\.ht {
deny all;
}
}
8. Configure PHP-FPM
Edit PHP-FPM to run as the nginx user:
vi /etc/php83/php-fpm.d/www.conf
Update the file with:
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_requests = 500
request_terminate_timeout = 60
Restart services:
rc-service php-fpm83 restart
rc-service nginx restart
9. Complete WordPress Installation
Now, open your browser and navigate to your server domain. You should see the WordPress setup page where you can complete the installation.
