第二十周

1、編譯安裝LNMP,并安裝wordpress

node-1:192.168.10.3:編譯安裝nginx,php-fpm

node-2:192.168.10.4:編譯安裝mariadb-10.0.38

node-2編譯安裝mariadb-10.0.38:

安裝相關(guān)依賴包

yum install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel

準(zhǔn)備用戶和數(shù)據(jù)目錄

[root@node-2 ~]# useradd -r -s /sbin/nologin -d /data/mysql/ mysql

[root@node-2 ~]# ls /data/mysql/

[root@node-2 ~]# chown mysql.mysql /data/mysql

[root@node-2 ~]# ll -d /data/mysql

drwxr-xr-x 2 mysql mysql 6 May? 7 08:43 /data/mysql

解壓安裝包:

[root@node-2 ~]# tar xvf mariadb-10.0.38.tar.gz

cmake 編譯安裝

cd mariadb-10.2.18/

cmake . \

-DCMAKE_INSTALL_PREFIX=/app/mysql \

-DMYSQL_DATADIR=/data/mysql/ \

-DSYSCONFDIR=/etc/ \

-DMYSQL_USER=mysql \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITHOUT_MROONGA_STORAGE_ENGINE=1 \

-DWITH_DEBUG=0 \

-DWITH_READLINE=1 \

-DWITH_SSL=system \

-DWITH_ZLIB=system \

-DWITH_LIBWRAP=0 \

-DENABLED_LOCAL_INFILE=1 \

-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

make -j 4&& make install

提示:如果出錯,執(zhí)行rm -f CMakeCache.txt

準(zhǔn)備環(huán)境變量

echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh

. /etc/profile.d/mysql.sh

生成數(shù)據(jù)庫文件

cd /app/mysql/

scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql

準(zhǔn)備配置文件

cp /app/mysql/support-files/my-huge.cnf /etc/my.cnf

準(zhǔn)備啟動腳本

cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld

啟動服務(wù)

chkconfig --add mysqld ;service mysqld start

創(chuàng)建數(shù)據(jù)庫并授權(quán)

[root@node-2 ~]# mysql

Welcome to the MariaDB monitor.? Commands end with ; or \g.

Your MariaDB connection id is 6

Server version: 10.0.38-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wordpress;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on wordpress.* to "wordpress"@"192.168.10.%" idenfied by "123456";

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'idenfied by "123456"' at line 1

MariaDB [(none)]> grant all privileges on wordpress.* to "wordpress"@"192.168.10.%" identified by "123456";

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show databases;

+--------------------+

| Database? ? ? ? ? |

+--------------------+

| information_schema |

| mysql? ? ? ? ? ? ? |

| performance_schema |

| test? ? ? ? ? ? ? |

| wordpress? ? ? ? ? |

+--------------------+

5 rows in set (0.05 sec)

編譯安裝php7.2.15:

yum install libxml2-devel bzip2-devel libmcrypt-devel (epel)

tar xvf php-7.3.5.tar.bz2

cd php-7.3.5/

./configure --prefix=/app/php \

--enable-mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-openssl \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--with-config-file-path=/etc \

--with-config-file-scan-dir=/etc/php.d \

--enable-mbstring \

--enable-xml \

--enable-sockets \

--enable-fpm \

--enable-maintainer-zts \

--disable-fileinfo

make && make install

準(zhǔn)備PHP配置文件:

? ? cp php.ini-production /etc/php.ini?

????cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

????chmod +x /etc/init.d/php-fpm

????chkconfig --add php-fpm

????chkconfig php-fpm on

????cd /app/php/etc

????cp php-fpm.conf.default php-fpm.conf

????cp php-fpm.d/www.conf.default php-fpm.d/www.conf

????service php-fpm start

修改PHP配置文件:

[root@node-1 php-fpm.d]# grep -v ";" www.conf |grep -v "^$"

[www]

user = www

group = www

listen = 127.0.0.1:9000

pm = dynamic

pm.max_children = 50

pm.start_servers = 30

pm.min_spare_servers = 30

pm.max_spare_servers = 35

pm.status_path = /pm_status

ping.path = /ping

ping.response = pong

access.log = log/$pool.access.log

slowlog = log/$pool.log.slow

[root@node-1 php-fpm.d]# mkdir /app/php/log? ? ? ? 創(chuàng)建日志文件

