zoukankan      html  css  js  c++  java
  • LNMP架构之搭建wordpress博客网站

    系统环境版本

    [root@db02 ~]# cat /etc/redhat-release 
    CentOS release 6.9 (Final)
    [root@db02 ~]# uname -a
    Linux db02 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

    首先部署mysql数据库

    二进制包方式安装mysql数据库软件

    下载解压mysql软件

    wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
    
    tar xf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
    下载解压

    创建mysql管理用户

    useradd -s /sbin/nologin -M mysql

    给mysql放到一个目录中,设置软连接

    mv mysql-5.6.34-linux-glibc2.5-x86_64/ /application/mysql-5.6.34
    
    ln -s /application/mysql-5.6.34/ /application/mysql
    软连接

    授权mysql数据目录

    chown -R mysql.mysql /application/mysql/data/

    初始化mysql

    /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
    --basedir    --- 指定mysql的程序目录
    --datadir    --- 指定mysql的数据目录
    --user       --- 指定管理用户

    将mysql给/etc/init.d管理

    cp -a /application/mysql/support-files/mysql.server /etc/init.d/mysqld
    需要修改启动文件的mysql路径:
    sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

    设置mysql配置文件

    mysql默认配置文件保存位置: /etc/my.conf

    cp /application/mysql/support-files/my-default.cnf /etc/my.conf

    启动mysql,并设置用户密码

    /etc/init.d/mysqld start      --- 启动

    /application/mysql/bin/mysqladmin -u root password '123'    --- 设置用户密码

    /application/mysql/bin/mysql -u root -p123                  --- 登陆

    Nginx部署

    更加详细的Nginx讲解请看: http://www.cnblogs.com/lyq863987322/p/8111347.html

    安装依赖

    yum install -y pcre-devel openssl-devel

    下载nginx,进行解压

    cd /server/tools/
    
    wget -q http://nginx.org/download/nginx-1.10.2.tar.gz
    
    tar xf nginx-1.10.2.tar.gz
    下载解压

    创建管理用户,初始化程序

    cd nginx-1.10.2
    
    useradd -s /sbin/nologin -M www -u 2222
    
    ./configure --prefix=/application/nginx-1.10.2 --user=www --group=www --with-http_stub_status_module  --with-http_ssl_module
    创建用户,初始化

    编译、编译安装、创建软连接

    make && make install
    
    ln -s /application/nginx-1.10.2 /application/nginx
    编译安装,软连接

    精简化配置文件

    egrep -v "#|^$" /application/nginx/conf/nginx.conf.default >/application/nginx/conf/nginx.conf

    启动nginx

    /application/nginx/sbin/nginx

    这里就能web网页访问,但是没什么东西,具体可以看看我的另一篇Nginx的详解

    PHP部署

    解决依赖关系

    yum install -y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel

    libiconv-devel ---字符集转换库    这个软件需要编译安装

    说明:此软件在centos6.8之后,系统已经自带此软件功能,可以不进行安装

    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
    
    tar xf libiconv-1.14.tar.gz
    
    cd libiconv-1.14
    
    ./configure --prefix=/usr/local/libiconv
    
    make && make install
    libiconv编译过程

    还需要安装三个与数据加密相关的软件 --- 需要epel源获取

    yum -y install libmcrypt-devel mhash mcrypt

    PHP解压

    tar xf php-5.5.32.tar.gz

    初始化

    这里根据不同的需求增加初始化内容

    cd php-5.5.32
    
    ./configure --prefix=/application/php-5.5.32 --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=no --with-mysqli=mysqlnd --with-gettext
    初始化

    编译安装,创建软连接

    make && make install
    
    ln -s /application/php-5.5.32/ /application/php
    编译安装、软连接

    php配置文件

    cp /server/tools/php-5.5.32/php.ini-production /application/php/lib/php.ini
    
    cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf

    启动php服务

    /application/php/sbin/php-fpm

    wordpress博客网站站点部署

    关于wordpress的下载百度一下一大堆,我就省略了

    wordpress解压、移动到站点目录下

    tar xf wordpress-4.7.3-zh_CN.tar.gz
    
    mv wordpress /application/nginx/html/blog/

    修改nginx配置文件

    worker_processes  1;
    events {
        worker_connections  1024;
    }
    http {
        include       mime.types;
        default_type  application/octet-stream;
    sendfile        on;
    client_max_body_size 1024M;
        keepalive_timeout  65;
    server {
            listen       80;
            server_name  blog.zxpo.com;
            location / { 
                root   html/blog/wordpress;
                index  index.php index.html index.htm;
            }   
             location ~* .*.(php|php5)?$ {
                      root html/blog/wordpress;
                      fastcgi_pass  127.0.0.1:9000;
                      fastcgi_index index.php;
                      include fastcgi.conf;
                }     
                
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }   
        }   
    }
    Nginx配置文件

    重新启动Nginx

    [root@webtest tools]# /application/nginx/sbin/nginx -t      --- 检查Nginx配置是否正确
    nginx: the configuration file /application/nginx-1.10.2/conf/nginx.conf syntax is ok
    nginx: configuration file /application/nginx-1.10.2/conf/nginx.conf test is successful
    [root@webtest tools]# /application/nginx/sbin/nginx -s reload    --- 平滑重启nginx
    重启nginx

    站点目录修改属主和属组

    chown -R www.www /application/nginx/html/blog/wordpress/

    登陆数据库创建所需内容

    mysql> create database web03;
    Query OK, 1 row affected (0.00 sec)
    mysql> grant all on web03.* to 'web03'@'172.16.1.0/255.255.255.0' identified by '123'; 
    Query OK, 0 rows affected (0.00 sec)
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    网页登陆配置

    注意主机hosts文件解析

     

    完成了。这就搭建完成了一个简单的博客网站,。哪里不懂可以私信我。

  • 相关阅读:
    202006leetcode刷题记录
    二分查找详解
    并查集
    202005leetcode刷题记录
    基于地震数据的Spark数据处理与分析
    Java日志框架:logback详解
    java 多线程
    Oracle表恢复(truncate)
    关于软件开发,你老板不知道的7件事
    调用oracle 分页存储过程 返回游标数据集
  • 原文地址:https://www.cnblogs.com/lyq863987322/p/8242693.html
Copyright © 2011-2022 走看看