说明:关于LNMP的快速搭建以说明,这里只演示安装wordpress和phpAdmin
1.在mariadb主机上创建两个数据库以及用户授权
(1)创建和授权wordpress数据库
MariaDB [(none)]> create database wpdb;
MariaDB [(none)]> grant all on wpdb.* to wpuser@'192.168.80.%' identified by 'wppass';
MariaDB [(none)]> flush privileges;
(2)创建和授权phpAdmin数据库
MariaDB [(none)]> create database pma;
MariaDB [(none)]> grant all on pma.* to pmauser@'192.168.80.%' identified by 'pmapass';
MariaDB [(none)]> flush privileges;
2.下载wordpress安装包和phpAdmin安装包
(1)编辑worpress配置文件
# mv wp-config-sample.php wp-config.php
# vim wp-config.php
编辑内容如下:
/** WordPress数据库的名称 */
define('DB_NAME', 'wpdb');
/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');
/** MySQL数据库密码 */
define('DB_PASSWORD', 'wppass');
/** MySQL主机 */
define('DB_HOST', '192.168.80.118');
(2)编辑phpAdmin配置文件
# mv config.sample.inc.php config.inc.php
# vim config.inc.php
编辑内容如下:
$cfg['Servers'][$i]['host'] = '192.168.80.118';
3.虚拟主机的配置(一个虚拟主机一个配置文件)
(1)wordpress虚拟主机
# vim wordpress.conf
server {
listen 80;
server_name www.mywp.com;
location / {
root /www/html;
index index.html;
}
location /wordpress/ {
root /www/php;
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/php/$fastcgi_script_name;
include fastcgi_params;
}
}
(2)phpAdmin虚拟主机
# vim phpAdmin.conf
server {
listen 80;
server_name www.mypma.com;
location / {
root /www/html;
index index.html;
}
location /pma/ {
root /www/php;
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/php/$fastcgi_script_name;
include fastcgi_params;
}
}
提示:这里有可能提示需要安装一下插件,所以事先安装一下:mbstring和php。
4.配置本地hosts文件
192.168.80.128 www.mywp.com
192.168.80.128 www.mypma.com