ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Install a Basic WordPress Site with WP-CLI

    IT Discussion
    wordpress wp-cli
    6
    14
    1.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by scottalanmiller

      WP-CLI is an open source command line for WordPress. Here we will demonstrate a very basic install of WordPress assuming that we have a working web server and PHP stack with MariaDB or MySQL already installed. And assuming that you have installed WP-CLI and have it in your path as wp.

      First change directory into your default web directory:

      cd /var/www/html
      

      Now to get you up and running quickly, here is a single line installer to just copy and paste so that you can use it quickly. Below we will break down the parts of it, but if you just want to get up and running, here you go:

      wp core download; wp core config --dbname=dbname --dbuser=dbuser --dbpass='mysecret' --dbhost=localhost; wp db create ; wp core install --url=mysite.com --title="My Title" --admin_user="admin" --admin_email="[email protected]"
      

      Now the breakdown:

      In my example I am using CentOS, RHEL or Fedora. But the idea is the same regardless. Now we need to download the WordPress files.

      wp core download
      

      Once downloaded, we need to make a wp-config.php file, which we can do by copying the wp-config.php.sample file and filling in our credentials for our database server. We need only the server name (normally just localhost) and a username and password that have been set up with access to create databases on our server. You can specify here a dedicated database name (not yet created) or one that is already created and specify an unused prefix OR.... we can do this with WP as well...

      wp core config --dbname=databasename --dbuser=databaseuser --dbpass=databasepassword --dbhost=localhost --dbprefix=prfx_
      wp db create
      

      This command takes the details in the wp-config.php file and creates the database that we need based on the specifications there. If you are doing this multiple times with a single database, most of these details can simply be copied from another installation.

      Once the database is ready, we are free to set up our site:

      wp core install --url=mysite.mydomain.com --title="My Cool Site" --admin_user="admin" --admin_email="[email protected]"
      

      That's it. Your site should be up and running assuming that your infrastructure is ready for it. A very simplistic example, but just three commands from blank LAMP (or similar server) to working WordPress install.

      ObsolesceO 1 Reply Last reply Reply Quote 5
      • BRRABillB
        BRRABill
        last edited by

        One thing to note, that I missed.

        When you run the command to make the admin account, the command will return a password to you. You may want to write that down. 🙂

        If not, you can reset it as follows with WP-CLI:

        wp user update admin --user_pass=Duhduhduh1
        

        But this works out really well. Very easy.

        1 Reply Last reply Reply Quote 3
        • ObsolesceO
          Obsolesce @scottalanmiller
          last edited by

          @scottalanmiller said in Install a Basic WordPress Site with WP-CLI:

          In my example I am using CentOS, RHEL or Fedora. But the idea is the same regardless. Now we need to download the WordPress files.
          wp core download

          Do you run this command as root? It gives a warning about that.

          black3dynamiteB scottalanmillerS 2 Replies Last reply Reply Quote 0
          • black3dynamiteB
            black3dynamite @Obsolesce
            last edited by

            @tim_g said in Install a Basic WordPress Site with WP-CLI:

            @scottalanmiller said in Install a Basic WordPress Site with WP-CLI:

            In my example I am using CentOS, RHEL or Fedora. But the idea is the same regardless. Now we need to download the WordPress files.
            wp core download

            Do you run this command as root? It gives a warning about that.

            Probably have to run sudo -u apache wp core download.

            1 Reply Last reply Reply Quote 0
            • scottalanmillerS
              scottalanmiller @Obsolesce
              last edited by

              @tim_g said in Install a Basic WordPress Site with WP-CLI:

              @scottalanmiller said in Install a Basic WordPress Site with WP-CLI:

              In my example I am using CentOS, RHEL or Fedora. But the idea is the same regardless. Now we need to download the WordPress files.
              wp core download

              Do you run this command as root? It gives a warning about that.

              As the Apache user.

              1 Reply Last reply Reply Quote 0
              • NashBrydgesN
                NashBrydges
                last edited by

                I know that manually installing it I can tell it if I want it to run as a subdomain or a subfolder (blog.domain.com or domain.com/blog). If I want to use the subfolder method, is it as simple as changing this section?

                wp core install --url=mysite.com/blog

                A ObsolesceO 2 Replies Last reply Reply Quote 0
                • A
                  Alex Sage @NashBrydges
                  last edited by

                  @nashbrydges Seem so 🐶

                  https://developer.wordpress.org/cli/commands/core/install/

                  1 Reply Last reply Reply Quote 0
                  • ObsolesceO
                    Obsolesce @NashBrydges
                    last edited by Obsolesce

                    @nashbrydges said in Install a Basic WordPress Site with WP-CLI:

                    I know that manually installing it I can tell it if I want it to run as a subdomain or a subfolder (blog.domain.com or domain.com/blog). If I want to use the subfolder method, is it as simple as changing this section?

                    wp core install --url=mysite.com/blog

                    Yes, yoursite.com/path/to/wordpress. You need to anyways or it won't work correctly.

                    1 Reply Last reply Reply Quote 0
                    • NashBrydgesN
                      NashBrydges
                      last edited by

                      Now getting a too many redirects error. I entered https://domain.com/blog as a URL.

                      ObsolesceO 1 Reply Last reply Reply Quote 0
                      • ObsolesceO
                        Obsolesce @NashBrydges
                        last edited by

                        @nashbrydges said in Install a Basic WordPress Site with WP-CLI:

                        Now getting a too many redirects error. I entered https://domain.com/blog as a URL.

                        Try clearing your browser cache

                        1 Reply Last reply Reply Quote 0
                        • NashBrydgesN
                          NashBrydges
                          last edited by

                          It allows me access when I set it up without https in the url. But once in settings, and I change the blog address from http://domain.com/blog to https://domain.com/blog I get the same too many redirects error. Cleared history and cache 3 times and still same issue.

                          I'm going to blow this install away and recover from backup and will have to install manually.

                          Still can't figure out why this issue. The root domain works perfectly with Let's Encrypt but as soon as I get to the blog folder it just shits all over itself.

                          ObsolesceO 1 Reply Last reply Reply Quote 0
                          • NashBrydgesN
                            NashBrydges
                            last edited by

                            It's loading but had to allow unsafe script for the blog to load. Gotta go digging around for that now.

                            1 Reply Last reply Reply Quote 0
                            • ObsolesceO
                              Obsolesce @NashBrydges
                              last edited by

                              @nashbrydges said in Install a Basic WordPress Site with WP-CLI:

                              It allows me access when I set it up without https in the url. But once in settings, and I change the blog address from http://domain.com/blog to https://domain.com/blog I get the same too many redirects error. Cleared history and cache 3 times and still same issue.

                              I'm going to blow this install away and recover from backup and will have to install manually.

                              Still can't figure out why this issue. The root domain works perfectly with Let's Encrypt but as soon as I get to the blog folder it just shits all over itself.

                              How did you set up the whole thing? Did you use my guide? It includes the SSL set up.

                              NashBrydgesN 1 Reply Last reply Reply Quote 0
                              • NashBrydgesN
                                NashBrydges @Obsolesce
                                last edited by

                                @tim_g said in Install a Basic WordPress Site with WP-CLI:

                                @nashbrydges said in Install a Basic WordPress Site with WP-CLI:

                                It allows me access when I set it up without https in the url. But once in settings, and I change the blog address from http://domain.com/blog to https://domain.com/blog I get the same too many redirects error. Cleared history and cache 3 times and still same issue.

                                I'm going to blow this install away and recover from backup and will have to install manually.

                                Still can't figure out why this issue. The root domain works perfectly with Let's Encrypt but as soon as I get to the blog folder it just shits all over itself.

                                How did you set up the whole thing? Did you use my guide? It includes the SSL set up.

                                I used your guide up to the SSL setup. I'm running a website in the root directory and Nginx as a proxy.

                                1 Reply Last reply Reply Quote 0
                                • 1 / 1
                                • First post
                                  Last post