Skip to content

Latest commit

 

History

History
225 lines (171 loc) · 7.4 KB

DEVELOPER_README.md

File metadata and controls

225 lines (171 loc) · 7.4 KB

Instructions for WordPress Developers

First, install PHP 7.3 on your machine.

Installation of WordPress and most plugins is handled with Composer. If you aren't familiar with Composer, you can get instructions on installation and how to use it here.

Getting Started (Webonary cloud api integration development only)

If you are working on Webonary integration with the Cloud API backend only, you can use wp-env for local development using Docker.

To start, clone this full repo and install npm packages and install Wordpress plugins through composer.

git clone https://github.com/sillsdev/webonary.git

cd webonary

npm install

composer install

Then, copy sample wp-env.json configuration file and modify it to point to a valid Webonary Cloud API environment and a test dictionary.

cp ../.wp-env.json.sample .wp-env.json

The local environment will be available at http://localhost:8888 (Username: admin, Password: password) once you start it by:

npx wp-env start

See here for more instructions on wp-env

Getting Started (full local WordPress development)

The first steps are to clone the repository and install WordPress. The recommended location is a directory accessible by Apache. Possibilities include, but are not limited to /var/www/sites or /var/www/projects.

mkdir -p /var/www/sites/
cd /var/www/sites/
git clone https://github.com/sillsdev/webonary.git
cd webonary
composer install
npm install

Next, make a copy of shared/config/wp-config-sample.php and name it shared/config/wp-config.php. This will be the configuration file used by Webonary. The last few lines of the file have been modified to function correctly in this modified directory structure. In shared/config/wp-config.php set the database connection information.

cp shared/config/wp-config-sample.php shared/config/wp-config.php

Add the following line to /etc/hosts

127.0.0.1   webonary.localhost

Add the following Apache virtual host. On Ubuntu the file is /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    ServerName webonary.localhost
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/sites/webonary/wordpress

    ErrorLog ${APACHE_LOG_DIR}/webonary_error.log
    CustomLog ${APACHE_LOG_DIR}/webonary_access.log combined

    <Directory "/var/www/sites/webonary/wordpress/">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

Finally, restart Apache:

sudo service apache2 restart

Install WP CLI

See https://wp-cli.org/

cd ~/
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

Deploying to webonary.work

You will need to add webonary.work to your ~/.ssh/config file.

Host sysops.webonary.work
  User your_user_name
  IdentityFile ~/.ssh/your_private_key
  IdentitiesOnly yes
  Port 22

Once that is done, run the following command in the repository root. You may need to install make.

make test

Restore MySQL backup to webonary.work

NOTE: this process may take several hours.

For this to work, you will need to create a MySQL config file ~/.mysql/my.local.conf and put this in it:

[mysql]
user=your_user
password="your_password"
host=localhost
protocol=tcp
port=3306

[mysqldump]
user=your_user
password="your_password"
host=localhost
protocol=tcp
port=3306
  1. Download a backup from https://s3.amazonaws.com/backups.languagetechnology.org/webonary.org/mysql/daily/webonary/

  2. Rename the downloaded file to webonary.sql.gz

  3. Transfer the file to webonary.work:

    rsync -avz --chmod=D2775,F664 -e 'ssh' ~/Downloads/webonary.sql.gz sysops.webonary.work:~/webonary.sql.gz
    
  4. On webonary.work run these commands:

    cd ~/
    rm -f webonary.sql
    gunzip webonary.sql.gz
    mysql --defaults-file=~/.mysql/my.local.conf -A --default-character-set=utf8mb4 webonary
    mysql> SOURCE webonary.sql;
    mysql> UPDATE wp_blogs SET domain = replace(domain, 'webonary.org', 'webonary.work');
    mysql> quit
    
    mkdir -p /var/www/sites/webonary/current/wordpress/wp-content/wflogs
    touch /var/www/sites/webonary/current/wordpress/wp-content/wflogs/rules.php
    wp eval-file updateDataLive2Work.php --path='/var/www/sites/webonary/current/wordpress'
    wp cache flush --path='/var/www/sites/webonary/current/wordpress'
    
  5. That's it, you're finished!

Install MongoDB Shell

wget -qO- https://www.mongodb.org/static/pgp/server-6.0.asc | sudo tee /etc/apt/trusted.gpg.d/server-6.0.asc
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt update
sudo apt install mongodb-mongosh
mongosh --version

Install MongoDB tools

Download from [https://www.mongodb.com/try/download/database-tools]

Instructions, [https://www.mongodb.com/docs/database-tools/installation/installation-linux/]

mongoexport --config=/home/phil/.mongo/webonary_org.yml --db=webonary --collection=webonaryDictionaries --out=/home/phil/dumps/dictionaries.json --query='{ "_id": "test-stutzman" }'
# mongoexport --config=/home/phil/.mongo/webonary_org.yml --db=webonary --collection=webonaryReversals --out=/home/phil/dumps/reversals.json --query='{ "dictionaryId": "test-stutzman" }'
mongoexport --config=/home/phil/.mongo/webonary_org.yml --db=webonary --collection=webonaryEntries_test-stutzman --out=/home/phil/dumps/entries.json
mongoexport --config=/home/phil/.mongo/webonary_org.yml --db=webonary --collection=webonaryReversals --out=/home/phil/dumps/reversals.json


# mongoimport --config=/home/phil/.mongo/webonary_work.yml --db=webonary-work --collection=webonaryReversals --mode=upsert --file=/home/phil/dumps/reversals.json
mongoimport --config=/home/phil/.mongo/webonary_work.yml --db=webonary-work --collection=webonaryDictionaries --mode=upsert --file=/home/phil/dumps/dictionaries.json
mongoimport --config=/home/phil/.mongo/webonary_work.yml --db=webonary-work --collection=webonaryEntries_test-stutzman --drop --mode=upsert --file=/home/phil/dumps/entries.json
mongoimport --config=/home/phil/.mongo/webonary_work.yml --db=webonary-work --collection=webonaryReversals --drop --mode=upsert --file=/home/phil/dumps/reversals.json

Copy S3 folder from .org to .work

aws s3 cp --recursive --profile webonary s3://cloud-storage.webonary.org/lietuviukalba-espanol /home/phil/Downloads/webonary
aws s3 cp --recursive --profile webonary /home/phil/Downloads/webonary s3://cloud-storage.webonary.work/lietuviukalba-espanol

Install redis on the server

See https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-22-04

sudo apt update
sudo apt install redis-server
sudo nano /etc/redis/redis.conf
# set the `supervised` value to `systemd`
sudo systemctl restart redis.service
sudo systemctl status redis
redis-cli
> ping
# response should be PONG
exit