lnmp架构mysql分离_分离式部署LNMP架构并实现项目上线

/nginx配置/

$ hostnamectl set-hostname nginx_server

$ vim /etc/yum.repos.d/nginx.repo

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/$basearch

gpgcheck=0

enabled=1

$ yum -y install nginx

$ vim /etc/nginx/conf.d/default.conf

server {

listen 80;

server_name localhost;

location / {

root /usr/share/nginx/html;

index index.php index.html index.htm;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}

location ~ .php$ {

root /usr/share/nginx/html;

fastcgi_pass 192.168.161.130:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

$ systemctl start nginx

/php及nfs配置/

/mairadb配置/

$ systemctl enable nginx

$ rm -rf /usr/share/nginx/html/$ vim /etc/fstab

192.168.161.130:/usr/share/nginx/html /usr/share/nginx/html nfs

defaults 0 0

$ id nginx

uid=998(nginx) gid=996(nginx) group=nginx(996)

$ groupadd -g 996 nginx

$ useradd -u 998 -g 996 nginx

$ yum -y install php php-gd php-xml php-devel php-fpm php-mysql phpmbstring php-mcrypt

$ vim /etc/php-fpm.d/www/conf

listen = 192.168.161.130:9000 --第⼀处

listen.allowed_clients = 192.168.161.129 --第⼆处

user = nginx --第三处

group = nginx

$ systemctl restart php-fpm

$ yum -y install nfs-utils

$ vim /etc/exports

/usr/share/nginx/html 192.168.161.0/24(rw,sync)

$ mkdir -p /usr/share/nginx/html

$ systemctl start nfs

$ systemctl enable nfs

$ yum -y install mariadb-server mariadb

$ mysqladmin -uroot -p password "123456"

Enter password:

$ mysql -uroot -p123456

[MariaDB(none)]> create database wordpress;

[MariaDB(none)]> grant all privileges on wordpress. to

'nginx'@'192.168.161.130' identified by "123456";

[MariaDB(none)]> exit

/整合/

nginx$ mount -a

phpnfs$ wget https://wordpress.org/latest.tar.gz

phpnfs$ tar xf latest.tar.gz

phpnfs$ mv wordpress/wp-config-sample.php wordpress/wp-config.php

phpnfs$ vim wordpress/wp-config.php

/The name of the database for WordPress */

define('DB_NAME', 'wordpress');

/*MySQL database username/

define('DB_USER', 'nginx');

/ MySQL database password */

define('DB_PASSWORD', '123456');

/*MySQL hostname/

define('DB_HOST', '192.168.161.131');

phpnfs$ cp -rf wordpress/* /usr/share/nginx/html/

打开浏览器访问nginx_server的IP地址!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值