本文共 2214 字,大约阅读时间需要 7 分钟。
分离式部署LNMP架构并实现项目上线
/ nginx配置 /
$ hostnamectl set-hostname nginx_server$ vim /etc/yum.repos.d/nginx.repo[nginx]name=nginx repobaseurl=gpgcheck=0enabled=1$ yum -y install nginx$ vim /etc/nginx/conf.d/default.confserver { 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/fstab192.168.161.130:/usr/share/nginx/html /usr/share/nginx/html nfsdefaults 0 0$ id nginxuid=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/conflisten = 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 -aphpnfs$ wget phpnfs$ tar xf latest.tar.gzphpnfs$ mv wordpress/wp-config-sample.php wordpress/wp-config.phpphpnfs$ 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地址!转载于:https://blog.51cto.com/14173127/2353156