执行命令
cat /etc/centos-release
执行结果
# CentOS Linux release 7.6.1810 (Core)
timedatectl list-timezones
sudo timedatectl set-timezone 'Asia/Shanghai'
date 命令查看时区
date
sudo yum update -y
若执行失败 可参考网站(https://mirrors.tuna.tsinghua.edu.cn/help/centos/)
sudo yum install -y curl wget vim git unzip socat bash-completion epel-release
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install -y php72w php72w-cli php72w-fpm php72w-common php72w-mbstring php72w-zip php72w-mysql php72w-sqlite3 php72w-curl php72w-xml php72-gd php72w-intl
要显示在模块中编译的PHP,您可以运行:
php -m
运行结果
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
检查PHP版本:
php --version
运行结果
# PHP 7.2.14 (cli) (built: Jan 12 2019 12:47:33) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
# with Zend OPcache v7.2.14, Copyright (c) 1999-2018, by Zend Technologies
sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service
继续下一步,即数据库安装和设置
sudo yum install -y mariadb-server
检查数据库版本
mysql --version
运行结果
# mysql Ver 15.1 Distrib 5.5.60-MariaDB, for Linux (x86_64) using readline 5.1
如果是远程环境,不需要设置服务启动和密码(进行2,3步骤)
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
sudo mysql_secure_installation
回答每个问题:
Would you like to setup VALIDATE PASSWORD plugin? N
New password: your_secure_password
Re-enter new password: your_secure_password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
以root用户身份连接到 mysql shell:
sudo mysql -u root -p
# Enter password
为Bolt CMS 创建一个空的 MariaDB 数据库和用户并记住凭据:
MariaDB> CREATE DATABASE dbname;
MariaDB> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
MariaDB> FLUSH PRIVILEGES;
退出 MariaDB:
MariaDB> exit
替换,并用您自己的名字。 dbname username password
nginx 安装参考文档 http://nginx.org/en/linux_packages.html#RHEL-CentOS
sudo yum install yum-utils
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
安装nginx
sudo yum install nginx
检查nginx的版本
nginx -v
运行结果
# nginx version: nginx/1.12.2
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
sudo vim /etc/nginx/conf.d/pagekit.conf
并使用以下配置填充文件:
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
listen [::]:80;
listen 80;
# 配置自己的域名
server_name example.com;
index index.php index.html;
#配置项目目录
root /var/www/pagekit;
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php; include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
如果是yii框架,参考网站 https://www.yiichina.com/doc/guide/2.0/start-installation
检查 NGINX 配置是否存在语法错误:
sudo nginx -t
sudo systemctl reload nginx.service
参考网站 https://www.howtoforge.com/how-to-install-pagekit-cms-on-centos-7/