lnmp与wordpress搭建

基础环境1511的centos7镜像

我这里的lnmp软件包和wordpress压缩包是老师的资源,水平有限,仅供参考
关防火墙和规则链

[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# iptables -Z
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -X

yum源的配置

把lnmp的包上传到opt目录下(用于下载lnmp)
在opt目录创建centos文件夹

在这里插入图片描述

然后新建yum源文件

[root@localhost yum.repos.d]# vi /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
enabled=1
gpgcheck=0

[lnmp]
name=lnmp
baseurl=file:///opt/lnmp
gpgcheck=0
enabled=1

然后挂载、清空缓存、查看yum源

[root@localhost yum.repos.d]# mount /dev/sr0 /opt/centos/
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum repolist

在这里插入图片描述


yum做好了。下面来安装nginx/mariadb/php环境

[root@localhost yum.repos.d]# yum  install nginx  mariadb mariadb-server  php  php-mysql  php-fpm  php-devel  -y
[root@localhost yum.repos.d]# yum  install nginx  mariadb mariadb-server  php  php-mysql  php-fpm  php-devel  -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package 1:nginx-1.16.1-1.el7.ngx.x86_64 already installed and latest version
Package matching 1:mariadb-5.5.44-2.el7.centos.x86_64 already installed. Checking for update.
Package matching 1:mariadb-server-5.5.44-2.el7.centos.x86_64 already installed. Checking for update.
Package matching php-5.4.16-46.1.el7_7.x86_64 already installed. Checking for update.
Package matching php-mysql-5.4.16-46.1.el7_7.x86_64 already installed. Checking for update.
Package matching php-fpm-5.4.16-46.1.el7_7.x86_64 already installed. Checking for update.
Package matching php-devel-5.4.16-46.1.el7_7.x86_64 already installed. Checking for update.
Nothing to do
[root@localhost yum.repos.d]# 

上面这些东西缺一不可
启动nginx和mariadb服务并设置开机自启动

[root@localhost yum.repos.d]# systemctl  start  nginx
[root@localhost yum.repos.d]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@localhost yum.repos.d]# systemctl  start  mariadb
[root@localhost yum.repos.d]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

启动nginx后上网页登录ip查看nginx是否可用

在这里插入图片描述
如上图那样子就OK的~

配置数据库

nginx启动成功我们来配置数据库
上面启动过了就直接初始化
我密码设置为000000

[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

初始化之后进入数据库并创建名为wordpress的数据库

[root@localhost ~]# mysql -u root -p000000
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> Ctrl-C -- exit!
Aborted
[root@localhost ~]# 

退出数据库

配置nginx文件

验证php是否正常解析php文件
打开文件

[root@localhost ~]# vi /etc/nginx/conf.d/default.conf

添加如下:在第10行增加了 index.php
第30-36行取消了注释,并修改了21行和第34行

在这里插入图片描述

在/usr/share/nginx/html目录下新建一个index.php文件

[root@localhost ~]# vi /usr/share/nginx/html/index.php

添加如下

<?php
 phpinfo();
?>

保存退出后,重启nginx

[root@localhost wordpress]# systemctl restart nginx

在物理机上使用浏览器访问该服务器的IP,如192.168.100.10,可以看见服务器上的php版本相关信息,如果看不见,则说明php安装有问题
在这里插入图片描述

安装wordpress

上传wordpress-4.7.3-zh_CN.zip压缩包到/opt目录下
并安装zip压缩软件

[root@localhost ~]# yum install zip unzip  -y

解压文件:[root@localhost opt]# unzip wordpress-4.7.3-zh_CN.zip

当前在opt下目录操作
进入wordpress目录下
将wp-config-sample.php复制一份,并将文件名修改为wp-config.php,然后修改该文件内容

[root@localhost wordpress]# cp wp-config-sample.php wp-config.php
[root@localhost wordpress]# vi wp-config.php

修改如下
在这里插入图片描述

接下来修改nginx文件

[root@localhost wordpress]# vi /etc/nginx/conf.d/default.conf

改为如下
在这里插入图片描述
然后重启nginx服务

[root@localhost wordpress]# systemctl restart nginx

物理机上使用浏览器访问该服务器的IP
在这里插入图片描述

至此搭建wordpress成功

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值