azpanel是一个免费开源的azure api面板。官方给的安装教程有用lnmp和bt面板的,这两种我都不太喜欢,所以写一下手动安装教程。
项目信息 官方安装教程 手动安装 系统要求 理论上配置不要太低的Linux服务器都可以。我是在Ubuntu 20.04 LTS上安装的,本文命令也是基于此。
环境安装 我们需要安装的东西有: ☑️ Nginx 1.17 ☑️ MySQL 5.6 (或者mariadb) ☑️ PHP 7.2.5+
安装PHP和nginx 1 2 apt update && apt upgrade -y apt install php-fpm php-mysql php-curl php-xml nginx -y
验证是否安装成功:
安装MySQL 这里我是采用docker安装,其实直接安装也很方便啦。
安装docker和docker-compose 1 2 curl -fsSL https://get.docker.com | bash apt install docker-compose
1 2 docker -v docker-compose -v
docker-compose启动mysql 先新建文件夹:
1 2 3 mkdir -p /opt/azpanel && cd /opt/azpanel vim /opt/azpanel/docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 version: "3" services: db: image: mysql:oracle ports: - 127.0 .0 .1 :3306:3306 volumes: - ./db/mysql:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: 写你的root密码 MYSQL_DATABASE: azpanel MYSQL_USER: azpanel MYSQL_PASSWORD: 写你的数据库密码 restart: always
再运行:
下载azpanel 下载
1 2 mkdir -p /www/wwwroot/azpanel && mkdir /www/wwwlogs/ && cd /www/wwwroot/azpanel git clone https://github.com/azpanel/azpanel.git ./
修改权限
1 2 3 4 5 6 7 cd /www/wwwroot/azpanelchmod 755 -R *chown -R www-data *cat /etc/php/7.4/fpm/pool.d/www.conf | grep "user = " cat /etc/nginx/nginx.conf | grep "user"
安装Composer Composer 是PHP的一个依赖管理工具。 它能管理你的PHP项目所需要的所有依赖关系。 也就是说,Composer 会将你的PHP项目需要的所有代码库、依赖项从网上全部拉取下来,放到一起进行管理。
参考:How to Install Composer: A Step-By-Step Guide and Best Practices
1 2 3 4 5 cd /www/wwwroot/azpanel php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');" php composer.phar
1 php composer.phar install
安装成功的输出请看附录:点击跳转 继续安装
配置数据库 导入数据库:
1 2 3 cd /opt/azpanel/cp /www/wwwroot/azpanel/database/*.sql /opt/azpanel/db/mysql/azpanel/ docker-compose down && docker-compose up -d
1 2 docker exec -it azpanel_db_1 sh
这里输入你的root 密码,登入数据库。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 sh-4.4 Enter password: (输入你的root密码) Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.29 MySQL Community Server - GPL Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help . Type '\c' to clear the current input statement. mysql>
数据库操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 mysql> use azpanel; Database changed mysql> source /var/lib/mysql/azpanel/azure.sql; Query OK, 0 rows affected (0.01 sec) mysql> source /var/lib/mysql/azpanel/config.sql; Query OK, 12 rows affected (0.01 sec) Records: 12 Duplicates: 0 Warnings: 0 mysql> show tables; +----------------------+ | Tables_in_azpanel | +----------------------+ | ann | | azure | | azure_server | | azure_server_traffic | | config | | login_log | | task | | user | | verify | +----------------------+ 9 rows in set (0.01 sec) mysql> \q Bye sh-4.4exit
配置文件 复制配置文件模板并编辑配置文件
1 2 3 cd /www/wwwroot/azpanel/cp .example.env .env vim .env
如下修改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 APP_DEBUG = false [APP] DEFAULT_TIMEZONE = Asia/ShanghaiAPP_NAME = Azure[DATABASE] TYPE = mysqlHOSTNAME = 127.0 .0.1 DATABASE = azpanelUSERNAME = azpanelPASSWORD = 你的azpanel密码HOSTPORT = 3306 CHARSET = utf8DEBUG = true [THEME] CARD_WIDTH = 10 CARD_RIGHT_OFFSET = 1 [LANG] default_lang = zh-cn
创建管理员 如果数据库配置错误,会这样
1 2 [think\db\exception\PDOException] SQLSTATE[HY000] [1045] Access denied for user 'root' @'localhost' (using password: NO)
导入更多数据库 添加定时任务 然后输入
1 2 3 4 5 0 0 * * * php /www/wwwroot/azpanel/think tools --action statisticsTraffic 0 * * * * php /www/wwwroot/azpanel/think autoRefreshAccount 0 * * * * php /www/wwwroot/azpanel/think closeTimeoutTask 0 * * * * php /www/wwwroot/azpanel/think trafficControlStop */5 * * * * php /www/wwwroot/azpanel/think trafficControlStart
编辑 nginx 配置 1 2 3 touch /etc/nginx/sites-available/azpanel.conf vim /etc/nginx/sites-available/azpanel.conf
输入下面模板(把azpanel.net)改成你的域名
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 server { listen 80; server_name azpanel.net ; return 301 https://$server_name$request_uri ; } server { listen 443 ssl http2; server_name azpanel.net ; index index.html index.htm index.php default.html default.htm default.php; root /www/wwwroot/azpanel/public; ssl_certificate /etc/letsencrypt/live/azpanel.net/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/azpanel.net/privkey.pem; 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; include conf.d/azpanel/thinkphp.conf; location ~ \.php$ { fastcgi_pass unix:/var/run/php/php-fpm.sock; include conf.d/azpanel/php_fastcgi.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 /www/wwwlogs/azpanel.net.log; }
1 mkdir /etc/nginx/conf.d/azpanel/ && vim /etc/nginx/conf.d/azpanel/thinkphp.conf
输入
1 2 3 4 5 location / { if (!-e $request_filename ){ rewrite ^(.*)$ /index.php?s=$1 last; break ; } }
1 vim /etc/nginx/conf.d/azpanel/php_fastcgi.conf
输入
1 2 3 4 5 6 7 8 9 10 11 12 13 14 # 404 try_files $fastcgi_script_name =404; # default fastcgi_params include fastcgi_params; # fastcgi settings fastcgi_index index.php; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; # fastcgi params fastcgi_param DOCUMENT_ROOT $realpath_root; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
申请证书 先把你的域名进行dns解析到正确的ip
1 2 apt install certbot python3-certbot-nginx -y certbot certonly --nginx -d 你的域名
重启nginx 1 2 ln -s /etc/nginx/sites-available/azpanel.conf /etc/nginx/sites-enabled/azpanel.conf systemctl restart nginx
完成!
附录 安装成功输出 看完可跳转到继续安装 -> 点击跳转
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 root@ashburn:/www/wwwroot/azpanel Do not run Composer as root/super user! See https://getcomposer.org/root for details Continue as root/super user [yes ]? yes No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information. Loading composer repositories with package information Updating dependencies Lock file operations: 39 installs, 0 updates, 0 removals - Locking adbario/php-dot-notation (2.3.0) - Locking alibabacloud/client (1.5.31) - Locking clagiordano/weblibs-configmanager (v1.2.0) - Locking danielstjules/stringy (3.1.0) - Locking guzzlehttp/guzzle (6.5.8) - Locking guzzlehttp/promises (1.5.1) - Locking guzzlehttp/psr7 (1.9.0) - Locking league/flysystem (1.1.9) - Locking league/flysystem-cached-adapter (1.1.0) - Locking league/mime-type-detection (1.11.0) - Locking mtdowling/jmespath.php (2.6.1) - Locking nesbot/carbon (2.59.1) - Locking paragonie/constant_time_encoding (v2.6.3) - Locking paragonie/random_compat (v9.99.100) - Locking phpmailer/phpmailer (v6.6.3) - Locking phpseclib/phpseclib (3.0.14) - Locking psr/cache (1.0.1) - Locking psr/container (1.1.2) - Locking psr/http-message (1.0.1) - Locking psr/log (1.1.4) - Locking psr/simple-cache (1.0.1) - Locking ralouphie/getallheaders (3.0.3) - Locking symfony/deprecation-contracts (v2.5.2) - Locking symfony/polyfill-intl-idn (v1.26.0) - Locking symfony/polyfill-intl-normalizer (v1.26.0) - Locking symfony/polyfill-mbstring (v1.26.0) - Locking symfony/polyfill-php72 (v1.26.0) - Locking symfony/polyfill-php80 (v1.26.0) - Locking symfony/translation (v5.4.9) - Locking symfony/translation-contracts (v2.5.2) - Locking symfony/var-dumper (v4.4.42) - Locking topthink/framework (v6.0.13) - Locking topthink/think-captcha (v3.0.7) - Locking topthink/think-helper (v3.1.6) - Locking topthink/think-migration (v3.0.3) - Locking topthink/think-orm (v2.0.54) - Locking topthink/think-template (v2.0.8) - Locking topthink/think-trace (v1.4) - Locking topthink/think-view (v1.0.14) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 39 installs, 0 updates, 0 removals - Downloading symfony/polyfill-mbstring (v1.26.0) - Downloading mtdowling/jmespath.php (2.6.1) - Downloading symfony/polyfill-php72 (v1.26.0) - Downloading symfony/polyfill-intl-normalizer (v1.26.0) - Downloading symfony/polyfill-intl-idn (v1.26.0) - Downloading ralouphie/getallheaders (3.0.3) - Downloading psr/http-message (1.0.1) - Downloading guzzlehttp/psr7 (1.9.0) - Downloading guzzlehttp/promises (1.5.1) - Downloading guzzlehttp/guzzle (6.5.8) - Downloading danielstjules/stringy (3.1.0) - Downloading clagiordano/weblibs-configmanager (v1.2.0) - Downloading adbario/php-dot-notation (2.3.0) - Downloading alibabacloud/client (1.5.31) - Downloading psr/cache (1.0.1) - Downloading league/mime-type-detection (1.11.0) - Downloading league/flysystem (1.1.9) - Downloading league/flysystem-cached-adapter (1.1.0) - Downloading symfony/translation-contracts (v2.5.2) - Downloading symfony/polyfill-php80 (v1.26.0) - Downloading symfony/deprecation-contracts (v2.5.2) - Downloading symfony/translation (v5.4.9) - Downloading nesbot/carbon (2.59.1) - Downloading phpmailer/phpmailer (v6.6.3) - Downloading paragonie/random_compat (v9.99.100) - Downloading paragonie/constant_time_encoding (v2.6.3) - Downloading phpseclib/phpseclib (3.0.14) - Downloading psr/container (1.1.2) - Downloading symfony/var-dumper (v4.4.42) - Downloading topthink/think-helper (v3.1.6) - Downloading psr/simple-cache (1.0.1) - Downloading psr/log (1.1.4) - Downloading topthink/think-orm (v2.0.54) - Downloading topthink/framework (v6.0.13) - Downloading topthink/think-captcha (v3.0.7) - Downloading topthink/think-migration (v3.0.3) - Downloading topthink/think-trace (v1.4) - Downloading topthink/think-template (v2.0.8) - Downloading topthink/think-view (v1.0.14) - Installing symfony/polyfill-mbstring (v1.26.0): Extracting archive - Installing mtdowling/jmespath.php (2.6.1): Extracting archive - Installing symfony/polyfill-php72 (v1.26.0): Extracting archive - Installing symfony/polyfill-intl-normalizer (v1.26.0): Extracting archive - Installing symfony/polyfill-intl-idn (v1.26.0): Extracting archive - Installing ralouphie/getallheaders (3.0.3): Extracting archive - Installing psr/http-message (1.0.1): Extracting archive - Installing guzzlehttp/psr7 (1.9.0): Extracting archive - Installing guzzlehttp/promises (1.5.1): Extracting archive - Installing guzzlehttp/guzzle (6.5.8): Extracting archive - Installing danielstjules/stringy (3.1.0): Extracting archive - Installing clagiordano/weblibs-configmanager (v1.2.0): Extracting archive - Installing adbario/php-dot-notation (2.3.0): Extracting archive - Installing alibabacloud/client (1.5.31): Extracting archive - Installing psr/cache (1.0.1): Extracting archive - Installing league/mime-type-detection (1.11.0): Extracting archive - Installing league/flysystem (1.1.9): Extracting archive - Installing league/flysystem-cached-adapter (1.1.0): Extracting archive - Installing symfony/translation-contracts (v2.5.2): Extracting archive - Installing symfony/polyfill-php80 (v1.26.0): Extracting archive - Installing symfony/deprecation-contracts (v2.5.2): Extracting archive - Installing symfony/translation (v5.4.9): Extracting archive - Installing nesbot/carbon (2.59.1): Extracting archive - Installing phpmailer/phpmailer (v6.6.3): Extracting archive - Installing paragonie/random_compat (v9.99.100): Extracting archive - Installing paragonie/constant_time_encoding (v2.6.3): Extracting archive - Installing phpseclib/phpseclib (3.0.14): Extracting archive - Installing psr/container (1.1.2): Extracting archive - Installing symfony/var-dumper (v4.4.42): Extracting archive - Installing topthink/think-helper (v3.1.6): Extracting archive - Installing psr/simple-cache (1.0.1): Extracting archive - Installing psr/log (1.1.4): Extracting archive - Installing topthink/think-orm (v2.0.54): Extracting archive - Installing topthink/framework (v6.0.13): Extracting archive - Installing topthink/think-captcha (v3.0.7): Extracting archive - Installing topthink/think-migration (v3.0.3): Extracting archive - Installing topthink/think-trace (v1.4): Extracting archive - Installing topthink/think-template (v2.0.8): Extracting archive - Installing topthink/think-view (v1.0.14): Extracting archive 27 package suggestions were added by new dependencies, use `composer suggest` to see details. Generating autoload files > @php think service:discover Succeed! > @php think vendor:publish File /www/wwwroot/azpanel/config/captcha.php exist! File /www/wwwroot/azpanel/config/trace.php exist! Succeed! 17 packages you are using are looking for funding. Use the `composer fund` command to find out more!