Centos7部署SSPanel UIM前端教程
部署LNMP
环境
Linux
:Centos7
Nginx
:1.20
MriaDB
:10.6
PHP
:8.1
一、关闭防火墙和SElinux
# systemctl stop firewalld
# systemctl disable firewalld
# systemctl mask firewalld
# vim /etc/selinux/config
SELINUX=disabled
# setenforce 0
二、配置Yum源和Epel源(国内源)
如果没有
wget
命令,请安装yum install -y wget
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
# yum clean all && yum makecache fast
三、安装Nginx(自己编译)
编译安装Nginx教程【Linux基础服务教程】Nginx的安装和介绍
A.下载Nginx安装包
# wget http://nginx.org/download/nginx-1.20.2.tar.gz
B.安装必要的依赖
# yum install -y gcc openssl-devel pcre-devel zlib-devel
C.创建Nginx临时文件目录
# mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}
D.创建Nginx用户
# useradd -s /sbin/nologin nginx
E.解压Nginx
# tar xf nginx-1.20.2.tar.gz
# cd nginx-1.20.2/
F.编译并安装
# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-stream --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-file-aio --with-http_secure_link_module --with-threads --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi/ --http-scgi-temp-path=/var/tmp/nginx/scgi/
# make && make install
G.默认路径
/usr/local/nginx
暂时不要启动
Nginx
四、安装PHP8.1
A.配置epel源
# yum install -y epel-release
B.配置REMI
# yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
C.安装yum-utils
# yum install -y yum-utils
D.安装PHP8.1
# yum-config-manager --enable remi-php81
# yum install -y php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis
E.查询PHP版本
# php -version
PHP 8.1.18 (cli) (built: Apr 11 2023 16:47:45) (NTS gcc x86_64)
Copyright © The PHP Group
Zend Engine v4.1.18, Copyright © Zend Technologies
F.启动PHP和Nginx
如果想
Nginx
开机自启动,请把启动命令加入rc.local
文件内/etc/rc.d/rc.local
# systemctl enable --now php-fpm
# /usr/local/nginx/sbin/nginx
G.修改PHP用户
# vim /etc/php-fpm.d/www.conf
user = nginx #把默认的apache改成nginx
group = nginx
H.重启PHP
# systemctl restart php-fpm
I.可以查看端口状态,是否成功启动
# netstat -tunlp | grep -e "nginx" -e "php"
如果没有netstat命令,请安装
yum install -y net-tools
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6852/nginx: master
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 6845/php-fpm: master
五、安装MariaDB10.11
1.安装MariaDB
A.配置yum源
# vim /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.11/centos7-amd64
gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=1
B.安装MariaDB
# yum install -y MariaDB-server MariaDB-client
C.修改配置文件(可选的)
# vim /etc/my.cnf.d/server.cnf
[mysqld]
#配置文件不完整,仅展示添加部分
server_id=10 #指定ID
log_bin=master #开启二进制日志
sql_mode=NO_ENGINE_SUBSTITUTION #禁用严格模式
C.设置开机自启动
# systemctl enable --now mariadb
D.初始化设置MariaDB
# mariadb-secure-installation
Switch to unix_socket authentication [Y/n] root用户是否开启认证和unix_socket认证,y
Enter current password for root (enter for none): 输入当前的root密码(默认空),直接回车
Set root password? [Y/n] 设置新密码,y
Remove anonymous users? [Y/n] 移除匿名用户,y
Disallow root login remotely? [Y/n] 禁止root用户远程登录,y
Remove test database and access to it? [Y/n] 移除测试数据库,y
Reload privilege tables now? [Y/n] y
E.创建用到的库
# mysql -uroot -p
# CREATE DATABASE sspanel CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
F.创建用户和给予权限
# CREATE USER 'sspanel'@'localhost';
# GRANT ALL PRIVILEGES ON sspanel.* TO 'sspanel'@'localhost' IDENTIFIED BY 'WWW.1.com';
G.刷新用户数据
# FLUSH PRIVILEGES;
H.退出数据库
# exit
六、安装SSPanel UIM
1.配置Nginx
A.创建网页目录
我这里在根目录创建
VPN
目录做演示
# mkdir -p /vpn
A.创建子配置文件目录
# mkdir -p /usr/local/nginx/conf.d
B.创建子配置文件
# vim /usr/local/nginx/conf.d/你设置的网站域名.conf
server {
listen 80;
listen [::]:80;
root /path/to/your/site/public; #你的站点文件路径 + /public
index index.php index.html;
server_name 你设置的网站域名;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php-fpm; #如果检测这里报错,请更换为IP+端口,比如127.0.0.1:9000
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
上面是官方的,下面是我自己改的
server {
listen 80;
listen [::]:80; #这里的IPV6地址根据情况可以不写
server_name vpn.wsjj.top; #域名
if ($scheme = http) { #强制跳转https
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
access_log /var/log/nginx/vpn_access.log main; #指定访问日志
error_log /var/log/nginx/vpn_error.log error; #指定错误日志
server_name vpn.wsjj.top;
ssl_certificate /ssl/cert.pem; #证书路径
ssl_certificate_key /ssl/cert.key; #证书路径
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /vpn/SSPanel-Uim/public; #网页目录
index index.html index.htm index.php;
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
root /vpn/SSPanel-Uim/public; #网页目录
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
}
如果您跟我写的配置文件一样定义的
日志
,那么就需要创建日志需要存放的目录
# mkdir -p /var/log/nginx
C.修改主配置文件
把我们刚刚写好的子配置文件引用到主配置文件内
记住,如果跟我一样,定义了日志,请写到日志的下面!
# vim /usr/local/nginx/conf/nginx.conf
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#如果您写的配置文件跟我一样,请把Nginx官方的日志变量,前面的注释删除,并且把下面的include写到日志变量的下面!
include /usr/local/nginx/conf.d/*.conf;
D.检查配置文件
# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
E.重新加载配置文件
# /usr/local/nginx/sbin/nginx -s reload
2.安装redis
安装redis
# yum install -y redis
修改redis配置文件
# vim /etc/redis.conf
daemonize yes #把no改成yes开启后台模式
启动redis
# systemctl enable --now redis
3.前往网站根目录下载需要的文件
A.前往网站根目录
# cd 你的站点目录
B.安装Git环境
如果提示找不到包,请配置
epel
源!
# yum install -y git
C.克隆项目
# git clone -b dev https://github.com/Anankke/SSPanel-Uim.git
# cd SSPanel-Uim/
# git config core.filemode false
# wget https://getcomposer.org/installer -O composer.phar
如果没有
wget
命令,请安装yum install -y wget
# php composer.phar
# php composer.phar install
D.给予网页目录权限
# chmod -R 755 /你的网页目录
E.修改属主和属组
# chown -R nginx.nginx /你的网页目录
F.修改数据库连接信息
# cp config/.config.example.php config/.config.php
# cp config/appprofile.example.php config/appprofile.php
# vim config/.config.php
$_ENV['baseUrl'] = 'https://vpn.wsjj.top'; //指定站点地址
$_ENV['db_driver'] = 'mysql';
$_ENV['db_host'] = 'localhost'; //如果使用地址连接,则套接字留空即可
$_ENV['db_socket'] = '/var/lib/mysql/mysql.sock'; //本地建议使用套接字连接
$_ENV['db_database'] = 'sspanel'; //数据库名
$_ENV['db_username'] = 'sspanel'; //数据库用户名
$_ENV['db_password'] = 'WWW.1.com'; //用户名对应的密码
$_ENV['db_port'] = '3306'; //端口
#高级
$_ENV['db_charset'] = 'utf8mb4';
$_ENV['db_collation'] = 'utf8mb4_unicode_ci';
$_ENV['db_prefix'] = '';
仅展示修改数据库的地方,其他地方按需修改
G.站点初始化
# php xcat Migration new
# php xcat Tool importAllSettings
# php xcat Tool createAdmin
# php xcat ClientDownload
H.设置计划任务
# crontab -e
/vpn/
为你的网页目录
*/5 * * * * /usr/bin/php /vpn/SSPanel-Uim/xcat Cron
*/1 * * * * /usr/bin/php /vpn/SSPanel-Uim/xcat Job CheckJob
0 */1 * * * /usr/bin/php /vpn/SSPanel-Uim/xcat Job UserJob
0 0 * * * /usr/bin/php -n /vpn/SSPanel-Uim/xcat Job DailyJob
以下是可选的
5 0 * * * /usr/bin/php /vpn/SSPanel-Uim/xcat FinanceMail day
6 0 * * 0 /usr/bin/php /vpn/SSPanel-Uim/xcat FinanceMail week
7 0 1 * * /usr/bin/php /vpn/SSPanel-Uim/xcat FinanceMail month
*/1 * * * * /usr/bin/php /vpn/SSPanel-Uim/xcat DetectGFW