參考騰訊雲的教程html
選擇了 LAMP的方案,即Linux + Apache + MySQL + Php apache
參考連接vim
https://cloud.tencent.com/edu/learning/course-1063服務器
第一步更新系統測試
yum clean up網站
yum -y updatethis
而後安裝Apacherest
yum -y httpdcode
安裝好以後設置服務和開機啓動server
systemctl enable httpd.service
systemctl start httpd.service
啓動起來以後就能夠輸入本身的網站ip查看test頁面了。
mkdir -p /var/www/anloveslife/public_html
chown -R apache:apache anloveslife/public_html
chmod -R 755 /var/www/
vim anloveslife/public_html/index.html
<html>
<head>
<title>Hi, this is YanAn</title>
</head>
<body>
<hl>Hi, this is LiErGo</hl>
</body>
</html>
Apache配置文件,通常兩個目錄,一個是全部的配置文件,一個是主機啓用的配置文件
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled
vim知識::
進入編輯模式
i
在光標處開始進入編輯模式a
從光標位置的下一個字符開始(沒有內容時無效)進入編輯模式o
光標移動到下一行行首並進入編輯模式進入編輯模式,後直接使用shift+insert
進行粘貼。
vim /etc/httpd/conf/httpd.conf
末尾加上 IncludeOptional sites-enabled/*.conf
vim /etc/httpd/sites-available/anloveslife.conf
<VirtualHost *:80>
DocumentRoot /var/www/anloveslife/public_html
ServerName anloveslife
ErrorLog /var/www/anloveslife/error.log
CustomLog /var/www/anloveslife/requests.log combined
</VirtualHost>
軟連接 ln-s
ln -s /etc/httpd/sites-available/anloveslife.conf /etc/httpd/sites-enabled/anlovelife.conf
檢測軟鏈接
cat /etc/httpd/sites-enabled/anlovelife.conf
再檢測root目錄 用cd+ls
完成後重啓Apache apachectl restart
# httpd [ -d serverroot ] [ -f config ] [ -k start|restart|graceful|stop|graceful-stop ] ,用以啓動、關閉和從新啓動Web服務器進程
-f <設定文件> :指定配置文件
-d <服務器根目錄>: 指定服務器的根目錄
-l :顯示服務器編譯時所包含的模塊
-t :測試配置文件的語法是否正確
-M :顯示全部httpd 加載的模塊
# apachctl [ httpd-argument ] ,apachectl與httpd命令選項相似,不一樣之處可直接與下列項組合:
fullstatus:顯示服務器完整的狀態信息;
graceful:從新啓動Apache服務器,但不會中斷原有的鏈接;
help:顯示幫助信息;
restart:從新啓動Apache服務器;
start:啓動Apache服務器;
status:顯示服務器摘要的狀態信息;
stop:中止Apache服務器。