准备新的虚拟机,修改主机名并配置yum源(所需包 lnmp+wordpress.zip)
hostnamectl set-hostname lnmp
vi /etc/yum.repos.d/local.repo //配置yum源
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[lnmp]
name=lnmp
baseurl=file:///root/lnmp
gpgcheck=0
enabled=1
先下载解压缩
yum insatall -y unzip
下载所需要的依赖
yum -y install nginx mariadb-server mariadb php-fpm php-mysql
NGINX
ystemctl start nginx && systemctl enable nginx
# vi /etc/nginx/conf.d/default.conf
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# systemctl restart nginx //重启服务
MYAQL
systemctl start mariadb && systemctl enable mariadb //启动数据库
# mysql_secure_installation //初始化数据库
# mysql -uroot -p123456 //登录数据库
> create database wordpress; //创建数据库服务
> grant all privileges on *.* to root@localhost identified by '123456' with grant option; //授权所有用户拥有本地数据库的所有权限。
> grant all privileges on *.* to root@"%" identified by '123456' with grant option; //授权用户可进行远程登录
PHP
vi /etc/php-fpm.d/www.conf
39 user = nginx
40 ; RPM: Keep a group allowed to write in log dir.
41 group = nginx
systemctl start php-fpm && systemctl enable php-fpm
Wordpress
unzip wordpress-4.7.3-zh_CN.zip
cd /usr/share/nginx/html
rm -rf *
cp -rvf /root/wordpress* ./
cp wp-config-sample.php wp-config.php
chmod 777 *
vi wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');
使用Curl命令,返回前端页面
/** MySQL数据库用户名 */
define('DB_USER', 'root');
/** MySQL数据库密码 */
define('DB_PASSWORD', '123456');
/** MySQL主机 */
define('DB_HOST', '127.0.0.1');