温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

centos7.3搭建LNMP并部署wordpress站点

发布时间:2020-07-03 17:25:15 来源:网络 阅读:2205 作者:PowerMichael 栏目:数据库

centos7.3搭建LNMP并部署wordpress站点

一、拓扑图   

centos7.3搭建LNMP并部署wordpress站点

二、准备工作:

    1.三台独立主机(虚拟机)

        nginx:10.0.0.11

        php-fpm:10.0.0.2

        mariadb:10.0.0.13

        准备好yum环境(推荐阿里云yum源,请百度搜索)

    2.相关的软件包准备

      10.0.0.11(nginx)

         yum install nginx -y

      10.0.0.2(php-fpm)

         yum install php-fpm php-mysql  php-mbstring php-mcrypt php-xcache -y

      10.0.0.13(mariadb)

         yum install mariadb-server -y

三、搭建步骤

1.nginx主机操作

    1.安装

yum install nginx -y

    2.配置nginx支持反向代理php-fpm

vi /etc/nginx/conf.d/huwho.conf
    server {
        listen 80;
        server_name www.huwho.com;    #web站点域名
        index index.php index.html index.htm;
        #定义一个nginx的web站点,放置web静态资源
        location / {
        root /web/www;
        index index.html index.htm index.php;
        }
        #定义一个web状态页
        location /status {
        stub_status;
        }
        #pass the PHP scripts to FastCGI server listening on 10.0.0.2:9000
        #反向代理php,放置web动态资源
        location ~* \.php$ {
        root /web/www/php;                #php的站点根目录
        fastcgi_pass 10.0.0.2:9000;        #fastcgi的地址
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /web/www/php/$fastcgi_script_name;
        include fastcgi_params;
        }
    }

    3.创建相应的目录

mkdir /web/www/ -pv 
echo nginx web test >> /web/www/

    4.启动nginx服务并测试

systemctl start nginx

centos7.3搭建LNMP并部署wordpress站点


2.php-fpm主机操作

    1.安装

yum install php-fpm php-mysql  php-mbstring php-mcrypt php-xcache -y

    2.php-fpm配置文件修改

    修改图中三处位置

vi /etc/php-fpm.d/www.conf

centos7.3搭建LNMP并部署wordpress站点

centos7.3搭建LNMP并部署wordpress站点

    3.启动php-fpm服务

systemctl start php-fpm
[root@localhost ~]# ss -tln
State       Recv-Q Send-Q                                      Local Address:Port                                                     Peer Address:Port              
LISTEN      0      128                                                     *:111                                                                 *:*                  
LISTEN      0      5                                           192.168.122.1:53                                                                  *:*                  
LISTEN      0      128                                                     *:22                                                                  *:*                  
LISTEN      0      128                                             127.0.0.1:631                                                                 *:*                  
LISTEN      0      100                                             127.0.0.1:25                                                                  *:*                  
LISTEN      0      128                                              10.0.0.2:9000                                                                *:*                  
LISTEN      0      128                                                    :::111                                                                :::*                  
LISTEN      0      128                                                    :::22                                                                 :::*                  
LISTEN      0      128                                                   ::1:631                                                                :::*                  
LISTEN      0      100                                                   ::1:25                                                                 :::*

    4.创建动态资源目录,以及一个index.php文件做测试

mkdir /web/www/php -pv
cd /web/www/php
vi index.php
<h2>welcome to www.huwho.com website.</h2>
<?php
$conn=mysql_connect('10.0.0.13','jerry','123456');
if($conn)
echo "It's ok";
else
echo "bad";
phpinfo();
?>

    centos7.3搭建LNMP并部署wordpress站点

3.mysql主机操作

    1.安装

yum install mariadb-server -y

    2.mysql配置文件修改

vi /etc/my.cnf.d/server.cnf 
# this is only for the mysqld standalone daemon
[mysqld]
skip_name_resolve=ON
innodb_file_per_table=ON

    3.安全加固

mysql_secure_installation

    4.建立一个用户以及数据库

         grant all on wordpress.* to 'jerry'@'10.0.%.%' identified by '123456';

4.安装phpMyAddmin数据库管理工具(php-fpm主机中操作)

    1.下载phpMyAdmin-4.0.10.20-all-languages.tar.gz     

         下载地址https://www.phpmyadmin.net/

    2.解压

        tar -xf phpMyAdmin-4.0.10.20-all-languages.tar.gz

    3.创建软链接(因为名字太长)

        ln -sv phpMyAdmin-4.0.10.20-all-languages.tar.gz pma

    4.更改名字

    cd pma
    cp config.sample.inc.php config.inc.php

    5.编辑配置文件  

    修改图中两处信息

     第一处为随机加入字符,加密作用

     第二处为加入数据库ip地址

vi config.inc.php

centos7.3搭建LNMP并部署wordpress站点   

    6.测试  

centos7.3搭建LNMP并部署wordpress站点  

5.安装wordpress

    1.准备工作

     下载wordpress(https://wordpress.org/download/)

     nginx主机以及php主机都要安装wordpress以及进行下面的操作。解压文件分别放在对应的站点目录中。

     nginx站点目录:/web/www php-fpm站点目录:/web/www/php

    2.解压wordpress

tar  -xvf wordpress-4.7.4-zh_CN.tar.gz

    3.修改配置文件

      修改图中四处信息,分别为:数据库名称,用户名,密码,以及数据库主机ip地址   

cd wordpress/
cp wp-config-sample.php wp-config.php 
vi wp-config.php

centos7.3搭建LNMP并部署wordpress站点

    4.测试页面

centos7.3搭建LNMP并部署wordpress站点

centos7.3搭建LNMP并部署wordpress站点


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI