Typecho安装后后台界面和文章链接均为404解决办法 作者: _囧rz_ 时间: 2022-04-05 分类: 计算机类 使用lnmp安装后后台登录不进去,花费3个月重装VPS,重装LNMP 还是发现PHPinfo和伪静态问题导致无法打开后台,重新折腾了一下 自己手动安装了 nginx / php /mysql 最后终于折腾完成了 1.系统 ---- debian 11 更新源 /etc/apt/sources.list # comment out DVD source and add network source #deb cdrom:[Debian GNU/Linux 11.0.0 _Bullseye_ - Official amd64 DVD Binary-1 20210814-10:04]/ bullseye contrib main deb http://deb.debian.org/debian/ bullseye main contrib # if comment outed # uncomment it to enable [security] source deb http://security.debian.org/debian-security bullseye-security main contrib # if comment outed # uncomment it to enable [updates] source deb http://deb.debian.org/debian/ bullseye-updates main contrib deb http://deb.debian.org/debian/ bullseye-backports main contrib 最后可使用官方源,可以不用更改 2.安装nginx --------- 参考 https://www.insilen.com/post/linux-nginx-php.html 安装先决条件: apt install curl gnupg2 ca-certificates lsb-release 要为稳定的 nginx 软件包设置 apt 仓库 echo "deb http://nginx.org/packages/debian `lsb_release -cs` nginx" \ | tee /etc/apt/sources.list.d/nginx.list curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add - 不验证完整了 sudo apt update sudo apt install nginx 加入开机 systemctl enable nginx 重新启动nginx service restart nginx 3.防火墙放行 ------- 参考 https://sunpma.com/555.html 添加80和443端口,测试是否正常访问 Debian/Ubuntu 放行端口 安装iptables(通常系统都会自带,如果没有就需要安装) apt-get update apt-get install iptables 放行对应端口 iptables -I INPUT -p tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp --dport 443 -j ACCEPT 然后保存放行规则 iptables-save 设置完就已经放行了指定的端口,但重启后会失效,下面设置持续生效规则; 安装iptables-persistent apt-get install iptables-persistent 保存规则持续生效 netfilter-persistent save netfilter-persistent reload 设置完成后指定端口就会持续放行了; Centos: yum update yum install iptables 放行端口 firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent 命令含义: --zone #作用域 --add-port=80/tcp #添加端口,格式为:端口/通讯协议 --permanent #永久生效,没有此参数重启后失效 然后重启防火墙 firewall-cmd --reload 查看防火墙规则 iptables -L 4.安装PHP ------- 要安装 MySQL 对 PHP 7.4 的支持 sudo apt install -y php7.4-mysql WordPress 的 PHP 扩展 apt install -y \ php7.4-mysql \ php7.4-dom \ php7.4-simplexml \ php7.4-ssh2 \ php7.4-xml \ php7.4-xmlreader \ php7.4-curl \ php7.4-exif \ php7.4-ftp \ php7.4-gd \ php7.4-iconv \ php7.4-imagick \ php7.4-json \ php7.4-mbstring \ php7.4-posix \ php7.4-sockets \ php7.4-tokenizer Typecho 的 PHP 扩展 apt install -y \ php7.4-xml \ php7.4-curl \ php7.4-mysql \ php7.4-mbstring Joomla 的 PHP 扩展 apt install -y \ php7.4-mysql \ php7.4-xml \ php-pear \ php7.4-json Drupal 的 PHP 扩展 apt install -y \ php7.4-mysql \ php7.4-dom \ php7.4-gd \ php7.4-json \ php7.4-pdo \ php7.4-simplexml \ php7.4-tokenizer \ php7.4-xml 5.安装mysql ------- 从mysql官网找到debian的mysql安装包url https://dev.mysql.com/downloads/repo/apt/ 查看最新的版本 wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb 配置下载的包 sudo dpkg -i mysql-apt-config_0.8.22-1_all.deb 弹出mysql数据源配置的图形界面,选择ok 继续。 更新数据源 sudo apt-get update 安装更新包 sudo apt-get install mysql-server 正常的操作 配置root 密码 后测试出现mysql>即可 mysql -uroot -p 基本的mysql 操作 sudo service mysql start sudo service mysql stop sudo service mysql restart 删除mySQL 停用,查询包,删除文件 service mysql stop rm -rf /var/lib/mysql rm -rf /var/lib/mysql rm -rf /usr/lib64/mysql dpkg --get-selections | grep mysql sudo apt-get --purge remove mysql-server sudo apt-get --purge remove mysql-client sudo apt-get --purge remove mysql-common apt-get autoremove apt-get autoclean rm /etc/mysql/ -R rm /var/lib/mysql/ -R 6.配置nginx,修改文件重定向 进入/etc/nginx 配置 nginx.conf 改成自己想要使用的方式 nginx/1.18.0 目录有变化 进入/etc/nginx/sites-available 后台404,参考官方更改 http://docs.typecho.org/servers#nginx 修改default文件,权限,安全,配置根据需要修改 server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /www; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html index.php; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; ##这里添加 set $path_info ""; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; ##这里结束 } # pass PHP scripts to FastCGI server ##这里修改 location ~ .*\.php(\/.*)*$ { ##这里结束 fastcgi_pass unix:/run/php/php7.4-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; ##这里添加 fastcgi_param PATH_INFO $path_info; ##这里结束 } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } 弄完之后发现typecho竟然升级了.... 最近版本 1.2.0赶紧升级上去!! 标签: none
评论已关闭