参照博文《Website for Students》或《How to Install WordPress with LAMP Stack on Ubuntu 18.04》进行搭建.

在Ubuntu18.04上,分别按照《Website for Students》和文章《How to Install WordPress with LAMP Stack on Ubuntu 18.04》搭建网站时,发现第一篇文章能够成功进入WordPress,而第二篇文章无法配置WordPress,经分析后通过命令

1
apt install php-mysql

进行修复,成功进入WordPress配置页面。

下面根据前面两篇文章总结出一个搭建网站的方法,一共分为7步:

具体地

Step 1: Connect to your Server,更新系统

1
2
apt-get update
apt-get upgrade

Step 2: Apache Web Server Installation,安装Web服务器

1
apt-get install apache2
1
systemctl enable apache2
1
systemctl status apache2

Step 3: Install PHP,安装PHP

1
apt install php php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip<strong> php-mysql</strong>

Step 4: Install the MySQL Database server,安装数据库

1
apt install mysql-server
1
mysql_secure_installation

Step 5: Create a Database for WordPress,为网站创建一个数据库

1
mysql -u root -p
CREATE DATABASE wp;
GRANT ALL PRIVILEGES ON wp.* TO 'jayzon'@'localhost' IDENTIFIED BY 'StrongPassword';
FLUSH PRIVILEGES;
EXIT;

Step 6: Install WordPress,安装WordPress

1
2
3
4
5
cd /var/www/html
wget -c http://wordpress.org/latest.zip
unzip latest.zip
chown -R www-data:www-data wordpress
rm latest.zip
1
2
cd /var/www/html/wordpress
mv wp-config-sample.php wp-config.php
1
vim wp-config.php

插入一下代码

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

/** MySQL database username */
define(‘DB_USER’, ‘jayzon‘);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘StrongPassword‘);

/** 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’, ‘’);

Step 6: Create the Virtual Host Files,打开80端口

1
vim /etc/apache2/sites-available/your_domain.com.conf


ServerAdmin admin@jayzonxu.com
ServerName jayzonxu.com
ServerAlias www.jayzonxu.com
DocumentRoot /var/www/html/wordpress


     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted


ErrorLog ${APACHE_LOG_DIR}/jayzonxu.com_error.log 
CustomLog ${APACHE_LOG_DIR}/jayzonxu.com_access.log combined 
1
ln -s /etc/apache2/sites-available/jayzonxu.com.conf /etc/apache2/sites-enabled/jayzonxu.com.conf

Step 7: Configure WordPress,配置网站

在浏览器中输入以下网址,进行配置WordPress

http://www.jayzonxu.com/
更多请参考 [embed]https://www.rosehosting.com/blog/how-to-install-wordpress-with-lamp-stack-on-ubuntu-18-04/[/embed]