1.下载花生壳(内网穿透)客户端
wget "/hsk/linux/phddns_5.2.0_amd64.deb" -O phddns_5.2.0_amd64.deb
2.下载后,安装并启用花生壳
sudo dpkg -i xxx.debsudo phddns start/stop/restart
3.进入花生壳远程管理页面
浏览器输入远程管理地址
输入安装花生壳时生成的SN码及默认密码admin进入
4.安装Apache
sudo apt updatesudo apt install apache2
5.验证 Apache2 是否正在运行
sudo systemctl status apache2
运行成功
6.验证 Apache 安装
打开你的浏览器,输入服务器 IP 地址http://YOUR_IP_OR_DOMAIN/
安装成功
7.配置默认000-default.conf虚拟主机(也可创建多个)
sudo vim /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80># The ServerName directive sets the request scheme, hostname and port that# the server uses to identify itself. This is used when creating# redirection URLs. In the context of virtual hosts, the ServerName# specifies what hostname must appear in the request's Host: header to# match this virtual host. For the default virtual host (this file) this# value is not decisive as it is used as a last resort host regardless.# However, you must set it for any further virtual host explicitly.#ServerName html#ServerAlias www.htmlServerAdmin webmaster@内网穿透访问地址DocumentRoot /var/www/项目文件夹# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,# error, crit, alert, emerg.# It is also possible to configure the loglevel for particular# modules, e.g.#LogLevel info ssl:warn#<Directory /var/www/html>#Options -Indexes +FollowSymLinks#AllowOverride All#</Directory>ErrorLog ${APACHE_LOG_DIR}/error.logCustomLog ${APACHE_LOG_DIR}/access.log combined# For most configuration files from conf-available/, which are# enabled or disabled at a global level, it is possible to# include a line for only one particular virtual host. For example the# following line enables the CGI configuration for this host only# after it has been globally disabled with "a2disconf".#Include conf-available/serve-cgi-bin.conf</VirtualHost># vim: syntax=apache ts=4 sw=4 sts=4 sr noet
8.在apache2.conf最后一行添加ServerName
sudo vim /etc/apache2/sites-enabled/apache2.conf
ServerName 内网穿透访问地址:端口号
9.测试配置文件,是否有任何语法错误
sudo apachectl configtest
如果没有任何错误,你将会看到下面的输出
Syntax OK
10.重启 Apache 服务,使修改生效
sudo systemctl restart apache2
11.最终效果
在浏览器输入http://内网穿透访问地址/xxx.html
好了,就到这了,如果喜欢就点个赞吧!
如果觉得《ubuntu20 系统 Apache+花生壳(内网穿透)服务项目上线》对你有帮助,请点赞、收藏,并留下你的观点哦!