Azure开机面板搭建教程

安装 lnmp

cd /root
wget "http://soft.vpser.net/lnmp/lnmp1.9beta.tar.gz"
tar -zxvf lnmp1.9beta.tar.gz
rm lnmp1.9beta.tar.gz
cd lnmp1.9
./install.sh

运行要求

  • php7.2.5+
  • mysql / mariadb

注意事项

  • 需要启用 InnoDB 引擎
  • 暂不支持 php8

配置环境

启用被禁用的函数

sed -i 's/,system//g' /usr/local/php/etc/php.ini
sed -i 's/,proc_open//g' /usr/local/php/etc/php.ini
sed -i 's/,proc_get_status//g' /usr/local/php/etc/php.ini

关闭防跨站

sed -i 's/^fastcgi_param PHP_ADMIN_VALUE/#fastcgi_param PHP_ADMIN_VALUE/g' /usr/local/nginx/conf/fastcgi.conf

重启 lnmp

lnmp restart

添加虚拟主机

[email protected]:~# lnmp vhost add
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Please enter domain(example: www.lnmp.org): azpanel.net
 Your domain: azpanel.net
Enter more domain name(example: lnmp.org sub.lnmp.org): 
 domain list: azpanel.net 
Please enter the directory for the domain: azpanel.net
Default directory: /home/wwwroot/azpanel.net: /home/wwwroot/azpanel
Virtual Host Directory: /home/wwwroot/azpanel
Allow Rewrite rule? (y/n) y
Please enter the rewrite of programme, 
wordpress,discuzx,typecho,thinkphp,laravel,codeigniter,yii2 rewrite was exist.
(Default rewrite: other): thinkphp
You choose rewrite: thinkphp
Enable PHP Pathinfo? (y/n) 
Disable pathinfo.
Allow access log? (y/n) y
Enter access log filename(Default:azpanel.net.log): 
You access log filename: azpanel.net.log
Create database and MySQL user with same name (y/n) n
Add SSL Certificate (y/n) y
1: Use your own SSL Certificate and Key
2: Use Let's Encrypt to create SSL Certificate and Key
3: Use BuyPass to create SSL Certificate and Key
4: Use ZeroSSL to create SSL Certificate and Key
Enter 1, 2, 3 or 4: 3
Please enter your email address: [email protected]
Email address [email protected] is valid.

Press any key to start create virtul host...

这里挑重点说

  • 询问是否添加 rewrite 时输入 y,然后输入 thinkphp
  • 询问是否添加 SSL 时,建议添加并选择第三个(BuyPass),证书有效期 180 天

编辑 nginx 配置

主要是以下三点

  • 强制 https
  • 修改网站目录,在原先的网站目录后加上 /public
  • 确认存在 include rewrite/thinkphp.conf;

配置文件路径在 /usr/local/nginx/conf/vhost/azpanel.net.conf ,配置文件模板

server
    {
        listen 80;
        server_name azpanel.net ;
        return 301 https://$server_name$request_uri;
    }

server
    {
        listen 443 ssl http2;
        #listen [::]:443 ssl http2;
        server_name azpanel.net ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/azpanel/public;

        ssl_certificate /usr/local/nginx/conf/ssl/azpanel.net/fullchain.cer;
        ssl_certificate_key /usr/local/nginx/conf/ssl/azpanel.net/azpanel.net.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
        ssl_session_cache builtin:1000 shared:SSL:10m;
        # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
        ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

        include rewrite/thinkphp.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/azpanel.net.log;
    }

重新加载配置

lnmp nginx reload

配置网站

本文以 /home/wwwroot/azpanel 目录作为演示

cd /home/wwwroot/azpanel
chattr -i .user.ini
rm .user.ini
git clone https://github.com/a9086/azpanel.git .
chmod 755 -R *
chown www -R *
composer install

配置数据库

  • 创建数据库 azpanel
  • 导入 database/azure.sql
  • 导入 database/config.sql

你可以使用 phpmyadmin 来创建和导入数据库,教程将演示在命令行下创建和导入

[email protected]:/home/wwwroot/azpanel# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database azpanel;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> use azpanel;
Database changed
MariaDB [azpanel]> source /home/wwwroot/azpanel/database/azure.sql;
...
MariaDB [azpanel]> source /home/wwwroot/azpanel/database/config.sql;
Query OK, 12 rows affected (0.00 sec)
Records: 12  Duplicates: 0  Warnings: 0

MariaDB [azpanel]> Bye
[email protected]:/home/wwwroot/azpanel# 

最后按 ctrl + d 退出

配置参数

复制配置文件模板

cp .example.env .env

编辑配置文件

vim .env

参数说明

如无必要,生产环境强烈建议更改为 false

APP_DEBUG = true

名称可以自定义

APP_NAME = Azure

配置数据库名称,用户和密码

[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = azpanel
USERNAME = root
PASSWORD = dbpasswd
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true

其他略

创建管理员

执行

[email protected]:/home/wwwroot/azpanel# php think createAdmin --email [email protected] --passwd loginpasswd
An administrator account has been created.

如果数据库配置错误,会这样

[think\db\exception\PDOException]                                                      
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

添加定时任务

此任务将统计所有虚拟机在昨日的流量用量

0 0 * * * php /home/wwwroot/azpanel/think tools --action statisticsTraffic

给TA买糖
共{{data.count}}人
人已赞赏
学无止境

甲骨文一键开ARM脚本并推送至TG

2022-2-25 11:34:52

学无止境实用工具

Xrayr安装教程

2022-3-17 16:16:29

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索