如何在带有LAMP堆栈的Ubuntu 20.04上安装WordPress

介绍 (Introduction)

WordPress is an extremely popular open-source technology for making websites and blogs on the internet today. Used by 63% of all websites that use a content management system (CMS), WordPress sites represent 36% of all websites that are currently online.

WordPress是一种非常流行的开源技术,用于在当今的互联网上制作网站和博客。 WordPress网站被使用内容管理系统(CMS)的所有网站中的63%使用,WordPress网站代表了当前在线的所有网站中的36%。

There are many different approaches to getting access to WordPress and some setup processes are more complex than others. This tutorial is intended for those who desire to install and administer a Wordpress instance on an unmanaged cloud server via the command line. Though this approach requires more steps than a ready-made WordPress installation, it offers administrators greater control over their WordPress environment.

有许多不同的方法可以访问WordPress,并且某些设置过程比其他过程更复杂。 本教程适用于希望通过命令行在非托管云服务器上安装和管理Wordpress实例的用户。 尽管这种方法比现成的WordPress安装需要更多的步骤,但它为管理员提供了对其WordPress环境的更好控制。

If you are looking to access a ready-made WordPress installation, DigitalOcean Marketplace offers a one-click app to get you started with WordPress through installation when spinning up your server.

如果您希望访问现成的WordPress安装, DigitalOcean Marketplace提供了一个一键式应用程序 ,可让您在旋转服务器时通过安装开始使用WordPress。

Depending on your needs and goals, you may find other options that are more suitable. As open-source software, WordPress can be freely downloaded and installed, but to be available on the web, you will likely need to purchase cloud infrastructure and a domain name. Continue following this guide if you are interested in working through the server-side installation and set up of a WordPress site.

根据您的需求和目标,您可能会找到其他更合适的选择。 作为开源软件,可以免费下载和安装WordPress,但要在Web上使用,您可能需要购买云基础架构和域名。 如果您有兴趣完成服务器端安装和设置WordPress网站,请继续按照本指南进行操作。

This tutorial will be using a LAMP (Linux, Apache, MySQL, and PHP) stack, which is one option for a server architecture that supports WordPress by providing the Linux operating system, Apache web server, MySQL database, and PHP programming language. We’ll install and set up WordPress via LAMP on a Linux Ubuntu 20.04 server.

本教程将使用LAMP( L inux, A pache, M ySQL和P HP)堆栈,这是通过提供Linux操作系统,Apache Web服务器,MySQL数据库和PHP支持WordPress的服务器体系结构的一种选择。编程语言。 我们将在Linux Ubuntu 20.04服务器上通过LAMP安装和设置WordPress。

先决条件 (Prerequisites)

In order to complete this tutorial, you will need access to an Ubuntu 20.04 server and will need to complete these steps before beginning this guide:

为了完成本教程,您将需要访问Ubuntu 20.04服务器,并且需要在开始本指南之前完成以下步骤:

  • Set up your server by following our Ubuntu 20.04 initial server setup guide, and ensure you have a non-root sudo user.

    请遵循我们的Ubuntu 20.04初始服务器设置指南来设置服务器 ,并确保您具有非root用户sudo

  • Install a LAMP stack by following our LAMP guide to install and configure this software.

    按照我们的LAMP指南 安装LAMP堆栈 ,以安装和配置此软件。

    • If you have a domain name… you can secure your site with Let’s Encrypt, which provides free, trusted certificates. Follow our Let’s Encrypt guide for Apache to set this up.

      如果您拥有域名… ,则可以使用Let's Encrypt(提供免费的受信任证书)保护您的网站。 请遵循我们的Apache Let's Encrypt指南进行设置。

    • If you do not have a domain… and you are just using this configuration for testing or personal use, you can use a self-signed certificate instead. This provides the same type of encryption, but without the domain validation. Follow our self-signed SSL guide for Apache to get set up.

      如果您没有域...而您只是使用此配置进行测试或个人使用,则可以使用自签名证书。 这提供了相同类型的加密,但没有域验证。 请遵循我们针对Apache的自签名SSL指南进行设置。

    Secure your site: WordPress takes in user input and stores user data, so it is important for it to have a layer of security. TLS/SSL is the technology that allows you to encrypt the traffic from your site so that your and your users’ connection is secure. Here are two options available to you to meet this requirement:

    保护您的网站安全 :WordPress接受用户输入并存储用户数据,因此拥有一层安全很重要。 TLS / SSL是一项技术,可让您加密来自站点的流量,以确保您和用户的连接安全。 您可以使用以下两个选项来满足此要求:

