Home  >  Article  >  Computer Tutorials  >  Build a WordPress website on Ubuntu 22.04 in 9 steps

Build a WordPress website on Ubuntu 22.04 in 9 steps

PHPz
PHPzforward
2024-02-20 15:09:22336browse

Quickly build a WordPress website on Ubuntu 22.04. After reading the following 9 steps, you can quickly build your own WordPress site.

1. Install Apache2 and PHP.

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

<code>sudo apt update</code><code>sudo apt install apache2</code><code>sudo apt install php libapache2-mod-php php-mysql</code>

2. Install mariadb database

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

<code>sudo apt install mariadb-server</code>

In steps 3 to 6, the commands executed in the terminal can also be executed by logging in to the database and executing the corresponding SQL commands.

<code>sudo mysql -uroot -p</code>

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

3. Create a new database.

Suppose you want to set the database name to "wordpress", execute the following command in the terminal:

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

<code>CREATE DATABASE wordpress;</code>

4. Create a new database user.

Suppose you want to set the username to "linux265" and the password to the password you choose. Execute the following command in the terminal:

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

<code>CREATE USER 'linux265'@'localhost' IDENTIFIED BY 'wordpress';</code>

5. Grant the newly created database user all permissions on the new database.

This will allow the "linux265" user to perform any operation on the "wordpress" database, execute the following command:

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

<code>GRANT ALL PRIVILEGES ON wordpress.* TO 'linux265'@'localhost';</code>

6. Refresh permissions and exit MariaDB, execute the following command:

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

<code>FLUSH PRIVILEGES;</code><code>exit;</code>

7. Now, you can download the latest version of WordPress from the WordPress official website. Run the following command in the terminal:

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

<code>sudo wget https://cn.wordpress.org/latest-zh_CN.tar.gz</code>

Or download from https://cn.wordpress.org/. Unzip the downloaded WordPress file and execute the following command:

<code>sudo tar -zxvf latest-zh_CN.tar.gz</code><code>or</code><code>sudo unzip latest-zh_CN.zip</code>

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

8. Move the unzipped wordpress file to your website directory.

Assume that your website directory is /var/www/html, execute the following command:

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

<code>sudo mv wordpress/* /var/www/html/</code><code>sudo chown -hR www-data: /var/www/html</code>

9. Now, you can access the WordPress installation page through the browser.

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

Ubuntu 22.04 搭建 WordPress 网站,9 步搞定

At this point, the entire WordPress building process has been explained.

Try it on your server!

The above is the detailed content of Build a WordPress website on Ubuntu 22.04 in 9 steps. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete