分离式部署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地址!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。