When you are finished with the setup steps, log into your server as your sudo user and continue below.

完成设置步骤后,以sudo用户身份登录服务器并继续以下操作。

第1步-为WordPress创建MySQL数据库和用户 (Step 1 — Creating a MySQL Database and User for WordPress)

The first step that we will take is a preparatory one. WordPress uses MySQL to manage and store site and user information. We have MySQL installed already, but we need to make a database and a user for WordPress to use.

我们将采取的第一步是准备工作。 WordPress使用MySQL来管理和存储站点和用户信息。 我们已经安装了MySQL,但是我们需要创建一个数据库和一个供WordPress使用的用户。

To get started, log into the MySQL root (administrative) account by issuing this command (note that this is not the root user of your server):

首先,通过发出以下命令登录到MySQL根(管理)帐户(请注意,这不是服务器的根用户):

  • mysql -u root -p

    mysql -u root -p

You will be prompted for the password you set for the MySQL root account when you installed the software.

安装该软件时,系统将提示您输入为MySQL根帐户设置的密码。

Note: If you cannot access your MySQL database via root, as a sudo user you can update your root user’s password by logging into the database like so:

注意 :如果您不能通过root用户访问MySQL数据库,作为sudo用户,您可以通过登录数据库来更新root用户的密码,如下所示:

  • sudo mysql -u root

    须藤mysql -u root

Once you receive the MySQL prompt, you can update the root user’s password. Here, replace new_password with a strong password of your choosing.

收到MySQL提示后,您可以更新root用户的密码。 在这里,用您选择的强密码替换new_password

  • ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';

    ALTER USER'root'@'localhost'通过mysql_native_password标识为' new_password ';

You may now type EXIT; and can log back into the database via password with the following command:

您现在可以输入EXIT; 并可以使用以下命令通过密码重新登录数据库:

  • mysql -u root -p

    mysql -u root -p

Within the database, we can create an exclusive database for WordPress to control. You can call this whatever you would like, but we will be using the name wordpress in this guide. Create the database for WordPress by typing:

在数据库中,我们可以创建一个专用数据库供WordPress控制。 您可以随意命名,但在本指南中我们将使用wordpress名称。 通过键入以下内容为WordPress创建数据库:

  • CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

    创建数据库wordpress默认字符集utf8 COLLATE utf8_unicode_ci;

Note: Every MySQL statement must end in a semi-colon (;). Check to make sure this is present if you are running into any issues.

注意:每个MySQL语句必须以分号( ; )结尾。 如果遇到任何问题,请检查以确保存在此问题。

Next, we are going to create a separate MySQL user account that we will use exclusively to operate our new database. Creating specific databases and accounts can support us from a management and security standpoint. We will use the name wordpressuser in this guide, but feel free to use whatever name is relevant for you.

接下来,我们将创建一个单独MySQL用户帐户,该帐户将专门用于操作新数据库。 从管理和安全的角度来看,创建特定的数据库和帐户可以为我们提供支持。 我们将在本指南中使用wordpressuser这个名称,但是请随意使用与您相关的任何名称。

We are going to create this account, set a password, and grant access to the database we created. We can do this by typing the following command. Remember to choose a strong password here for your database user where we have password:

我们将创建该帐户,设置密码,并授予对我们创建的数据库的访问权限。 我们可以通过键入以下命令来做到这一点。 记住在这里为您的数据库用户选择一个强密码,我们有password

  • CREATE USER 'wordpressuser'@'%' IDENTIFIED WITH mysql_native_password BY 'password';

    创建用户' wordpressuser '@'%'用mysql_native_password标识' 密码 ';

Next, let the database know that our wordpressuser should have complete access to the database we set up:

