注:本次使用的操作系统为centos7
1、关闭防火墙与selinux
systemctl stop firewalld
setenforce 0
2、配置yum源
vi /etc/yum.repos.d/centos.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[lnmp]
name=lnmp
baseurl=file:///root/lnmp
gpgcheck=0
enabled=1
3、安装环境
yum install nginx mariadb-server php php-mysql php-fpm
systemctl start nginx mariadb php-fpm
systemctl status mariadb nginx php-fpm
此时即可查看nginx的默认界面
4、修改配置文件
vim /etc/nginx/conf.d/default.conf
将:
location / {
root /usr/share/nginx/html;
index index.html index.htm;
修改为:
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
将:
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
修改为:
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
vim /etc/php-fpm.d/www.conf
将:
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache
修改为:
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
systemctl restart php-fpm
vim /usr/share/nginx/html/test.php ————>创建一个测试页面
<?php
phpinfo();
?>
curl http://192.168.100.20/test.php(也可用浏览器访问)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<style type="text/css">
body {background-color: #ffffff; color: #000000;}
body, td, th, h1, h2 {font-family: sans-serif;}
pre {margin: 0px; font-family: monospace;}
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
a:hover {text-decoration: underline;}
table {border-collapse: collapse;}
.center {text-align: center;}
.center table { margin-left: auto; margin-right: auto; text-align: left;}
.center th { text-align: center !important; }
td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
······················
5、处理wordpress
[root@localhost ~]# yum -y install unzip
[root@localhost ~]# unzip wordpress-4.7.3-zh_CN.zip
[root@localhost ~]# mv /root/wordpress/* /usr/share/nginx/html/
浏览器访问:192.168.100.20 即可进入
点击开始:
6、初始化mariadb数据库
[root@localhost ~]# mysql_secure_installation
回车
回车
密码
确认密码
回车
回车
回车
回车
[root@localhost ~]# mysql -uroot -p000000
MariaDB [(none)]> show databases; 查看数据库
MariaDB [(none)]> create database wordpress; 创建数据库
7、初始化wordpress
填写以下信息
点击提交,进入以下页面
[root@localhost ~]# vim /usr/share/nginx/html/wp-config.php 在此目录下创建文件
并将它所给的内容复制到该文件内,并点击安装
填写以下信息:
完成