其他分享
首页 > 其他分享> > 分离式部署LNMP架构并实现项⽬上线 -Author: bavdu -Email: bavduer@

分离式部署LNMP架构并实现项⽬上线 -Author: bavdu -Email: bavduer@

作者:互联网

分离式部署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 php￾mbstring 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地址!

标签:Author,分离式,share,nginx,html,wordpress,usr,bavdu,php
来源: https://blog.51cto.com/14173127/2353156