-
Notifications
You must be signed in to change notification settings - Fork 205
lnmp.org
azpanel edited this page Sep 24, 2023
·
10 revisions
cd /root
wget http://soft.lnmp.com/lnmp/lnmp2.0.tar.gz -O lnmp2.0.tar.gz
tar zxf lnmp2.0.tar.gz
cd lnmp2.0
./install.sh lnmp
运行要求
-
php
:7.2.5+
或8.x +
-
mysql
/mariadb
注意事项
- 需要启用
InnoDB
引擎
启用被禁用的函数
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
添加虚拟主机
root@lnmp19:~# 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: xxx@gmail.com
Email address xxx@gmail.com is valid.
Press any key to start create virtul host...
这里挑重点说
- 询问是否添加
rewrite
时输入y
,然后输入thinkphp
- 询问是否添加
SSL
时,建议添加并选择第三个(BuyPass),证书有效期180
天
主要是以下三点
- 强制
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/azpanel/azpanel.git .
chmod 755 -R *
chown www -R *
composer install
- 创建数据库
azpanel
- 导入
database/azure.sql
- 导入
database/config.sql
你可以使用 phpmyadmin
来创建和导入数据库,教程将演示在命令行下创建和导入
root@lnmp19:/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
root@lnmp19:/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
其他略
执行
root@lnmp19:/home/wwwroot/azpanel# php think createAdmin --email admin@azpanel.net --passwd loginpasswd
An administrator account has been created.
如果数据库配置错误,会这样
[think\db\exception\PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
执行
php think migrate:run
php think seed:run
0 0 * * * php /home/wwwroot/azpanel/think tools --action statisticsTraffic
0 * * * * php /home/wwwroot/azpanel/think autoRefreshAccount
0 * * * * php /home/wwwroot/azpanel/think closeTimeoutTask
0 * * * * php /home/wwwroot/azpanel/think trafficControlStop
*/5 * * * * php /home/wwwroot/azpanel/think trafficControlStart