接下来,让数据库知道我们的wordpressuser应该具有对我们设置的数据库的完全访问权限:

  • GRANT ALL ON wordpress.* TO 'wordpressuser'@'%';

    授予对wordpress的所有许可 。* TO'wordpressuser '@'%';

You now have a database and user account, each made specifically for WordPress. We need to flush the privileges so that the current instance of MySQL knows about the recent changes we’ve made:

现在,您有一个数据库和用户帐户,每个帐户和帐户都是专门为WordPress创建的。 我们需要清除特权,以便MySQL的当前实例知道我们最近所做的更改:

  • FLUSH PRIVILEGES;

    冲洗特权;

Exit out of MySQL by typing:

输入以下内容退出MySQL:

  • EXIT;

    出口;

In the next step, we’ll lay some foundations for WordPress plugins by downloading PHP extensions for our server.

在下一步中,我们将通过下载服务器PHP扩展来为WordPress插件奠定基础。

第2步-安装其他PHP扩展 (Step 2 — Installing Additional PHP Extensions)

When setting up our LAMP stack, we only required a very minimal set of extensions in order to get PHP to communicate with MySQL. WordPress and many of its plugins leverage additional PHP extensions.

设置我们的LAMP堆栈时,我们只需要很少的扩展集即可使PHP与MySQL进行通信。 WordPress及其许多插件都利用了其他PHP扩展。

We can download and install some of the most popular PHP extensions for use with WordPress by typing:

我们可以通过键入以下内容来下载并安装一些最流行PHP扩展以用于WordPress:

  • sudo apt update

    sudo apt更新
  • sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

    sudo apt安装php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

This will lay the groundwork for installing additional plugins into our WordPress site.

这将为在我们的WordPress网站上安装其他插件奠定基础。

Note: Each WordPress plugin has its own set of requirements. Some may require additional PHP packages to be installed. Check your plugin documentation to discover its PHP requirements. If they are available, they can be installed with apt as demonstrated above.

注意:每个WordPress插件都有其自己的一组要求。 有些可能需要安装其他PHP软件包。 检查您的插件文档以发现其PHP要求。 如果可用,则可以如上所述安装apt

We will need to restart Apache to load these new extensions, we’ll be doing more configurations on Apache in the next section, so you can wait until then, or restart now to complete the PHP extension process.

我们将需要重新启动Apache来加载这些新扩展,我们将在下一部分中对Apache进行更多配置,因此您可以等到那时,或者现在重新启动以完成PHP扩展过程。

  • sudo systemctl restart apache2

    sudo systemctl重新启动apache2

步骤3 —调整Apache的配置以允许.htaccess覆盖和重写 (Step 3 — Adjusting Apache’s Configuration to Allow for .htaccess Overrides and Rewrites)

Next, we will be making a few minor adjustments to our Apache configuration. Based on the prerequisite tutorials, you should have a configuration file for your site in the /etc/apache2/sites-available/ directory.

接下来,我们将对Apache配置进行一些小的调整。 根据先决条件教程,您应该在/etc/apache2/sites-available/目录中具有站点的配置文件。

In this guide, we’ll use /etc/apache2/sites-available/wordpress.conf as an example here, but you should substitute the path to your configuration file where appropriate. Additionally, we will use /var/www/wordpress as the root directory of our WordPress install. You should use the web root specified in your own configuration. If you followed our LAMP tutorial, it may be your domain name instead of wordpress in both of these instances.

在本指南中,我们以/etc/apache2/sites-available/ wordpress .conf为例,但是您应该在适当的地方替换配置文件的路径。 此外,我们将使用/var/www/ wordpress作为WordPress安装的根目录。 您应该使用自己的配置中指定的Web根目录。 如果您遵循了我们的LAMP教程 ,则在这两种情况下都可能是您的域名而不是wordpress

Note: It’s possible you are using the 000-default.conf default configuration (with /var/www/html as your web root). This is fine to use if you’re only going to host one website on this server. If not, it’s better to split the necessary configuration into logical chunks, one file per site.

注意:可能您正在使用000-default.conf默认配置(以/var/www/html作为您的Web根)。 如果您只打算在此服务器上托管一个网站,则可以使用此方法。 如果没有,最好将必要的配置分成逻辑块,每个站点一个文件。

