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

自此,完成

相关推荐
zs宝来了1 分钟前
网络篇15-网络收发包应用之iptable
开发语言·网络·php
烤麻辣烫1 分钟前
算法--二分搜索
java·开发语言·学习·算法·intellij-idea
编码浪子3 分钟前
《安全 Rust 的边界在哪?》— 中文解读
开发语言·安全·rust
kyriewen1120 分钟前
Next.js:让你的React应用从“裸奔”到“穿衣服”
开发语言·前端·javascript·react.js·设计模式·ecmascript
三品吉他手会点灯25 分钟前
C语言学习笔记 - 18.C编程预备计算机专业知识 - 什么是变量
c语言·开发语言·笔记·学习
好奇龙猫30 分钟前
[大学院-python-base gammer learning2: python base programming ]
开发语言·python
海盗12341 小时前
C#上位机开发-S7协议通信
开发语言·c#
小短腿的代码世界1 小时前
Qt 2D 绘制实战与性能优化深度解析
开发语言·qt·性能优化
FeBaby1 小时前
ReentrantLock 与 synchronized 底层实现对比图解
开发语言·c#