From 0f2a0873f72a30494d3f5c28dd496d637bed1863 Mon Sep 17 00:00:00 2001 From: bt Date: Thu, 23 May 2024 08:15:32 -0500 Subject: --- wordpress/NearlyFreeSpeech_Setup.mdwn | 156 ++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 wordpress/NearlyFreeSpeech_Setup.mdwn (limited to 'wordpress/NearlyFreeSpeech_Setup.mdwn') diff --git a/wordpress/NearlyFreeSpeech_Setup.mdwn b/wordpress/NearlyFreeSpeech_Setup.mdwn new file mode 100644 index 0000000..aed4d68 --- /dev/null +++ b/wordpress/NearlyFreeSpeech_Setup.mdwn @@ -0,0 +1,156 @@ +## Installing WordPress on NearlyFreeSpeech + +### Download WordPress + +We will use the `wp-cli` that comes packaged with NearlyFreeSpeech (NFS): + +1. Connect to your site via SSH. +2. Change to the directory you want to be the base of your blog (e.g. /home/public if WordPress will be running the whole site, or /home/public/blog if you want to share the site with other content). + +For help using WP-CLI from the SSH command line, use this command: + + wp help + +To download and unpack the latest version of WordPress, enter the following command: + + wp core download + +## Create a MySQL Process and Database + +Follow the instructions in the NearlyFreeSpeech.NET FAQ to [create a MySQL process](https://members.nearlyfreespeech.net/faq?q=MySQL#MySQL) if you haven't already. + +Next, [create a new database](https://members.nearlyfreespeech.net/faq?q=CreateDatabase#CreateDatabase) within that process. Note the name of the process and the name of the database. + +**Important**: Do not use your own MySQL credentials to connect WordPress to your database. Instead, create a new user. This will protect your member password in the event that your site becomes compromised. + + +- Click on the [MySQL tab](https://members.nearlyfreespeech.net/mysql) in the member interface +- Click "[Open phpMyAdmin](https://phpmyadmin.nearlyfreespeech.net/" in the Actions box. +- Enter the DSN ("Server") of your MySQL Process, MySQL username, and MySQL password. The DSN and username can be found on the Process Information page in our member UI. +- Click on the "Users" tab. +- Click "Add user." (It's toward the bottom left of the page.) +- Give the user a descriptive name. We'll use exampledbuser here, but you should pick something better, like wpuser or something representative of your blog. +- Make sure to leave the Host: selectbox on "Any host." +- Click the "Generate" link to generate a nice strong password. +- Use cut and paste to copy the new password somewhere, you'll need it later. (We'll use dbpassword here.) +- Grant the following permissions to the new user: + - All the permissions except "file" in the "data" box, + - Everything in the "structure" box, and + - "LOCK TABLES" in the "administration" box. +- Click the "Go" button in the lower right. +- Exit phpMyAdmin. + +## Generate a WordPress Configuration File + +At the SSH command line (replace the examples with the info for the database and user you created above): + + wp core config --dbhost=example.db --dbname=exampledb --dbuser=exampledbuser --dbpass=dbpassword + chmod 644 wp-config.php + +## Run the WordPress Installation and Setting Permissions + +To get your permalinks to work properly, you must set up an .htaccess file. + + +1. Go to the Dashboard for your WordPress site. (e.g. https://www.example.com/wp-admin/index.php) +2. In the navigation sidebar, find Settings and, under that, Permalinks. +3. Select your preferred link style under "Common Settings." (We like "Day and name.") +4. Scroll down and select the "Save Changes" button. + +Next, create an `.htaccess` file for your WordPress site. We suggest doing this directly from the SSH command line using the cat shell command: + + cat >.htaccess <name-of-wordpress-backup.tar.gz + +To back up WordPress to a file on our system that you can transfer via SFTP to your own computer, you can use a command like: + + tar -C /home/public -cvzf /home/tmp/name-of-wordpress-backup.tar.gz . + +This assumes that your WordPress install is in the default location (`/home/public`). It will put your backup file in your `/home/tmp` directory. + +Do not try to back up your WordPress folder into your WordPress folder, as that occasionally results in attempts to use infinite disk space by trying to back up the backup of the backup of the backup of the... + +### Backing up the WordPress Database + +If you have a Unix-like system of your own (e.g. macOS or Linux), you can do the backup directly from there using your local command prompt using the MySQL username and password you created for WordPress: + + ssh yourmembername_siteshortname@ssh.phx.nearlyfreespeech.net wp db export - | gzip >wordpress-backup.sql.gz + +Or you can do it from the SSH command line via WP-CLI: + + wp db export /home/tmp/wordpress-backup.sql + +The `wordpress-backup.sql` file this generates will be stored in your site's `/home/tmp` directory. Download it from there to have a local copy. -- cgit v1.2.3-54-g00ecf