FRPC+PHP+MYSQL+APACHE2=个人网站

应用背景有公网需求,但是又不想去买又贵又低配置的服务器,然后方案就应运而生

frp/README_zh.md at dev · fatedier/frp (github.com)

在这里,

FRPC作为内网穿透服务,

PHP+MYSQL+APACHE2,作为网站搭建,具体细节不细讲,

但是在我的/var/www/html下面

linaro@Hinlink:/var/www/html$ tree -L 1

.

├── 404.html

├── 笔记.txt

├── ask

├── base64

├── bg.png

├── chat

├── DownLoad

├── favicon.ico

├── H68K

├── index.html

├── on_publish.php

├── pac

├── probe.php

├── README.md

├── speedtest-x

├── tools

├── typecho

├── typecho_2023_5_1.sql

├── videos

├── WebShell.php

├── websocket.html

├── wordpress

├── www

└── xss

可以看到,有很多目录,我想实现 typecho.domain.com,这样的三级域名的方式,访问,

在FRPC.ini的配置里面

linaro@Hinlink:/var/www/html$ cat /etc/frp/frpc.ini

common

server_addr = FRPS服务器

server_port = 7000

token = 第三方token

HT2_PHP

type = http

local_ip = 127.0.0.1

local_port = 80

remote_port = 80

#subdomain = www

custom_domains = *.domain.com

custom_domains 其中的值,带上了*,通配符匹配

然后是去域名服务器配置域名解析

然后,任意访问 www.domain.com或者222.domain.com,会发现得到的页面都是一样的

这个时候,需要配置apache

第一步开启地址重写

sudo a2enmod rewrite

第二步,修改配置文件

nano /etc/apache2/sites-available/000-default.conf

复制代码
<VirtualHost *:80>

    DocumentRoot /var/www/html

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^(([-_a-zA-Z0-9])+)\.\w+\.\w+$ [NC]
    RewriteRule ^(.*)$ /%1/$1 [L]

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    ErrorDocument 404 "404 Not Found"
</VirtualHost>

第三步重启Apache2

sudo systemctl restart apache2

自此,完成

相关推荐
damoluomu2 天前
挑 PHP CMS 之前,先学会看它的协议
php
小羊没烦恼!2 天前
初探性能优化——2个月到4小时的性能提升
java·开发语言·windows·算法·c#
伞伞悦读2 天前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__
开发语言·python
C语言小火车2 天前
C/C++ 为什么需要编译器?
开发语言·c++
霍霍的袁2 天前
【C++】map 和 set 的使用 | 从用法到底层
开发语言·c++·学习·visual studio
孙启超2 天前
【AI开发之Rust】第 11 课:智能指针与内部可变性
开发语言·后端·rust
此生决int2 天前
深入理解C++系列(20)——C++11(下)
开发语言·c++
CoderYanger3 天前
A.每日一题:835. 图像重叠
java·开发语言·程序人生·leetcode·面试·职场和发展·学习方法
伞伞悦读3 天前
【第37期】Python JSON 与配置详解:序列化、反序列化、嵌套结构和配置文件
开发语言·python·json
CCCCCCCCharlie3 天前
Linux进程控制四大核心操作
linux·开发语言