With our paths identified, we can move onto working with .htaccess so that Apache can handle configuration changes on a per-directory basis.

确定了路径后,我们可以继续使用.htaccess以便Apache可以按目录处理配置更改。

启用.htaccess覆盖 (Enabling .htaccess Overrides)

Currently, the use of .htaccess files is disabled. WordPress and many WordPress plugins use these files extensively for in-directory tweaks to the web server’s behavior.

当前,禁用.htaccess文件的使用。 WordPress和许多WordPress插件广泛使用这些文件对Web服务器的行为进行目录内调整。

Open the Apache configuration file for your website with a text editor like nano.

使用文本编辑器(例如nano)打开您网站的Apache配置文件。

  • sudo nano /etc/apache2/sites-available/wordpress.conf

    须藤纳米/etc/apache2/sites-available/wordpress.conf

To allow .htaccess files, we need to set the AllowOverride directive within a Directory block pointing to our document root. Add the following block of text inside the VirtualHost block in your configuration file, making sure to use the correct web root directory:

要允许.htaccess文件,我们需要在Directory块中设置AllowOverride指令,该指令指向我们的文档根目录。 在配置文件的VirtualHost块内添加以下文本块,确保使用正确的Web根目录:

/etc/apache2/sites-available/wordpress.conf
/etc/apache2/sites-available/wordpress.conf
<Directory /var/www/wordpress/>
    AllowOverride All
</Directory>

When you are finished, save and close the file. In nano, you can do this by pressing CTRL and X together, then Y, then ENTER.

完成后,保存并关闭文件。 在nano中,您可以通过同时按CTRLX ,然后按Y ,然后按ENTER来执行此操作。

启用重写模块 (Enabling the Rewrite Module)

Next, we can enable mod_rewrite so that we can utilize the WordPress permalink feature:

接下来,我们可以启用mod_rewrite以便我们可以利用WordPress永久链接功能:

  • sudo a2enmod rewrite

    sudo a2enmod重写

This allows you to have more human-readable permalinks to your posts, like the following two examples:

这样可以使您的帖子具有更多易于阅读的永久链接,例如以下两个示例:

http://example.com/2012/post-name/
http://example.com/2012/12/30/post-name

The a2enmod command calls a script that enables the specified module within the Apache configuration.

a2enmod命令调用一个脚本,该脚本启用Apache配置中的指定模块。

启用变更 (Enabling the Changes)

Before we implement the changes we’ve made, check to make sure we haven’t made any syntax errors by running the following test.

在实施所做的更改之前,请运行以下测试以确保没有发生任何语法错误。

  • sudo apache2ctl configtest

    须藤apache2ctl configtest

You may receive output like the following:

您可能会收到类似以下的输出:


   
   
Output
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message Syntax OK

If you wish to suppress the top line, just add a ServerName directive to your main (global) Apache configuration file at /etc/apache2/apache2.conf. The ServerName can be your server’s domain or IP address. This is just a message, however, and doesn’t affect the functionality of your site. As long as the output contains Syntax OK, you are ready to continue.

如果要取消显示第一行,只需在/etc/apache2/apache2.conf主(全局)Apache配置文件中添加ServerName指令。 ServerName可以是服务器的域或IP地址。 但是,这仅是一条消息,并不影响您网站的功能。 只要输出包含Syntax OK ,您就可以继续。

Restart Apache to implement the changes. Make sure to restart now even if you have restarted earlier in this tutorial.

重新启动Apache以实施更改。 即使您已在本教程的前面重新启动,也请确保立即重新启动。

  • sudo systemctl restart apache2

    sudo systemctl重新启动apache2

Next, we will download and set up WordPress itself.

接下来,我们将下载并设置WordPress本身。

第4步-下载WordPress (Step 4 — Downloading WordPress)

Now that our server software is configured, we can download and set up WordPress. For security reasons in particular, it is always recommended to get the latest version of WordPress from their site.

现在我们的服务器软件已配置完毕,我们可以下载并设置WordPress。 特别是出于安全原因,始终建议从其站点获取最新版本的WordPress。

