Centos 7.5 安装LNMP平台

一台Centos 7.5虚拟机

安装软件包

[[email protected] /]# yum install -y epel-*

Centos 7.5 编译安装搭建wordpress

[[email protected] /]# yum install -y nginx mariadb-server php php-mysql \

> php-fpm  \php-xml php-pecl-zip php-json php-devel wget vim

Centos 7.5 编译安装搭建wordpress

 

配置nginx支持PHP

  1. 创建nginx的web主目录
  2. [[email protected] /]# mkdir /var/wwwroot
  3. [[email protected] /]# cd /var/wwwroot/
  4. [[email protected] wwwroot]# echo -e hello_world >> index.html
  5. [[email protected] wwwroot]# echo -e "<?php phpinfo(); ?>" >> info.php
  6. [[email protected] wwwroot]# ls

Centos 7.5 编译安装搭建wordpress

 

2、编辑nginx的配置文件

[[email protected] /]# vim /etc/nginx/nginx.conf

Centos 7.5 编译安装搭建wordpress

3、修改nginx主目录和索引

将http下的server下的root的值修改为/var/wwwroot

在http下的server下添加index index.php index.html index.htm

Centos 7.5 编译安装搭建wordpress

4.在http下的server区块加入以下内容

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

5.启动nginx和php-fpm

[[email protected] ~]# systemctl start nginx php-fpm

[[email protected] ~]# systemctl enable nginx php-fpm

[[email protected] ~]# systemctl status nginx php-fpm

 

Centos 7.5 编译安装搭建wordpress

6.关闭防火墙

[[email protected] ~]# setenforce 0

[[email protected] ~]# systemctl stop firewalld

[[email protected] ~]# systemctl disable firewalld

7.在宿主机访问nginx

访问 http://[centos_ip]/info.php

Centos 7.5 编译安装搭建wordpress

配置MySQL

  1. 启动MySQL

[[email protected] /]# systemctl start mariadb

[[email protected] /]# systemctl enable mariadb

  1. 输入以下命令,配置MySQL

[[email protected] /]# mysql_secure_installation

 

  1. 提示 Enter current password for root (enter for none):

 

敲击回车

4.提示Set root password? [Y/n]

按Y,随后设置密码

密码设置:123(生产环境尽量不要使用弱口令密码)

 

5.提示Remove anonymous users?

意思是否删除匿名用户

 

6.提示Disallow root login remotely?

意思是远程禁止root登录吗?

 

7.提示Remove test database and access to it?

意思为删除测试数据库吗?

 

  1. 提示Reload privilege tables now?

意思是现在重新加载特权表吗?

9.登录mysql数据库

[[email protected] /]# mysql -u root -p

 

MariaDB [(none)]> show databases;

 

下载WorldPress测试LNMP环境

 

  1. 下载WordPress

[[email protected] ~]# cd /var/www/root/

[[email protected] wwwroot]# rm -rf index.html

[[email protected] wwwroot]# rm -rf info.php

[[email protected] wwwroot]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz

Centos 7.5 编译安装搭建wordpress

[[email protected] wwwroot]# tar -zxvf wordpress-4.9.4-zh_CN.tar.gz

[[email protected] wwwroot]# cd wordpress/

[[email protected] /]# cp -r /var/wwwroot/wordpress/* /var/wwwroot/

[[email protected] /]# cd /var/wwwroot/

[[email protected] wwwroot]# ll

Centos 7.5 编译安装搭建wordpress

  1. 登录mysql创建数据库

[[email protected] wwwroot]# mysql -u root -p

#创建一个wordperss数据库

MariaDB [(none)]> CREATE DATABASE wordpress;

在宿主机访问nginx服务器

访问http://[centos_ip]/

按提示安装即可

Centos 7.5 编译安装搭建wordpress

 

 

 

相关文章: