Static Pages

WordPress with Caddy


Open webmin, go to desired domain, upload wordpress.zip and extract wordpress.zip. OR

$ cd /tmp
$ wget https://wordpress.org/latest.zip
$ sudo mkdir /usr/share/caddy/domain
$ sudo unzip /tmp/latest.zip   //it will unzip in the directory wordpress.
$ sudo mv /tmp/wordpress/* /usr/share/caddy/domain  //it will transfer all the files to domain.
$ cd /usr/share/caddy/domain
$ ls //see if all the files there
$ sudo chown -R $USER:$USER /usr/share/caddy/domain

mysql -u root -p
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL ON wordpress.* TO 'user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'user'@'localhost';
FLUSH PRIVILEGES;
exit;

$ nano /etc/caddy/Caddyfile
domain:80 {    
    tls [email protected]
        log {
        output file /var/log/caddy/your.domain
        format console
    }
    root * /usr/share/caddy/domain
    encode gzip
    file_server
    php_fastcgi unix//run/php/php8.2-fpm.sock
      @disallowed {
        path /xmlrpc.php
        path *.sql
        path /wp-content/uploads/*.php
                  }
     rewrite @disallowed '/index.php'

        if {path} not_match ^\/wp-admin
        to {path} {path}/ /index.php?_url={uri}
}
$ sudo systemctl restart caddy
$ cd /usr/share/caddy/domain
  rename wp-config-sample.php to wp-config.php
$ mv wp-config-sample.php wp-config.php
$ sudo nano /usr/share/caddy/domain/wp-config.php
define('DB_NAME', 'wp_site');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'StrongPassword');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
Go to https://Domain, it will setup Wordpress.