搭建登录/注册的服务/客户端
安装Apache:
在 Ubuntu 和 Debian 系统中,Apache 软件包和服务被称为 apache2
sudo apt update
sudo apt install apache2
安装完成,Apache服务将被自动启动
验证Apache是否正在运行:
sudo systemctl status apache2
打开HTTP和HTTPS端口
Apache 监听了端口80
和443
你需要在防火墙打开那些端口,以便网站服务器从互联网上是可以访问的
如果正在使用UFW,可以通过启用Apache Full
配置,它包含了这两个端口的规则
sudo ufw allow 'Apache Full'
验证改变:
sudo ufw status
或者:
netstat -lntup
# 显示被监听UDP、TCP端口使用情况
最后验证
在浏览器地址栏输入自己的主机名 或 ipv4地址
localhost
http://127.0.0.1/
http://10.17.54.163/
启动成功是这样一个样子
Apache常用命令:
sudo service apache2 start //启动服务
sudo service apache2 stop //结束服务
sudo service apache2 restart //重启服务
最后将其修改成自己的网页:
sudo vim /etc/apache2/sites-enabled/000-default.conf
Forbidden
启动网站:
———————————————————————————————————————————————————————————————————————
好家伙,提示我没有权限访问
按照网上的解决办法:
1. 要755以上权限。解决方法:用命令
chmod 755 相应目录
2. 防火墙的原因
让防火墙通过WWW服务
3. 虚拟主机配置错误
4. DocumentRoot的设置(这个解决了我的问题)
-
Apache 2.2
没安装我不清楚
-
Apache 2.4
sudo vim /etc/apache2/apache2.conf
###以下是我/etc/apache2 原来的配置 ###
<!--这是我/etc/apache2原生的配置-->
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
我看到这个递归目录还是原来的,就把它改一下试试
sudo sudo /etc/apache2/apache2.conf
这是改好的配置
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /home/x9nu/PROJECT/go><!-就只改了这行,是我自己站点的目录-->
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
最后启动成功