Aller au contenu

Wordpress

MariaDB

Installation

Bash
apk add --update mariadb mariadb-client

Configuration

Bash
1
2
3
4
mysql_install_db --user=mysql --datadir=/var/lib/mysql
rc-service mariadb start
rc-update add mariadb
mysql_secure_installation

Base de données Wordpress

Bash
mysql -u root -p

⚠ CHANGER LE MOT DE PASSE CI-DESSOUS

Text Only
1
2
3
4
5
CREATE USER 'wordpress'@'localhost' IDENTIFIED BY '';
CREATE DATABASE IF NOT EXISTS wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';
FLUSH PRIVILEGES;
QUIT;

PHP

Installation

Bash
apk add --update php84 php84-fpm php84-mysqli

Configuration

Modifier user et group pour mettre nginx

Bash
nano /etc/php84/php-fpm.d/www.conf

PHP-fpm

Lancer le service

Bash
rc-service php-fpm84 start
rc-update add php-fpm84

Nginx

Installation

Bash
apk add --update nginx

Configuration

nginx.conf

Bash
mv /etc/nginx/nginx.conf /etc/nginx/[old]-nginx.conf
nano /etc/nginx/nginx.conf
Text Only
user nginx;
worker_processes auto;

# Configures default error logger.
error_log /var/log/nginx/error.log warn; # Log warn, error, crit, alert, emerg

events {
    # The maximum number of simultaneous connections that can be opened by a worker process.
    worker_connections 1024; # increase if you need more connections
}

http {
    # server_names_hash_bucket_size controls the maximum length
    # of a virtual host entry (ie the length of the domain name).
    server_names_hash_bucket_size   64; # controls the maximum length of a virtual host entry (ie domain name)
    server_tokens                   off; # hide who we are, don't show nginx version to clients
    sendfile                        off; # can cause issues

    # nginx will find this file in the config directory set at nginx build time
    # Includes mapping of file name extensions to MIME types of responses
    include mime.types;

    # fallback in case we can't determine a type
    default_type application/octet-stream;

    # buffering causes issues, disable it
    # increase buffer size. still useful even when buffering is off
    proxy_buffering off;
    proxy_buffer_size 4k;

    # allow the server to close the connection after a client stops responding. Frees up socket-associated memory.
    reset_timedout_connection on;

    # Specifies the main log format.
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
            '$status $body_bytes_sent "$http_referer" '
            '"$http_user_agent" "$http_x_forwarded_for"';

    # Sets the path, format, and configuration for a buffered log write.
    # Buffer log writes to speed up IO, or disable them altogether
    access_log /var/log/nginx/access.log main buffer=16k;
    #access_log off;

    # Include files with config snippets into the root context.
    include conf.d/*.conf;

    # Includes virtual hosts configs.
    include http.d/*.conf;
}

wordpress.conf

Bash
mv /etc/nginx/http.d/default.conf /etc/nginx/http.d/default.conf.old
nano /etc/nginx/http.d/wordpress.conf
Text Only
server {
    listen 80;
    listen [::]:80;

    server_name localhost;

    root /usr/share/webapps/wordpress;

    index index.php index.html index.htm;

    location ~ \.php$ {
        # the following line needs to be adapted, as it changes depending on OS distributions and PHP versions
        #fastcgi_pass unix:/run/php-fpm82/php-fpm.sock;
        fastcgi_pass 127.0.0.1:9000;

        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Démarrer le service

Bash
rc-service nginx start
rc-update add nginx

Wordpress

Installation

Bash
1
2
3
mkdir -p /usr/share/webapps/
cd /usr/share/webapps/
wget https://wordpress.org/latest.tar.gz

On décompresse l'archive

Bash
tar -xzvf latest.tar.gz
rm latest.tar.gz

Droits

Bash
chown -R nginx:nginx /usr/share/webapps/wordpress