Nginx--LNMP 應用部署
- 一、LNMP 部署
- 二、測驗
- 三、應用部署
本環境是基于 Centos 7.8 系統構建Nginx學習環境
具體構建,請參考 Nginx-1.18.0 環境部署
Nginx作為一款非常優秀的Web服務器,同樣支持動態站點的部署,和Apache一樣,也可以部署LNMP,接下來我將相信介紹,
一、LNMP 部署
安裝軟體
[root@node01 ~]# yum install mariadb-server php php-mysql php-gd php-fpm -y
啟動資料庫
[root@node01 ~]# vim /etc/my.cnf
[mysqld]
character-set-server=utf8
[root@node01 ~]# systemctl enable --now mariadb
[root@node01 ~]# mysqladmin -uroot password '123'
修改Nginx服務組態檔
[root@node01 ~]# vim /etc/nginx/conf.d/host.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
修改php組態檔
[root@node01 ~]# vim /etc/php.ini
cgi.fix_pathinfo=0
date.timezone = 'Asia/shanghai'
啟動服務
[root@node01 ~]# systemctl enable --now php-fpm
[root@node01 ~]# systemctl restart nginx mariadb
[root@node01 ~]# netstat -lnutp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2658/nginx: master
[root@node01 ~]# netstat -lnutp | grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2879/mysqld
[root@node01 ~]# netstat -lnutp | grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2638/php-fpm: maste
二、測驗
Nginx和php協調作業
[root@node01 ~]# echo "<?php phpinfo(); ?>" >/usr/share/nginx/html/test.php

mysql和php協調作業

三、應用部署
[root@node01 ~]# cd /usr/share/nginx/html/
[root@node01 html]# ll Discuz_X3.2_SC_UTF8.zip
-rw-r--r-- 1 root root 12486773 Sep 13 2017 Discuz_X3.2_SC_UTF8.zip
[root@node01 html]# unzip Discuz_X3.2_SC_UTF8.zip
[root@node01]# vim /etc/nginx/conf.d/host.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[root@node01 html]# systemctl restart nginx
瀏覽器訪問:http://192.168.5.11/upload/

同意安裝

修改權限
[root@node01 html]# cd upload/
[root@node01 upload]# chmod -R a+w config/ data/ uc_*
重繪,單機下一步

創建資料庫、授權用戶
[root@node01 ~]# mysql -uroot -p123
MariaDB [(none)]> create database ultrax;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on ultrax.* to wan@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> \q
Bye
[root@node01 ~]#

單機下一步,安裝

安裝完成,登錄論壇

進入管理后臺
[root@node01 upload]# mv install/index.php install/index.php.bak


轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/263373.html
標籤:其他
