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

 自此,完成

相关推荐

  1. Vue 3 + Koa2 + MySQL 开发和上线部署个人网站

    2024-04-25 08:46:02       36 阅读
  2. 计算机网络个人小结

    2024-04-25 08:46:02       35 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-25 08:46:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-25 08:46:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-25 08:46:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-25 08:46:02       20 阅读

热门阅读

  1. perl:BigInt 计算 斐波那契数列

    2024-04-25 08:46:02       16 阅读
  2. 学习STM32第十八天

    2024-04-25 08:46:02       14 阅读
  3. MySQL中like关键字与索引的使用

    2024-04-25 08:46:02       50 阅读
  4. SQL中PIVOT函数的用法

    2024-04-25 08:46:02       33 阅读
  5. Vue入门

    Vue入门

    2024-04-25 08:46:02      17 阅读
  6. 基于vscode的c++开发(Windows)

    2024-04-25 08:46:02       35 阅读