This guide intends to walk you through every step of a WordPress install, and to avoid the use of a GUI whenever possible. It was designed with NearlyFreeSpeech.NET hosting in mind, but may be helpful on other hosts as well.
First, we’ll set up the database that WordPress needs to run.
- Log into phpMyAdmin (or equivalent UI for your server’s MySQL Database).
- Click on “Databases”.
- Create a new database by providing a database name like “sitenamewp”, then clicking “Create”. WordPress recommends using “utf8mb4_general_ci” collation when creating a database. Write the database name down–it will be required later.
- Return to the main page by clicking the home icon in the top left.
- Click “User Accounts”
- Click “Add user account”
- Give the user a name like “wpuser_sitename” Write the user name down–it will be required later.
- Generate a password for the user by clicking the “Generate” button. Write the password down–it will be required later.
- Click “Go” to create the user.
- Go back to “User accounts”, then click “Edit privileges” for the recently created user.
- Click “Database”.
- Select the database that you created for this WordPress site, then click “Go”.
- Click “Check all”, then click “Go” to give this user all permissions on the selected database.
- Look at the top of the page and write down the host name for your MySQL server. It will look something like “hostname.db” and be found after the text “Server:”.
- Next, we’ll install WordPress on the web server. Use PuTTY to SSH into the server where you wish to install WordPress.
- Run
wp core download
To get the latest for WordPress. It may take a few moments. Wait for it to complete.
- Replace the bracketed text with the database info that you wrote down in steps 3, 7, 8, and 14, then run
wp core config --dbhost=[step14] --dbname=[step3] --dbuser=[step7] --dbpass=[step8]
The actual command should look something like this below (but won’t be exactly the same)
wp core config --dbhost=hostname.db --dbname=sitenamewp --dbuser=wpuser_sitename --dbpass=R@ndomP@$w0rd
- Run
chmod 644 wp-config.php
To change the permissions of the wp-config.php file.
- Replace the bracketed text with your actual site URL, site name, admin user, admin user password, and admin user email, then run
wp core install --url=[url] --title="[title]" --admin_user=[user] --admin_password=[pass] --admin_email=[email]
The actual command should look something like this below (but won’t be exactly the same)
wp core install --url=sitename.nfshost.com --title="Site Name" --admin_user=AdminUsername --admin_password=AdminP@$w0rd --admin_email=example@example.com
- In PuTTY, run the following commands one after another:
cd wp-content mkdir -p uploads chgrp -R web uploads chmod -R 775 uploads cd ..
This should ensure that you can upload files to your site (based on the recommendation here.)
- In PuTTY, run the following command:
touch .htaccess
This creates an empty
.htaccess
file, which can be used for setting up permalinks. - In PuTTY, run the following commands one after another:
chgrp -R web ../public find ../public -type f -exec chmod 664 {} \; find ../public -type d -exec chmod 775 {} \; chgrp -R web * find . -type d -exec chmod 775 {} \; find . -type f -exec chmod 664 {} \;
This will allow the web server to create and modify files. It also sets proper permissions for directories and files. It’s riskier than using the WordPress CLI from a security standpoint, but more convenient for WordPress users.
- Optionally, add the line,
define('FS_METHOD','direct');
to thewp-config.php
file, immediately before the/* That's all, stop editing! Happy publishing. */
line. This can make WordPress, Theme, and Plugin upgrades easier, but be sure you are aware of the security concerns before doing this. To edit thewp-config.php
file…
Runpico wp-config.php
Adddefine('FS_METHOD','direct');
in the location described above
Press CTRL + X to exit pico
Then press Y to Save modified buffer, then press Enter to confirm the save. - Since we wrote passwords on the command line, you may wish to clear the history with
history -c
- Exit PuTTY with the
exit
command
And that’s it! WordPress should be set up and ready to go! You can visit and log in to your site using the admin credentials and the URL you specified in step 19.
Do these steps not work for you? You can run wp --info
to see if your server has the wp cli already. Servers not running the wp cli may need a more manual install of WordPress, such as the steps listed here.