====== 建立 PVE CT-CentOS8 + php7.3 + nginx + MariaDB 樣板 ======
* 建立環境 :
* PVE 6.3-2
* Cores 1 / Memory 512MB / Swap 512MB / Root Disk 8G
* CentOS 8 Template - centos-8-default_20191016_amd64.tar.xz
* 建立 CT 之後, 先進行 [[tech/pve-ct-centos7]]
* 重新開機後登入進行安裝 php7.3 + nginx + MariaDB
dnf -y install epel-release
dnf module reset php
dnf module enable php:7.3
dnf install bash-completion cronie fping git ImageMagick mariadb-server mtr net-snmp net-snmp-utils nginx nmap php-fpm php-cli php-common php-curl php-gd php-json php-mbstring php-process php-snmp php-xml php-zip php-mysqlnd python3 python3-PyMySQL python3-redis python3-memcached python3-pip rrdtool unzip
* 設定 PHP 時區
vi /etc/php.ini
:
date.timezone = Asia/Taipei
:
* 設定 MariaDB
vi /etc/my.cnf.d/mariadb-server.cnf
在 [mysqld] 段落加入
innodb_file_per_table=1
lower_case_table_names=0
systemctl enable mariadb
systemctl restart mariadb
* 建立透過 192.168.11.xxx 網段可登入的 root 帳號, 密碼 xxxxxxxx
mysql -u root
CREATE USER 'root'@'192.168.11.%' IDENTIFIED BY 'xxxxxxxx';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.11.%';
FLUSH PRIVILEGES;
exit
* 設定 php-fpm
* 設定 nginx web Exp. test.ichiayi.com
vi /etc/nginx/conf.d/web.conf
server {
listen 80 default_server;
server_name test.ichiayi.com;
root /var/www/html;
index index.php;
charset utf-8;
gzip on;
gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
如果只要執行一個網站, 就移去 nginx.conf 內的預設的 server 段落
vi /etc/nginx/nginx.conf
:
include /etc/nginx/conf.d/*.conf;
# server {
# listen 80 default_server;
# listen [::]:80 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
:
systemctl enable --now nginx
systemctl enable --now php-fpm