Change into a writable directory (we recommend a temporary one like /tmp) and download the compressed release.

切换到可写目录(我们建议使用/tmp这样的临时/tmp )并下载压缩版本。

  • cd /tmp

    cd / tmp
  • curl -O https://wordpress.org/latest.tar.gz

    curl -O https://wordpress.org/latest.tar.gz

Extract the compressed file to create the WordPress directory structure:

解压缩压缩文件以创建WordPress目录结构:

  • tar xzvf latest.tar.gz

    tar xzvf Latest.tar.gz

We will be moving these files into our document root momentarily. Before we do, we can add a dummy .htaccess file so that this will be available for WordPress to use later.

我们将暂时将这些文件移到我们的文档中。 在执行此操作之前,我们可以添加一个虚拟的.htaccess文件,以便WordPress可以稍后使用它。

Create the file by typing:

通过键入以下内容来创建文件:

  • touch /tmp/wordpress/.htaccess

    触摸/tmp/wordpress/.htaccess

We’ll also copy over the sample configuration file to the filename that WordPress reads:

我们还将复制示例配置文件到WordPress读取的文件名:

  • cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

    cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

We can also create the upgrade directory, so that WordPress won’t run into permissions issues when trying to do this on its own following an update to its software:

我们还可以创建upgrade目录,以便WordPress在对其软件进行更新后尝试自行执行此操作时,不会遇到权限问题:

  • mkdir /tmp/wordpress/wp-content/upgrade

    mkdir / tmp / wordpress / wp-content / upgrade

Now, we can copy the entire contents of the directory into our document root. We are using a dot at the end of our source directory to indicate that everything within the directory should be copied, including hidden files (like the .htaccess file we created):

现在,我们可以将目录的全部内容复制到文档根目录中。 我们在源目录的末尾使用一个点来指示应复制目录中的所有内容,包括隐藏文件(如我们创建的.htaccess文件):

  • sudo cp -a /tmp/wordpress/. /var/www/wordpress

    须藤cp -a / tmp / wordpress /。 / var / www / wordpress

Ensure that you replace the /var/www/wordpress directory with the directory you have set up on your server.

确保将/var/www/ wordpress目录替换为在服务器上设置的目录。

第5步-配置WordPress目录 (Step 5 — Configuring the WordPress Directory)

Before we do the web-based WordPress setup, we need to adjust some items in our WordPress directory.

在进行基于Web的WordPress设置之前,我们需要调整WordPress目录中的某些项目。

调整所有权和权限 (Adjusting the Ownership and Permissions)

An important step that we need to accomplish is setting up reasonable file permissions and ownership.

我们需要完成的重要步骤是设置合理的文件权限和所有权。

We’ll start by giving ownership of all the files to the www-data user and group. This is the user that the Apache web server runs as, and Apache will need to be able to read and write WordPress files in order to serve the website and perform automatic updates.

我们将从将所有文件的所有权授予www-data用户和组开始。 这是运行Apache Web服务器的用户,Apache必须能够读写WordPress文件才能为网站提供服务并执行自动更新。

Update the ownership with the chown command which allows you to modify file ownership. Be sure to point to your server’s relevant directory.

使用chown命令更新所有权,该命令允许您修改文件所有权。 确保指向服务器的相关目录。

  • sudo chown -R www-data:www-data /var/www/wordpress

    须藤chown -R www-data:www-data / var / www / wordpress

Next we’ll run two find commands to set the correct permissions on the WordPress directories and files:

接下来,我们将运行两个find命令来设置WordPress目录和文件的正确权限:

  • sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;

    sudo查找/ var / www / wordpress / -type d -exec chmod 750 {} \;

  • sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;

    sudo查找/ var / www / wordpress / -type f -exec chmod 640 {} \;

These permissions should get you working effectively with WordPress, but note that some plugins and procedures may require additional tweaks.

这些权限应该可以使您有效地使用WordPress,但请注意,某些插件和过程可能需要进行其他调整。

设置WordPress配置文件 (Setting Up the WordPress Configuration File)

Now, we need to make some changes to the main WordPress configuration file.

