Setting Up Personal Websites

Author:Brant C. Faircloth
Copyright:This documentation is available under a Creative Commons (CC-BY) license.

Modification History

See Setting Up Personal Websites.

Purpose

I’ve setup personal wordpress installations for everyone in the lab (that wants one) - primarily so that folks don’t have to use weebly.

Steps

  1. Create appropriate entry in DNS

  2. Log into webserver VPS

  3. Log into MySQL as admin user

  4. Create new database(s) for personal website(s), create a new user for that db, then assign privileges to DB user

    CREATE DATABASE <name>_faircloth_lab;
    CREATE USER <name>_flab IDENTIFIED BY "STRONG PASSWORD";
    GRANT ALL PRIVILEGES ON <name>_faircloth_lab.* to <name>_flab@localhost IDENTIFIED BY "STRONG PASSWORD";
    
  5. Copy over Nginx config for new user’s website

    cd /etc/nginx/conf.d/
    cp template.website.bak <name>.faircloth-lab.org
    
  6. Edit file to reflect reasonable values (change <name>)

    server {
        listen       80;
        server_name  <name>.faircloth-lab.org;
        access_log /var/www/html/<name>.faircloth-lab.org/logs/access.log;
        error_log /var/www/html/<name>.faircloth-lab.org/logs/error.log;
    
        # note that these lines are originally from the "location /" block
        root   /var/www/html/<name>.faircloth-lab.org/public_html;
        index index.php index.html index.htm;
    
        location / {
            try_files $uri $uri/ /index.php?$args;
        }
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root /usr/share/nginx/html;
        }
    
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    
  7. Make appropriate directories in /var/www/html/

    cd /var/www/html
    mkdir -p <name>.faircloth-lab.org/{logs,public_html}
    
  8. Download and unzip wordpress to public_html

  9. Change permissions of files within public_html

  10. Restart Nginx

  11. Setup certbot for website and choose to redirect traffic from http to https:

    certbot --nginx
    
  12. Visit new site and setup

    https://<name>.faircloth-lab.org/
    
  13. At new site, turn of ability to comment, remove sample comment, and turn off discussion for initial post

  14. Copy over theme files

  15. Adjust permissions

    chown nginx:nginx <name>.faircloth-lab.org/{logs,public_html}
    cd public_html
    chown -R <admin>:<admin> -R *
    chown -R nginx:nginx wp-content
    find . -type d -exec chmod 755 {} \;
    find . -type f -exec chmod 644 {} \;