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

自此,完成

相关推荐
long31610 分钟前
java 工厂方法设计模式 FactoryMethod
java·开发语言·后端·设计模式
柯南二号4 小时前
MacOS 系统计算机专业好用工具安装
开发语言·lua
神洛华4 小时前
Lua语言程序设计2:函数、输入输出、控制结构
开发语言·lua
java1234_小锋5 小时前
一周学会Matplotlib3 Python 数据可视化-绘制热力图(Heatmap)
开发语言·python·信息可视化·matplotlib·matplotlib3
梁辰兴5 小时前
数据结构:串、数组与广义表
开发语言·数据结构·c··数组·广义表
nvvas6 小时前
PHP imagick扩展安装以及应用
php
三体世界6 小时前
Mysql基本使用语句(一)
linux·开发语言·数据库·c++·sql·mysql·主键
etcix6 小时前
wrap cpp variant as dll for c to use
java·c语言·开发语言
Websites7 小时前
Hyperf 百度翻译接口实现方案
开发语言·自然语言处理·php·自动翻译
papership8 小时前
【入门级-C++程序设计:11、指针与引用-引 用】
c语言·开发语言·c++·青少年编程