现在,我们需要对主WordPress配置文件进行一些更改。

When we open the file, our first task will be to adjust some secret keys to provide a level of security for our installation. WordPress provides a secure generator for these values so that you do not have to try to come up with good values on your own. These are only used internally, so it won’t hurt usability to have complex, secure values here.

当我们打开文件时,我们的首要任务是调整一些秘密密钥,为我们的安装提供安全级别。 WordPress为这些值提供了安全的生成器,因此您不必自己尝试提出好的值。 这些仅在内部使用,因此在这里拥有复杂,安全的值不会损害可用性。

To grab secure values from the WordPress secret key generator, type:

要从WordPress密钥生成器获取安全值,请输入:

  • curl -s https://api.wordpress.org/secret-key/1.1/salt/

    curl -s https://api.wordpress.org/secret-key/1.1/salt/

You will get back unique values that resemble output similar to the block below.

您将获得类似于以下块的类似于输出的唯一值。

Warning! It is important that you request unique values each time. Do NOT copy the values below!

警告! 每次都要求唯一值很重要。 不要复制下面的值!


   
   
Output
define('AUTH_KEY', '1jl/vqfs<XhdXoAPz9 DO NOT COPY THESE VALUES c_j{iwqD^<+c9.k<J@4H'); define('SECURE_AUTH_KEY', 'E2N-h2]Dcvp+aS/p7X DO NOT COPY THESE VALUES {Ka(f;rv?Pxf})CgLi-3'); define('LOGGED_IN_KEY', 'W(50,{W^,OPB%PB<JF DO NOT COPY THESE VALUES 2;y&,2m%3]R6DUth[;88'); define('NONCE_KEY', 'll,4UC)7ua+8<!4VM+ DO NOT COPY THESE VALUES #`DXF+[$atzM7 o^-C7g'); define('AUTH_SALT', 'koMrurzOA+|L_lG}kf DO NOT COPY THESE VALUES 07VC*Lj*lD&?3w!BT#-'); define('SECURE_AUTH_SALT', 'p32*p,]z%LZ+pAu:VY DO NOT COPY THESE VALUES C-?y+K0DK_+F|0h{!_xY'); define('LOGGED_IN_SALT', 'i^/G2W7!-1H2OQ+t$3 DO NOT COPY THESE VALUES t6**bRVFSD[Hi])-qS`|'); define('NONCE_SALT', 'Q6]U:K?j4L%Z]}h^q7 DO NOT COPY THESE VALUES 1% ^qUswWgn+6&xqHN&%');

These are configuration lines that we can paste directly in our configuration file to set secure keys. Copy the output you received now.

这些配置行可以直接粘贴到配置文件中以设置安全密钥。 复制您现在收到的输出。

Next, open the WordPress configuration file:

接下来,打开WordPress配置文件:

  • sudo nano /var/www/wordpress/wp-config.php

    须藤纳米/ var / www / wordpress /wp-config.php

Find the section that contains the example values for those settings.

找到包含这些设置的示例值的部分。

/var/www/wordpress/wp-config.php
/var/www/wordpress/wp-config.php
. . .

define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

. . .

Delete those lines and paste in the values you copied from the command line:

删除这些行,然后粘贴从命令行复制的值:

/var/www/wordpress/wp-config.php
/var/www/wordpress/wp-config.php
. . .

define('AUTH_KEY',         'VALUES COPIED FROM THE COMMAND LINE');
define('SECURE_AUTH_KEY',  'VALUES COPIED FROM THE COMMAND LINE');
define('LOGGED_IN_KEY',    'VALUES COPIED FROM THE COMMAND LINE');
define('NONCE_KEY',        'VALUES COPIED FROM THE COMMAND LINE');
define('AUTH_SALT',        'VALUES COPIED FROM THE COMMAND LINE');
define('SECURE_AUTH_SALT', 'VALUES COPIED FROM THE COMMAND LINE');
define('LOGGED_IN_SALT',   'VALUES COPIED FROM THE COMMAND LINE');
define('NONCE_SALT',       'VALUES COPIED FROM THE COMMAND LINE');

. . .

