Files
chill_notes/实践积累/个人知识库/Linux/阿里云_Ubuntu管理apache2.md
2026-04-21 17:24:50 +08:00

21 lines
4.8 KiB
Markdown
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
1. 首先安装Apache2安装命令sudo apt-get install apache2
[![UbuntuApache2](Exported%20image%2020260407231508-0.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=1)3.  安装完成后,进入到/etc/apache2中根据自己的实际安装目录这边我配置文件在/etc/apache2中。 我们看到没有想象中的httpd.conf配置文件这里要说明的是apache2的配置文件是apache2.conf,而不是http.conf。 打开apache2.conf。写入两条语句ServerName localhostDirectoryIndex index.html index.htm index.php这里的ServerName localhost是为了防止最后开启apache2服务的时候会提示DNS出错。DirectoryIndex index.html index.htm index.php是默认目录的写法。保存退出。可以在apache2.conf中加入  AddDefaultCharset GB2312    设置默认字符集,定义服务器返回给客户机默认字符集(由于西欧UTF-8是Apache默认字符集因此当访问有中文的网页时会出现乱码这时只要将字符集改成GB2312再重启Apache服务即可)Listen 192.168.1.1:80       设置监听ip是192.168.1.1的地址和端口为80Listen 192.168.1.2:8080     设置监听ip是192.168.1.2的地址和端口为8080Alias /down    "/sofТWare /download"   创建虚拟目录创建名为down的虚拟目录它对应的物理路径是/sofТWare /downloadAlias /ftp     "/var/ftp"                创建虚拟目录创建名为ftp的虚拟目录它对应的物理路径是/var/ftp<Directory "/var/www/html">       设置目录权限(<Directory "目录路径">此次写设置目录权限的语句</Directory>      Options FollowSymLinks        page:116      AllowOverride None</Directory>
[![UbuntuApache2](Exported%20image%2020260407231510-1.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=2)
[![UbuntuApache2](Exported%20image%2020260407231513-2.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=3)7.  需要说明的是在apache2中根设置默认主目录在 /etc/apache2/sites-АVailable/default中我们打开default进行配置。如图这里我们的默认主目录设置的路径是/var/www,文档最上方的VirtualHost后方的*代表通配符即表示所有本机ip地址监听端口为80ServerName填写你注册的域名没有可以不填。保存退出。
[![UbuntuApache2](Exported%20image%2020260407231515-3.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=4)
[![UbuntuApache2](Exported%20image%2020260407231517-4.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=5)11.   至此基本配置已经全部完成查看本机ip地址。输入启用apache2的命令:/etc/init.d/apache2 restart.并在浏览器中输入本机ip地址。成功
[![UbuntuApache2](Exported%20image%2020260407231522-5.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=6)
[![UbuntuApache2](Exported%20image%2020260407231525-6.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=7)
[![UbuntuApache2](Exported%20image%2020260407231527-7.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=8)
## END
注意事项
18. 配置文件从httpd.conf变成了apache2.con > 来自 <[https://jingyan.baidu.com/article/9158e0006581d1a2541228b5.html](https://jingyan.baidu.com/article/9158e0006581d1a2541228b5.html)>
[![UbuntuApache2](Exported%20image%2020260407231553-8.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=1)[![UbuntuApache2](Exported%20image%2020260407231559-9.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=2)
[![UbuntuApache2](Exported%20image%2020260407231602-10.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=3)[![UbuntuApache2](Exported%20image%2020260407231605-11.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=4)
[![UbuntuApache2](Exported%20image%2020260407231610-12.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=5)[![UbuntuApache2](Exported%20image%2020260407231612-13.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=6)
[![UbuntuApache2](Exported%20image%2020260407231616-14.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=7)
[![UbuntuApache2](Exported%20image%2020260407231620-15.jpeg)](http://jingyan.baidu.com/album/9158e0006581d1a2541228b5.html?picindex=8)
> 来自 <[https://jingyan.baidu.com/article/9158e0006581d1a2541228b5.html](https://jingyan.baidu.com/article/9158e0006581d1a2541228b5.html)>
![plain aptget install apache2 aptget install libapa...](Exported%20image%2020260407231623-16.png)