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

自此,完成

相关推荐
聆风吟º2 分钟前
【Python编程日志】Python入门基础(二):行 | 缩进 | print输出
开发语言·python·print··缩进
weixin_430750935 分钟前
部署FreeRadius+php+apache+mariaDB+daloradius 实现认证计费功能
php·apache·mariadb·daloradius·freeradius
lsx2024065 分钟前
Servlet 点击计数器
开发语言
卷心菜狗7 分钟前
Python进阶-闭包与装饰器
开发语言·python·学习
凯瑟琳.奥古斯特10 分钟前
C++变量命名进阶技巧
开发语言·c++
不羁的fang少年12 分钟前
Netty网络模型
java·开发语言
niucloud-admin12 分钟前
PHP SAAS 框架常见问题——页面装修本地开发环境配置
php
基德爆肝c语言1 小时前
Qt—信号和槽
开发语言·qt
geovindu1 小时前
go:Decorator Pattern
开发语言·设计模式·golang·装饰器模式
故事和你912 小时前
洛谷-算法2-1-前缀和、差分与离散化1
开发语言·数据结构·c++·算法·深度优先·动态规划·图论