Next, we are going to modify some of the database connection settings at the beginning of the file. You need to adjust the database name, the database user, and the associated password that you configured within MySQL.

接下来,我们将在文件的开头修改一些数据库连接设置。 您需要调整数据库名称,数据库用户以及在MySQL中配置的关联密码。

The other change we need to make is to set the method that WordPress should use to write to the filesystem. Since we’ve given the web server permission to write where it needs to, we can explicitly set the filesystem method to “direct”. Failure to set this with our current settings would result in WordPress prompting for FTP credentials when we perform some actions.

我们需要进行的另一项更改是设置WordPress用来写入文件系统的方法。 由于我们已授予Web服务器写入所需位置的权限,因此我们可以将文件系统方法显式设置为“ direct”。 如果不使用当前设置对此进行设置,则当我们执行某些操作时,WordPress会提示您输入FTP凭据。

This setting can be added below the database connection settings, or anywhere else in the file:

此设置可以添加到数据库连接设置下面,或文件中的其他任何位置:

/var/www/wordpress/wp-config.php
/var/www/wordpress/wp-config.php
. . .

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'wordpressuser' );

/** MySQL database password */
define( 'DB_PASSWORD', 'password' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );


. . .

define('FS_METHOD', 'direct');

Save and close the file when you are finished.

完成后保存并关闭文件。

步骤6 —通过Web界面完成安装 (Step 6 — Completing the Installation Through the Web Interface)

Now that the server configuration is complete, we can complete the installation through the web interface.

现在服务器配置已完成,我们可以通过Web界面完成安装。

In your web browser, navigate to your server’s domain name or public IP address:

在Web浏览器中,导航到服务器的域名或公共IP地址:

https://server_domain_or_IP

Select the language you would like to use:

选择您要使用的语言:

Next, you will come to the main setup page.

接下来,您将进入主设置页面。

Select a name for your WordPress site and choose a username. It is recommended to choose something unique and avoid common usernames like “admin” for security purposes. A strong password is generated automatically. Save this password or select an alternative strong password.

为您的WordPress网站选择一个名称,然后选择一个用户名。 为了安全起见,建议选择唯一的内容,并避免使用通用用户名,例如“ admin”。 系统会自动生成一个强密码。 保存此密码或选择其他强密码。

Enter your email address and select whether you want to discourage search engines from indexing your site:

输入您的电子邮件地址,然后选择是否要阻止搜索引擎将您的网站编入索引:

When you click ahead, you will be taken to a page that prompts you to log in:

当您单击前进时,将转到一个页面,提示您登录:

Once you log in, you will be taken to the WordPress administration dashboard:

登录后,您将被带到WordPress管理仪表板:

At this point, you can begin to design your WordPress website! If this is your first time using WordPress, explore the interface a bit to get acquainted with your new CMS.

此时,您可以开始设计WordPress网站! 如果这是您第一次使用WordPress,请稍微探索一下界面以熟悉新的CMS。

结论 (Conclusion)

Congratulations, WordPress is now installed and is ready to be used!

恭喜,WordPress已安装并可以使用!

At this point you may want to start doing the following:

此时,您可能要开始执行以下操作:

  • Choose your permalinks setting for WordPress posts, which can be found in Settings > Permalinks.

    选择WordPress帖子的永久链接设置,可以在Settings > Permalinks找到。

  • Select a new theme in Appearance > Themes.

    Appearance > Themes选择一个新Appearance > Themes

  • Install new plugins to increase your site’s functionality under Plugins > Add New.

    在“ Plugins > Add New下安装新插件,以增强您网站的功能。

  • If you are going to collaborate with others, you may also wish to add additional users at this time under Users > Add New.

    如果您要与其他人合作,那么您现在还可以在Users > Add New下添加其他用户。

You can find additional resources for alternate ways to install WordPress, learn how to install WordPress on different server distributions, automate your WordPress installations, and scale your WordPress sites by checking out our WordPress Community tag.

您可以找到其他资源,以了解安装WordPress的其他方法,了解如何在不同的服务器发行版上安装WordPress,自动化WordPress安装以及通过查看WordPress社区标签扩展WordPress网站。

翻译自: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-20-04-with-a-lamp-stack

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值