1、安装nginx
输入apt-get -y install nginx回车
apt-get -y install nginx
然后就安装成功了
输入玩客云ip地址我这里是:10.0.0.109
2、安装php最新版的armbian包24.5默认安装的是php8.2
复制回车远行,然后等
apt install -y php php-fpm php-mysql php-gd php-curl php-mbstring php-xml php-xmlrpc php-json php-zip php-intl php-xsl
php -v查询版本号
3、安装Mariadb
apt install -y mariadb-server
mysql -v查询版本号
4.配置环境
4.1配置nginx
首先输入vim /etc/nginx/sites-enabled/default,打开nginx配置文件
vim /etc/nginx/sites-enabled/default
在44行前面添加index.php,56行57行和60行以及63行去除行头#号(注意这里的默认的php7.4要改为php8.2)注意这里如果用putty登录修改会出错,可能是编码的问题。
输入nginx -t
root@aml-s812:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
表示没有问题
重新启动nginx
service nginx restart
新建测试页面文件(后面记得删除)
echo "<?php phpinfo(); ?>">/var/www/html/info.php
浏览器打开ip/info.php
就可以看到php的相关信息了
4.2配置Mariadb
4.2.1安全设置
输入mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
- In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank,so you should just press enter here.
Enter current password for root (enter for none):
注意:建议所有人都运行此脚本的所有部分服务器在生产中使用!请仔细阅读每一步!为了登录MariaDB以确保其安全,我们需要当前根用户的密码。如果你刚刚安装了MariaDB您尚未设置根密码,密码将为空,所以你应该在这里按回车键。输入root用户的当前密码(输入无):我们刚刚安装,没有密码直接回车 - Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.You already have a root password set, so you can safely answer 'n'.Change the root password? [Y/n]
设置root密码可以确保任何人都无法登录MariaDB未经适当授权的root用户。您已经设置了根密码,因此可以安全地回答“n”。
更改根密码?[是/否]
输入y设置一个简单而且你记得住密码 我这里是P@ssW0 - By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.Remove anonymous users? [Y/n]
默认情况下,MariaDB安装有匿名用户,允许任何人登录MariaDB而无需为其创建用户帐户他们这仅用于测试和安装再平稳一点。你应该在搬进公寓前把它们取下来生产环境。
删除匿名用户?[是/否]
y 删除就完了 - Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n]
通常,root用户只能从“localhost”连接。这确保有人无法从网络中猜到根密码。
不允许根用户远程登录?[是/否]
n方便修改 - By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.Remove test database and access to it? [Y/n]
默认情况下,MariaDB附带一个名为“test”的数据库,任何人都可以使用通道这也仅用于测试,应移除在进入生产环境之前。
删除测试数据库并访问它?[是/否]
n没有用直接删除 - Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? [Y/n]
重新加载特权表将确保迄今为止所做的所有更改将立即生效。
现在重新加载特权表吗?[是/否]
y
4.2.2 账户设置
- 直接输入mysql直接登录
mysql - 查询用户表
select User,host from mysql.user; - 使用mysql数据库
use mysql;
GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
添加一个可以从任何地址登录的root账户密码建议复杂一点
mysql用户想连到mysql,需要使用grant命令给用户授权,有一个简单的办法,可以使用grant ALL privileges 命令给用户授予所有权限, 你想myuser使用mypassword从任何主机连接到mysql服务器的话。
主要使用:GRANT ALL PRIVILEGES ON . to 'root'@'%'; 命令授权. - -grant给root使用root密码从任何主机连接到mysql服务器。
GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES; - -或者
GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'root';
FLUSH PRIVILEGES; - -grant给root用户授予操作mysql所有数据库的所有权限
文链接:h[ttps://blog.csdn.net/weixin_32848231/article/details/113902462](https://blog.csdn.net/weixin_32848231/article/details/113902462)
ALTER USER 'root'@'%' IDENTIFIED BY '6166b2002fdcb5df';
ALTER USER 'root'@'localhost' IDENTIFIED BY 'P@ssW0rd';
update user set plugin = 'mysql_native_password' where user = 'root';
flush privileges;
5、自动挂载u盘,把typecho安装到u盘
修改/etc/rc.local添加挂载u盘命令,给该文件执行权限。
6、nginx修改web目录到u盘目录
nano /etc/nginx/sites-enabled/default,打开nginx配置文件
修改server块为:
root /mnt/sda/web/typecho;
挂在u盘时需要更改U盘的系统文件格式为ext4,否则不支持修改权限
重新加载Nginx配置以使更改生效,通常使用以下命令:sudo nginx -s reload
或者重启Nginx服务:sudo systemctl reload nginx
或者在不同的系统中:sudo service nginx reload
7、安装typecho
8、安装过程出错,问题解决:
8.1、安装程序时无法连接数据库
在把程序放到目录下,进行安装的时候,将数据库的密码输入正确后,无法进行安装
这个时候处理方式就是手动创建一个typecho的数据库即可解决
8.2、无法登录后台
Nginx服务器点击前台链接或者后台登录时出现404, not found
官方给的解决方式是一般的出现这种情况时,nginx.conf里的location设置都是类似这样
location ~ .*\.php$
要支持pathinfo,要改成
location ~ .*\.php(\/.*)*$
一个比较好的typecho博客网址:https://yangwenqing.com/