{"id":1102,"date":"2020-07-07T19:20:00","date_gmt":"2020-07-07T23:20:00","guid":{"rendered":"https:\/\/www.ectropyarts.com\/?p=1102"},"modified":"2020-10-07T23:49:12","modified_gmt":"2020-10-08T03:49:12","slug":"how-to-install-wordpress-with-almost-just-the-command-line","status":"publish","type":"post","link":"https:\/\/www.ectropyarts.com\/how-to-install-wordpress-with-almost-just-the-command-line\/","title":{"rendered":"How to install WordPress with (almost) just the command line"},"content":{"rendered":"

This guide intends to walk you through every step of a WordPress<\/a> install, and to avoid the use of a GUI whenever possible. It was designed with NearlyFreeSpeech.NET<\/a> hosting in mind, but may be helpful on other hosts as well.<\/p>\n

First, we’ll set up the database that WordPress needs to run.<\/p>\n

    \n
  1. Log into phpMyAdmin (or equivalent UI for your server’s MySQL Database).<\/li>\n
  2. Click on “Databases”.<\/li>\n
  3. 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.\u00a0Write the database name down–it will be required later.<\/li>\n
  4. Return to the main page by clicking the home icon in the top left.<\/li>\n
  5. Click “User Accounts”<\/li>\n
  6. Click “Add user account”<\/li>\n
  7. Give the user a name like “wpuser_sitename” Write the user name down–it will be required later.<\/li>\n
  8. Generate a password for the user by clicking the “Generate” button. Write the password down–it will be required later.<\/li>\n
  9. Click “Go” to create the user.<\/li>\n
  10. Go back to “User accounts”, then click “Edit privileges” for the recently created user.<\/li>\n
  11. Click “Database”.<\/li>\n
  12. Select the database that you created for this WordPress site, then click “Go”.<\/li>\n
  13. Click “Check all”, then click “Go” to give this user all permissions on the selected database.<\/li>\n
  14. 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:”.<\/li>\n
  15. Next, we’ll install WordPress on the web server. Use PuTTY to SSH into the server where you wish to install WordPress.<\/li>\n
  16. Run\n
    wp core download<\/pre>\n

    To get the latest for WordPress. It may take a few moments. Wait for it to complete.<\/li>\n

  17. Replace the bracketed text with the database info that you wrote down in steps 3, 7, 8, and 14<\/strong><\/span>, then run\n
    wp core config --dbhost=[step14] --dbname=[step3] --dbuser=[step7] --dbpass=[step8]<\/pre>\n

    The actual command should look something like this below (but won’t be exactly the same)<\/p>\n

    wp core config --dbhost=hostname.db --dbname=sitenamewp --dbuser=wpuser_sitename --dbpass=R@ndomP@$w0rd<\/pre>\n<\/li>\n
  18. Run\n
    chmod 644 wp-config.php<\/pre>\n

    To change the permissions of the wp-config.php file.<\/li>\n

  19. Replace the bracketed text with your actual site URL, site name, admin user, admin user password, and admin user email,<\/span><\/strong> then run\n
    wp core install --url=[url] --title=\"[title]\" --admin_user=[user] --admin_password=[pass] --admin_email=[email]<\/pre>\n

    The actual command should look something like this below (but won’t be exactly the same)<\/p>\n

    wp core install --url=sitename.nfshost.com --title=\"Site Name\" --admin_user=AdminUsername --admin_password=AdminP@$w0rd --admin_email=example@example.com<\/pre>\n<\/li>\n
  20. In PuTTY, run the following commands one after another:\n
    cd wp-content\nmkdir -p uploads\nchgrp -R web uploads\nchmod -R 775 uploads\ncd ..<\/pre>\n

    This should ensure that you can upload files to your site (based on the recommendation here<\/a>.)<\/li>\n

  21. In PuTTY, run the following command:\n
    touch .htaccess<\/pre>\n

    This creates an empty .htaccess<\/code> file, which can be used for setting up permalinks.<\/li>\n

  22. In PuTTY, run the following commands one after another:\n
    chgrp -R web ..\/public\nfind ..\/public -type f -exec chmod 664 {} \\;\nfind ..\/public -type d -exec chmod 775 {} \\;\nchgrp -R web *\nfind . -type d -exec chmod 775 {} \\;\nfind . -type f -exec chmod 664 {} \\;<\/pre>\n

    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.<\/li>\n

  23. Optionally, add the line, define('FS_METHOD','direct'); <\/code>to the wp-config.php<\/code> file, immediately before the \/* That's all, stop editing! Happy publishing. *\/<\/code> line. This can make WordPress, Theme, and Plugin upgrades easier, but be sure you are aware of the security concerns<\/a> before doing this. To edit the wp-config.php<\/code> file…
    \nRun pico wp-config.php<\/code>
    \nAdd define('FS_METHOD','direct');<\/code>in the location described above
    \nPress CTRL + X to exit pico
    \nThen press Y to Save modified buffer, then press Enter to confirm the save.<\/li>\n
  24. Since we wrote passwords on the command line, you may wish to clear the history with\n
    history -c<\/pre>\n<\/li>\n
  25. Exit PuTTY with the exit<\/code> command<\/li>\n<\/ol>\n

    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.<\/p>\n

    Do these steps not work for you? You can run wp --info<\/code> 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.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

    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 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[5,4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/posts\/1102"}],"collection":[{"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/comments?post=1102"}],"version-history":[{"count":13,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/posts\/1102\/revisions"}],"predecessor-version":[{"id":1170,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/posts\/1102\/revisions\/1170"}],"wp:attachment":[{"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/media?parent=1102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/categories?post=1102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ectropyarts.com\/wp-json\/wp\/v2\/tags?post=1102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}