LNMP架構之搭建wordpress博客網站

系統環境版本php

[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軟件html

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.confmysql

\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'    --- 設置用戶密碼linux

/application/mysql/bin/mysql -u root -p123                  --- 登錄nginx

Nginx部署

更加詳細的Nginx講解請看: http://www.cnblogs.com/lyq863987322/p/8111347.htmlweb

安裝依賴

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的詳解sql

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以後,系統已經自帶此軟件功能,能夠不進行安裝centos

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源獲取app

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文件解析

 

 

完成了。這就搭建完成了一個簡單的博客網站,。哪裏不懂能夠私信我。

相關文章
相關標籤/搜索