Category: Uncategorized

  • Databases

    Postgres

    sudo apt install postgresql
    sudo service postgresql status
    sudo passwd postgres
    sudo -u postgres psql

    create database dbname;
    create user username with encrypted password 'password';
    grant all privileges on database dbname to username;

    Useful commands

    ALTER TABLE table ADD column dataType NOT NULL;

    \l list databases
    \c select database
    \dt list tables

  • Move a wordpress site to the new server

    Backup

    mysqldump -u root -p database1 > database.sql

    tar -zcvf data.tar.gz data

    Restore

    CREATE DATABASE database1;
    CREATE USER ‘user’@’localhost’ IDENTIFIED BY ‘pwd’;
    GRANT ALL PRIVILEGES ON database1 . * TO ‘user’@’localhost’;
    FLUSH PRIVILEGES;

    mysql -u root -p database1 < database.sql

    tar -zxvf data.tar.gz
    new website:

    curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www

    update wp-config.php with the new password

    sudo chown -R www-data:www-data /var/www/data
    find /var/www/data -type d -exec chmod 755 {} \;
    find /var/www/data -type f -exec chmod 644 {} \;

    Server setup

    Reverse nginx proxy settings

    HTTP Apache2 settings