如何在 Ubuntu 18.04 上安装 WordPress

在本文中,我们将专注于如何在Ubuntu上安装WordPress 18.04. WordPress是一个基于PHP和MySQL的免费和开源内容管理平台,它是世界上领先的博客和内容管理系统,其市场份额超过60%,超过了其竞争对手如Joomla和Drupal。WordPress于2003年5月27日首次发布,迄今为止拥有超过6000万个网站!它变得如此强大和受欢迎,以至于一些主要品牌 / 公司已经在平台上托管了他们的网站。

为什么WordPress如此受欢迎?

那么为什么WordPress如此受欢迎呢?让我们简要研究一些导致该平台巨大的成功的因素。

易于使用

WordPress 配备了一个简单,直观和易于使用的仪表板. 仪表板不需要任何Web编程语言的知识,如PHP,HTML5和CSS3,你可以创建一个网站,只需点击几个按钮。

成本效益

WordPress极大地节省了你必须支付开发人员大量现金来开发你的网站的痛苦。你所需要做的就是获得一个免费的WordPress主题或购买一个并安装它。一旦安装,你有自由部署任何适合你的功能,并自定义无数的功能,而无需运行大量代码。

WordPress 网站具有响应性

WordPress平台本质上是响应性的,你不必担心你的网站能够适应多个设备,这也增加了你的网站在谷歌的SEO分数中排名更高!

WordPress 已做好 SEO 准备

WordPress 是使用结构齐全,清洁和一致的代码构建的,这使得您的博客 / 网站很容易被 Google 和其他搜索引擎索引,从而使您的网站排名更高。

易于安装和升级

很容易在Ubuntu或任何其他操作系统上安装WordPress。有这么多开源脚本甚至可以自动化这个过程。许多托管公司为WordPress提供一个单击的安装功能,以便您在短时间内开始。

在 Ubuntu 18.04 上安装WordPress

在我们开始之前,让我们更新和升级系统. 作为 root 用户登录到您的系统,并更新系统以更新存储库。

1apt update && apt upgrade

Output update and upgrade the ubuntu system Next, we are going to install the LAMP stack for WordPress to function. LAMP is short for Linux Apache MySQL and PHP.

步骤1:安装Apache

让我们先跳进并安装Apache,然后执行下面的命令。

1apt install apache2

Output Install Apache2 To confirm that Apache is installed on your system, execute the following command.

1systemctl status apache2

Output how to check apache2 status To verify further, open your browser and go to your server's IP address.

1https://ip-address

Output Apache Web Server Default Page

步骤二:安装MySQL

接下来,我们将安装MariaDB数据库引擎来存储我们的Wordpress文件。MariaDB是MySQL的开源叉子,大多数托管公司使用它而不是MySQL。

1apt install mariadb-server mariadb-client

Output Install MySQL Mariadb Server Mariadb Client Let's now secure our MariaDB database engine and disallow remote root login.

1$ mysql_secure_installation

The first step will prompt you to change the root password to login to the database. You can opt to change it or skip if you are convinced that you have a strong password. To skip changing type n. Change The Root Password For safety's sake, you will be prompted to remove anonymous users. Type Y. Remove Anonymous Users Next, disallow remote root login to prevent hackers from accessing your database. However, for testing purposes, you may want to allow log in remotely if you are configuring a virtual server Disallow Root Login Remotely Next, remove the test database. Remove Test Database Finally, reload the database to effect the changes. Reload Privilege Table

步骤三:安装PHP

最后,我们将安装PHP作为LAMP堆栈的最后组件。

1apt install php php-mysql

Output Install Php To confirm that PHP is installed , created a info.php file at /var/www/html/ path

1vim /var/www/html/info.php

附上以下几行:

1<?php
2phpinfo();
3?>

保存和退出. 打开您的浏览器,并附加 /info.php 到服务器的 URL。

1https://ip-address/info.php

Output Info Php Webpage

第4步:创建WordPress数据库

现在是时候作为 root 登录我们的 MariaDB 数据库,并创建一个数据库来容纳我们的 WordPress 数据。

1$ mysql -u root -p

Output Mysql Root Login Create a database for our WordPress installation.

1CREATE DATABASE wordpress_db;

Output Create Wordpress Database Next, create a database user for our WordPress setup.

1CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';

Output Create User For Wordpress Database Grant privileges to the user Next, grant the user permissions to access the database

1GRANT ALL ON wordpress_db.* TO 'wp_user'@'localhost' IDENTIFIED BY 'password';

Output Grant Privileges To Wp User On Wordpress Database Great, now you can exit the database.

1FLUSH PRIVILEGES;
2
3Exit;

步骤五:安装WordPress CMS

去你的 temp 目录并下载最新的 WordPress 文件

1cd /tmp && wget https://wordpress.org/latest.tar.gz

Output Download Wordpress Next, Uncompress the tarball which will generate a folder called "wordpress".

1tar -xvf latest.tar.gz

Output Uncompress Wordpress Tarball Copy the wordpress folder to /var/www/html/ path.

1cp -R wordpress /var/www/html/

运行下面的命令来更改WordPress目录的所有权。

1chown -R www-data:www-data /var/www/html/wordpress/

更改 WordPress 文件夹的文件权限。

1chmod -R 755 /var/www/html/wordpress/

创建上传目录。

1$ mkdir /var/www/html/wordpress/wp-content/uploads

最后,更改上传目录的权限。

1chown -R www-data:www-data /var/www/html/wordpress/wp-content/uploads/

打开您的浏览器,然后到服务器的URL。

1https://server-ip/wordpress

You’ll be presented with a WordPress wizard and a list of credentials required to successfully set it up. install wordpress on ubuntu 18.04 Fill out the form as shown with the credentials specified when creating the WordPress database in the MariaDB database. Leave out the database host and table prefix and Hit ‘Submit’ button. install wordpress on ubuntu 18.04 If all the details are correct, you will be given the green light to proceed. Run the installation. Alright Sparky Run The Installation Fill out the additional details required such as site title, Username, and Password and save them somewhere safe lest you forget. Ensure to use a strong password. Welcome More Information Needed Scroll down and Hit 'Install WordPress'. If all went well, then you will get a 'Success' notification as shown.

Success installing WordPress

Click on the 'Login' button to get to access the Login page of your fresh WordPress installation. Log In To Wordpress Provide your login credentials and hit 'Login'. wordpress dashboard Voila! there goes the WordPress dashboard that you can use to create your first blog or website! Congratulations for having come this far. You can now proceed to discover the various features, plugins, and themes and proceed setting up your first blog/website!

Published At
Categories with 技术
comments powered by Disqus