Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use wp-cli to install the WordPress blog program on Ubuntu 14.04

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use wp-cli to install the WordPress blog program on Ubuntu 14.04. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Here, wp-cli is a powerful command-line tool that you can manage WordPress, which can help you. This article describes how to install wp-cli and how to use it to perform some common, practical tasks.

precondition

This article is written for Ubuntu 14.04. Before moving on, make sure you have a basic knowledge of Linode.

Tip:

This article is written for non-root users. Commands that need to elevate privileges are prefixed with sudo. If you are not familiar with the sudo command, you can check our user and group wizards.

Install WP-CLI

1. Wp-cli can be provided as a PHP archive file (.phar). You can download it using the wget or curl command:

one

Curl-O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Or

one

Wget https://www.52banwagong.com / wp-cli/builds/gh-pages/phar/wp-cli.phar

2. You need to do this. The phar file executable and move it to / usr/local/bin so that you can run it directly:

one

two

Chmod + x wp-cli.phar

Sudo mv wp-cli.phar / usr/local/bin/wp

3. Check whether the installation is correct:

one

Wp-info

You should see similar output shown below, which means you can continue:

one

two

three

four

five

six

seven

PHP binary: / usr/bin/php5

PHP version: 5.6.11-1ubuntu3.1

Php.ini used: / etc/php5/cli/php.ini

WP-CLI root dir: phar://wp-cli.phar

WP-CLI global config:

WP-CLI project config:

WP-CLI version: 0.21.1

You can also use the above three steps to upgrade wp-cli.

Activate Bash complete

The bash completion feature of wp-cli allows you to view all available commands dynamically.

1. Download bash script from your home directory:

one

two

Cd ~ /

Wget https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash

2. Edit the .bashrc file. When you log in, it will be loaded by shell. Open the file and add the following line to the editor:

File excerpt / .bashrc

one

Source / home/$USER/wp-completion.bash

Run the following command to reload the bash configuration file:

one

Source / .bashrc

okay. Bash completion is now enabled. To test it, type wp theme (including the following space) and press Tab twice. You will see the list of available commands for the available wp theme again at the prompt.

Basic knowledge of WP-CLI

Before we move on, let's take a look at how wp-cli works. This will help you feel comfortable with the steps to come.

So far, we have seen wp-cli accessed through the main command wp-cli. You can use nested subcommands to execute the main command. For example, we have a command to download WordPress, which is:

one

Wp core download

Here, wp is the main command, and core and download are its nested subcommands. Nested subcommands can extend one or two levels.

Wp-cli also provides a detailed help section that shows all the commands you might need. Access help:

one

Wp help

The output should look like this:

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

sixteen

seventeen

eighteen

nineteen

twenty

twenty-one

twenty-two

Wp

DESCRIPTION

Manage WordPress through the command-line.

SYNOPSIS

Wp

SUBCOMMANDS

Cache Manage the object cache.

Cap Manage user capabilities.

Cli Get information about WP-CLI itself.

Comment Manage comments.

Core Download, install, update and otherwise manage WordPress proper.

Cron Manage WP-Cron events and schedules.

Db Perform basic database operations.

Eval Execute arbitrary PHP code after loading WordPress.

Eval-file Load and execute a PHP file after loading WordPress.

:

Tip: use subcommands to help you navigate through this help menu. The up and down arrow keys allow you to scroll the entire list of help commands. Type Q to exit the help menu. For more information about how to browse the full help section further, you can type h in the prompt above.

You can use the enabled bash completion to demonstrate the list of available commands for wp-cli. Just type wp and press tab twice. You will see a list of available commands. Now, type wp core and press tab twice. You will see a list of commands available for the core. For any main or subcommand, you can reuse the double tag after the command.

Install WordPress

Set up a database

Before you begin, you need to set up a database. Log in to the MySQL server and replace user with the MySQL user name

one

Mysql-u user-p

2. Create a database:

one

Create database wordpress

3. Grant requires the privileges provided to mysql users, while WordPress allows database access. Replace user and password with allowed mysql users:

one

Grant all on wordpress.* to 'user' identified by' password'

Type exit to exit the MySQL command line.

Main installation

1. Change to the Apache example.com directory:

one

Cd / var/www/html/example.com

2. Change the ownership of publichtml directory. Apache comes with its own usergroup www data. As a recommended practice, you should change the ownership of the installation directory to this group. You also need to add the user name to the group and enable group write permissions to execute any commands in the directory:

one

two

three

Sudo chown-R www-data public_html

Sudo usermod-aG www-data username

Sudo chmod-R Grouw public_html

Next, download the WordPress file. Here, you need to use the prefix sudo-u www data to run the wp-cli command under the www-data group. You need to use this command each time you run the command, which requires wp-cli to write to the directory, just like installing or upgrading:

one

Wp core download

4. Create a wp-config.php file:

one

Wp core config-dbname=wordpress-dbuser=user-dbpass=password-dbhost=localhost-dbprefix=wp_

The dbhost and db prefixes are completely optional and can be omitted unless you need to change their default values.

5. Run the installation:

one

Wp core install-url= "https://www.52banwagong.com"-title=" Blog Title "- admin_user=" adminuser "- admin_password=" password "- admin_email=" email@domain.com "

Your WordPress blog is now ready to use.

Common command

Install and update plug-ins

Suppose you want to install the Yoast search engine optimization plug-in. Your first step will be to find the plug-in slug. In this case, the slug is the last part of permalink url, which describes the plug-in directory. For example, a plug-in can be found in http://wordpress.org/plugins/plugin-dir/. In this case, plugin-dir is part of the plug-in. You installed this plugin on your blog, and its address is http://example.com/wp-content/plugins/plugin-dir/. Since this segment is unique to each plug-in, you can use wp-cli to search for fragments of any plug-in and install it:

one

Wp plugin search yoast

You'll get an output similar to this.

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

sixteen

seventeen

eighteen

nineteen

Success: Showing 10 of 259 plugins.

+-+

| | name | slug | rating | |

+-+

| | Yoast SEO | wordpress-seo | 90 | |

| | SO Clean Up Yoast SEO | so-clean-up-wp-seo | 96 | |

| | All Meta Stats Yoast SEO Addon | all-meta-stats-yoast-seo-addon | 100 | |

| | Google Analytics by Yoast | google-analytics-for-wordpress | 80 | |

| | Import Settings into WordPress | yoast-seo-settings-xml-csv-impor | 0 | |

| | SEO by Yoast | t |

| | Surbma-Yoast Breadcrumb Short | surbma-yoast-breadcrumb-shortcod | 84 | |

| | code | e |

| | Meta Box Yoast SEO | meta-box-yoast-seo | 0 | |

| | Keyword Stats Addon for Yoast S | keyword-stats-addon-for-yoast-se | 100 | |

| | EO | o |

| | Meta Description Stats Addon fo | meta-description-stats-addon-for | 100 | |

| | r Yoast SEO |-yoast-seo |

| | Title Stats Addon for Yoast SEO | title-stats-addon-for-yoast-seo | 100 | |

+-+

By modifying the command, you can see more than 10 plug-ins on each page.

one

Wp plugin search yoast-per-page=20

Now that you know the part of the plug-in you want to install (wordpressseo), copy it to your command and activate it:

one

two

Wp plugin install wordpress-seo

Wp plugin activate wordpress-seo

To update any plug-in, you can use:

one

Wp plugin update wordpress-seo

Or, to update all plug-ins, you can use:

one

Wp plugin update-all

Or, to list all the installed plug-ins on your blog, you can use:

one

Wp plugin list

To uninstall the plug-in, you can use:

one

Wp plugin uninstall wordpress-seo

Install and update themes

The process of installing and activating a theme is almost identical to that of a plug-in. Simply swap the plug-in theme in all commands.

So, to find a theme, you can use:

one

Wp theme search twentytwelve

To install and activate, you can use:

one

two

Wp theme install twentytwelve

Wp theme activate twentytwelve

To update one or all of the topics, you can use:

one

two

Wp theme update twentytwelve

Wp theme update-all

To list all topics in tabular form, you can use:

one

Wp theme list

To uninstall a theme, you can use:

one

Wp theme uninstall twentytwelve

Updates to WordPress

You can update your blog with the following command:

one

two

Wp core update

Wp core update-db

The first command updates the file. The second task completes the database upgrade.

Thank you for reading! This is the end of the article on "how to use wp-cli to install the WordPress blog program on Ubuntu 14.04". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 293

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report