Subarkah Tutorials

website·Indexed 29 days ago

https://www.subarkah.com

A collection of tutorials and guides focusing on website development and system administration. Content includes WordPress custom code, plugin development, LEMP stack setup on Ubuntu 24.04, server security, and tools like Composer and dpkg.

Tokens
8.6K
Snippets
58
Records
62
Agent score
50%

What's inside Subarkah

  1. Use dpkg to manage packages on Debian-based Linux distributions

    dpkg is the low-level package manager for Debian-based Linux operating systems (including derivatives like Ubuntu). It is used to install, remove, and build software packages.
  2. Enable Nginx site configuration and restart

    Create a symbolic link from sites-available to sites-enabled to activate the configuration, then test and restart Nginx.
    # Enable the site
    sudo ln -s /etc/nginx/sites-available/uio.my.id /etc/nginx/sites-enabled/uio.my.id
    
    # Test configuration
    sudo nginx -t
    
    # Restart Nginx
    sudo service nginx restart
  3. Install and configure Nginx on Ubuntu 24.04

    Install Nginx using the Ondřej Surý PPA repository for the latest version. After installation, the main configuration file /etc/nginx/nginx.conf should be updated to handle WebP mapping, SSL protocols (TLSv1 through TLSv1.3), Gzip compression, and specific client body size limits.
    # Add repository and install
    sudo add-apt-repository ppa:ondrej/nginx -y
    sudo apt update
    sudo apt install nginx -y
    
    # Verify installation
    nginx -v

    /etc/nginx/nginx.conf snippet

    user www-data; worker_processes 1; pid /run/nginx.pid; error_log /var/log/nginx/error.log; include /etc/nginx/modules-enabled/*.conf;

    events { worker_connections 1024; multi_accept on; }

    http { map $http_accept $webp_suffix{ default ""; "~*webp" ".webp"; }

    keepalive_timeout 15;
    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    client_max_body_size 64m;
    server_tokens off;
    
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    
    access_log /var/log/nginx/access.log;
    
    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    }

  4. Install Bedrock for a WordPress site

    Switch to the website owner's user account and use Composer to install the Bedrock boilerplate. After installation, create a logs directory for the site.
    # Switch to the site user
    sudo su uio
    cd /home/uio
    
    # Install Bedrock via Composer
    composer create-project roots/bedrock uio.my.id
    
    # Create logs directory
    sudo mkdir -p /home/uio/uio.my.id/logs
  5. Install WP-CLI

    Download the WP-CLI phar file, make it executable, and move it to the global bin directory to allow execution from any path.
    curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
    php wp-cli.phar --info
    chmod +x wp-cli.phar
    sudo mv wp-cli.phar /usr/local/bin/wp
    
    # Test installation
    wp --info
  6. Install and configure UFW firewall

    Install the Uncomplicated Firewall (UFW), allow essential traffic for SSH (22), HTTP (80), and HTTPS (443), and enable the firewall rules.
    # Install UFW
    sudo apt install ufw
    
    # Allow SSH, HTTP, and HTTPS
    sudo ufw allow ssh
    sudo ufw allow http
    sudo ufw allow https
    
    # Review added rules
    sudo ufw show added
    
    # Enable the firewall
    sudo ufw enable
    
    # Verify active status
    sudo ufw status verbose
  7. Determine when to use a separate domain for a microsite

    Use a separate domain for a microsite when the project meets one of the following criteria:

    1. Specific or Seasonal Marketing Campaigns: When running a large campaign separate from the main brand to ensure stronger focus and branding.
    2. Different Target Audiences: When targeting a market segment different from the main brand to avoid confusion and allow communication flexibility.
    3. Brand Collaborations or Partnerships: When partnering with another brand, a neutral domain appears more professional and equitable.
  8. Create a system user and directory structure for a website

    To isolate a website on a server, create a dedicated system user, add them to the www-data group for web server access, and set up the directory structure for public files and logs. Ensure the user owns their home directory.
    # Create the user
    sudo useradd mitra
    
    # Add user to www-data group
    sudo usermod -a -G mitra www-data
    
    # Create public and log directories
    sudo mkdir -p /home/mitra/mitra.web.id/public
    sudo mkdir -p /home/mitra/mitra.web.id/logs
    
    # Set ownership of the home directory
    sudo chown -R mitra:mitra /home/mitra
  9. Install WordPress using WP-CLI

    Download and configure WordPress using WP-CLI. This process involves switching to the site owner user, downloading the core files, configuring the database connection, and running the installation command.
    # Switch to site user and enter public directory
    sudo su mitra
    cd /home/mitra/mitra.web.id/public
    
    # Download WordPress
    wp core download
    
    # Configure database
    wp core config --dbname=mitra_db --dbuser=mitra_user --dbpass='Workshop@WPBogor2025'
    
    # Install WordPress
    wp core install --skip-email --url=https://www.mitra.web.id --title='Workshop WPBogor' --admin_user=akah --admin_email=[email protected] --admin_password='password'
    
    # Cleanup unnecessary plugins and themes
    wp plugin delete akismet
    wp plugin delete hello
    wp theme delete twentytwentyfour
    wp theme delete twentytwentythree
  10. Create a MariaDB database and user for Bedrock

    Set up a dedicated database and user with appropriate privileges for the WordPress installation using the MariaDB CLI.
    CREATE DATABASE uio_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
    CREATE USER 'uio_user'@'localhost' IDENTIFIED BY 'YourStrongPassword';
    GRANT ALL PRIVILEGES ON uio_db.* TO 'uio_user'@'localhost';
    FLUSH PRIVILEGES;
  11. Install and secure MariaDB

    Install MariaDB server, enable it to start on boot, and run the security script to configure root passwords and remove insecure defaults.
    sudo apt install mariadb-server
    sudo systemctl enable mariadb
    sudo systemctl start mariadb
    
    # Secure the installation
    sudo mysql_secure_installation

    Recommended mysql_secure_installation responses:

    • Switch to unix_socket authentication: n
    • Change the root password: Y
    • Remove anonymous users: Y
    • Disallow root login remotely: Y
    • Remove test database and access to it: Y
    • Reload privilege tables now: Y
  12. Create a system user and directory for a WordPress site

    To isolate a website, create a dedicated system user, add them to the www-data group, and set up their home directory with correct ownership.
    # Create the user
    sudo useradd uio
    
    # Add user to www-data group
    sudo usermod -a -G uio www-data
    
    # Create home directory
    sudo mkdir -p /home/uio
    
    # Set ownership
    sudo chown -R uio:uio /home/uio