[root@node-1 php-fpm.d]# /app/php/sbin/php-fpm -t? ? ? ? 驗證php-fpm

[07-May-2020 12:40:33] NOTICE: configuration file /app/php/etc/php-fpm.conf test is successful

編譯安裝nginx:

? ?useradd -r -s /sbin/nologin nginx? ? ? ? 創(chuàng)建nginx用戶

./configure --prefix=/apps/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_dav_module --with-http_stub_status_module --with-threads --with-file-aio

make -j 4 && make install

準(zhǔn)備環(huán)境變量

echo 'PATH=/apps/nginx/sbin/:$PATH' > /etc/profile.d/nginx.sh

. /etc/profile.d/nginx.sh

準(zhǔn)備PHP測試頁面:

[root@node-1 nginx-1.12.2]# mkdir /data/nginx/wordpress -p

[root@node-1 nginx-1.12.2]# vim /data/nginx/wordpress/index.php

[root@node-1 nginx-1.12.2]# vim /data/nginx/wordpress/index.php

<?php

? ? ? ? phpinfo();

?>

配置nginx

server {

? ? ? ? listen? ? ? 80;

? ? ? ? server_name? www.magedu.net;

? ? ? ? #charset koi8-r;

? ? ? ? #access_log? logs/host.access.log? main;

? ? ? ? location / {

? ? ? ? ? ? root? /data/nginx/wordpress;

? ? ? ? ? ? index? index.php index.html index.htm;

? ? ? ? ? ? ? ? if ($http_user_agent ~ "ApacheBench|WebBench|TurnitinBot|Sogou web spider|GridServer") {

? ? ? ? ? ? ? ? return 403;

? ? ? ? ? ? ? ? }

location ~ \.php$ {

? ? ? ? ? ? proxy_pass? http://127.0.0.1;

? ? ? ? ? ? ? ? root /data/nginx/wordpress;

? ? ? ? ? ? ? ? fastcgi_pass 127.0.0.1:9000;

? ? ? ? ? ? ? ? fastcgi_index index.php;

? ? ? ? ? ? ? ? fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

? ? ? ? ? ? ? ? include fastcgi_params;

測試PHP


部署wordpress:

[root@node-1 ~]# cd /data/nginx/wordpress/

[root@node-1 ~]# tar xvf wordpress-5.0-zh_CN.tar.gz

[root@node-1 wordpress]# mv index.php /opt

[root@node-1 wordpress]# mv wordpress/* .

[root@node-1 wordpress]# mv wordpress-5.0-zh_CN.tar.gz /root? ? ? ? ?

[root@node-1 wordpress]# cp wp-config-sample.php wp-config.php? ? ? ? ?

[root@node-1 wordpress]# vim wp-config.php

define('DB_NAME', 'wordpress');

/** MySQL數(shù)據(jù)庫用戶名 */

define('DB_USER', 'wordpress');

/** MySQL數(shù)據(jù)庫密碼 */

define('DB_PASSWORD', '123456');

/** MySQL主機(jī) */

define('DB_HOST', '192.168.10.4');

[root@node-1 wordpress]# chown www.www /data/nginx/wordpress/ /apps/nginx/ -R

[root@node-1 wordpress]# /apps/nginx/sbin/nginx -s reload


2、配置虛擬主機(jī),www.x.com域名實現(xiàn)首頁訪問,admin.x.com域名實現(xiàn)wordpress的后臺訪問。

server {

? ? ? ? listen 80;

? ? ? ? server_name www.x.com;

? ? ? ? location / {

? ? ? ? ? ? root? /data/nginx/wordpress;

? ? ? ? ? ? index? index.php index.html index.htm;

? ? ? ? ? ? ? ? }

? ? ? ? location ~ \.php$ {

? ? ? ? ? ? ? ? ? ? ? ? root /data/nginx/wordpress;

? ? ? ? ? ? ? ? ? ? ? ? fastcgi_pass 127.0.0.1:9000;

? ? ? ? ? ? ? ? ? ? ? ? fastcgi_index index.php;

? ? ? ? ? ? ? ? ? ? ? ? fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

? ? ? ? ? ? ? ? ? ? ? ? include fastcgi_params;

? ? ? ? ? ? ? ? ? ? ? ? }

}

server {

? ? ? ? listen 80;

? ? ? ? server_name admin.x.com;

? ? ? ? location / {

? ? ? ? ? ? ? ? rewrite / http://www.x.com/wp-login.php;

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容