最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

阿里云ECS服務(wù)器安裝Apache的步驟

 更新時(shí)間:2025年08月25日 14:29:22   作者:藍(lán)黑2020  
本文介紹在阿里云ECS CentOS7.9服務(wù)器上安裝Apache的步驟,包括使用yum安裝、開放80端口、配置主文件httpd.conf及默認(rèn)頁面index.html,最后通過創(chuàng)建ding用戶并調(diào)整權(quán)限實(shí)現(xiàn)對網(wǎng)站目錄的訪問與修改,感興趣的朋友跟隨小編一起看看吧

環(huán)境

  • 阿里云ECS服務(wù)器(CentOS 7.9)

Apache

安裝

以下命令使用 root 賬號(hào)操作。

使用 yum 命令安裝Apache:

yum install httpd

啟動(dòng)Apache:

systemctl start httpd

檢查Apache狀態(tài):

systemctl status httpd

設(shè)置Apache開機(jī)啟動(dòng):

systemctl enable httpd

打開80端口:

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

測試:

nc -zv localhost 80

打開瀏覽器,訪問 http://<公網(wǎng)IP>

至此,Apache安裝成功。

配置

Apache的主配置文件是 /etc/httpd/conf/httpd.conf 。其中包含如下內(nèi)容:

......
ServerRoot "/etc/httpd" # Apache的主目錄(可以看做是Apache的安裝目錄)
......
Listen 80 # 監(jiān)聽端口
......
DocumentRoot "/var/www/html" # 網(wǎng)站內(nèi)容所在
......
<IfModule dir_module>
    DirectoryIndex index.html # 當(dāng)訪問一個(gè)目錄時(shí),所訪問的默認(rèn)文件
</IfModule>
......
ErrorLog "logs/error_log" # 錯(cuò)誤日志
......
LogLevel warn # 日志級(jí)別
......
IncludeOptional conf.d/*.conf # 包含的其它配置文件

可見,網(wǎng)站的內(nèi)容是在 /var/www/html 目錄,默認(rèn)訪問的文件是 index.html 。

在該目錄下創(chuàng)建 index.html 文件,內(nèi)容是 hello world! 。在瀏覽器里訪問 http://<公網(wǎng)IP> ,實(shí)際訪問的就是該文件。

還有一個(gè)問題: /var/www/html 目錄是剛才安裝Apache時(shí)所創(chuàng)建的,這個(gè)目錄是屬于 root 賬戶的:

# ll -d /var/www/html
drwxr-xr-x 2 root root 4096 May 30  2023 /var/www/html

如果希望其它用戶能夠訪問(讀/寫)該目錄,則需要配置一下。

首先創(chuàng)建 ding 賬號(hào):

useradd -m ding # 同時(shí)創(chuàng)建 /home/ding 目錄

設(shè)置密碼:

passwd ding

如果需要,可以給 ding 賬號(hào)賦予 sudo 權(quán)限:

usermod -aG wheel ding

如果不想在 sudo 操作時(shí)輸入密碼,編輯 /etc/sudoers 文件:

visudo

添加如下內(nèi)容:

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL
ding    ALL=(ALL)       NOPASSWD: ALL # 新添加的內(nèi)容

現(xiàn)在 ding 賬號(hào)有 sudo 權(quán)限了,并且 sudo 操作不需要輸入密碼。

接下來的操作,切換到 ding 用戶:

su - ding

將用戶 ding 加入到 Apache 的組中:

sudo usermod -a -G apache ding

修改 /var/www/html 目錄的屬組和權(quán)限:

# 將 /var/www/html 的屬組改為 apache
sudo chgrp -R apache /var/www/html
# 設(shè)置權(quán)限:所有者(apache)讀寫執(zhí)行,屬組(apache)讀寫執(zhí)行,其他用戶只讀和執(zhí)行。
# g=rwx 表示給屬組賦予讀(r)寫(w)執(zhí)行(x)權(quán)限
# o=rx 表示給其他用戶賦予讀(r)和執(zhí)行(x)權(quán)限
sudo chmod -R g=rwx,o=rx /var/www/html
# 另外,還需要設(shè)置 setgid 位,保證未來新建的文件和子目錄也繼承相同的屬組
sudo chmod g+s /var/www/html

修改完畢后,需要重新登錄一下 ding 賬號(hào)。

現(xiàn)在,使用 ding 賬號(hào)就能訪問和修改 /var/www/html 目錄了。

參考

  • https://help.aliyun.com/zh/ecs/getting-started/use-the-ecs-instance-in-the-console

到此這篇關(guān)于阿里云ECS服務(wù)器安裝Apache的文章就介紹到這了,更多相關(guān)阿里云ECS安裝Apache內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

汽车| 兴安县| 成武县| 崇阳县| 开化县| 绵竹市| 库伦旗| 三江| 太谷县| 北海市| 竹溪县| 东莞市| 天气| 黑山县| 彭阳县| 尖扎县| 太白县| 乃东县| 武冈市| 嘉禾县| 临沭县| 花垣县| 漯河市| 浮梁县| 英超| 金沙县| 荣昌县| 含山县| 沁源县| 襄垣县| 东平县| 吴旗县| 三门峡市| 吉林市| 延长县| 山西省| 合作市| 孝感市| 哈密市| 彰武县| 顺昌县|