在Centos 8 中部署LNMP环境并安装Wordpress - 开发说
当前位置: 主页 » Centos » 在Centos 8 中部署LNMP环境并安装WordPress

在Centos 8 中部署LNMP环境并安装WordPress

      2019年09月25日   阅读 3,687 次     0 评论   Tags: · ·

Centos 8 已经发布,带来了诸多的新特性,具体请参考:(Centos Linux 8 新功能和评测),包括内核的升级,再也不用手动升级内核开启bbr了(Centos7手动升级最新版内核并开启BBR),而且在部署LNMP环境也精简了不少命令,终于不用在编译安装php,也不用为了开启BBR而升级内核重启服务器了。

1、准备条件,先查看Centos 8 中自带的nginx/php/mariadb的版本,肯定是dnf命令了,更多dnf命令参考:在Centos Linux 8 中使用dnf包管理工具

可以看出在centos8中,自带的nginx-1.14.1,php-7.2.11,mysql-8.0.13,mariadb-10.3.11,基本都是比较新的。

2、部署LNMP环境,命令也简单了很多: dnf install nginx php mariadb-server php-mysqlnd

3、把nginx,php-fpm,mariadb加入到开机启动,并启动nginx,php-fpm,mariadb


###把nginx,php-fpm,mariadb加入到开机启动

[root@localhost ~]# systemctl enable nginx
[root@localhost ~]# systemctl enable php-fpm
[root@localhost ~]# systemctl enable mariadb

###启动nginx,php-fpm,mariadb

[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl start php-fpm
[root@localhost ~]# systemctl start mariadb

###配置文件目录
NGINX配置文件:/etc/nginx/nginx.conf
PHP配置文件:/etc/nginx/default.d/php.conf 和 /etc/nginx/conf.d/php-fpm.conf
MariaDB配置文件:/etc/my.cnf.d/mariadb-server.cnf

4、初始化mariadb并设置root密码


[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] y
 ... Success!

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!

5、创建一个wordpress数据库并设置字符集为utf8,用来存储wordpress的数据库数据


MariaDB [(none)]> create database wordpress charset=utf8;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| wordpress          |
+--------------------+
4 rows in set (0.000 sec)

MariaDB [(none)]> 

6、下载wordpress,解压到 /usr/share/nginx/html


wget https://cn.wordpress.org/latest-zh_CN.tar.gz

tar xf latest-zh_CN.tar.gz
cp -r wordpress /usr/share/nginx/html

7、通过浏览器访问,进行wordpress安装。





至此,Centos Linux 8部署LNMP环境并安装wordpress完成,注意哦:没有修改nginx/php/mariadb的任何配置文件哦。

这里有一点我一脸懵逼233~,在 selinuxdisabled 状态下,当我把 nginx.conf 和 www.conf 文件中的用户和用户组都改为 nobody,并把/usr/share/nginx/html 文件夹的所属组和所有者改为 nobody.nobody,nginx会报 404 错误,不知道怎么回事???

  • 版权声明:本文版权归开发说和原作者所有,未经许可不得转载。文章部分来源于网络仅代表作者看法,如有不同观点,欢迎进行交流。除非注明,文章均由 开发说 整理发布,欢迎转载,转载请带版权。

  • 来源:开发说 ( https://www.kaifashuo.com/ ),提供主机优惠信息深度测评和服务器运维编程技术。
  • 链接:https://www.kaifashuo.com/1441.html
  • 评论(0

    1. 还没有任何评论,你来说两句吧

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用 * 标注