ubuntu部署Apache發佈網站

今天自己往服務器上部署了一個網站,記錄一下做法。
①首先要獲取服務器的root權限
②控制檯輸入:apt-get install apache2
③把網站源碼通過FTP上傳到/var/www
④控制檯輸入:sudo vim /etc/apache2/sites-available/000-default.conf修改配置文件
⑤修改www/後面的名稱,就是你文件夾的名稱

⑥修改完之後控制檯輸入:sudo /etc/init.d/apache2 restart重啓Apache
⑦在服務內部可以輸入localhost或者127.0.0.1,在公網就輸入公網IP就可以了。

Linux下修改Apache默認首頁

修改路徑
$ sudo vim /etc/apache2/sites-available/000-default.conf

ServerAdmin webmaster@localhost
DocumentRoot /var/www/LYXF(展示首頁所在的路徑)

添加自己的主頁.
$ sudo vim /etc/apache2/mods-enabled/dir.conf
在index.html 前添加 home.html (home.html是你自己的主頁)
1、修改默認網站目錄
ubuntu8.10下修改apache2的默認文檔目錄默認是在/var/www裏面

sudo gedit /etc/apache2/sites-enabled/000-default

在文檔中找到DocumentRoot 在後面修改你要放置網頁文件的目錄。

修改完了別忘記重啓apache2服務器
命令: sudo/etc/init.d/apache2 restart

2、修改默認主頁
修改默認主頁:一般在 sudo gedit/etc/apache2/apache2.conf裏面
找到 DirectoryIndex 在後面添加如index.php等
不過隨apache2的版本不同文件的放置位置不一樣我在ubuntu8.10下面配置文件就不一樣。
別怕輸入這個命令 grep -iRDirectoryIndex /etc/apache2
查看 DirectoryIndex 在apache2那個文件裏面。
我的就是這樣的
/etc/apache2/mods-enabled/dir.conf: DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
/etc/apache2/mods-available/dir.conf: DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
爲什麼所2個文件都有呢。我也不清楚不過我在羣裏有高手說了其實2個文件關係是上面那個是下面那個的符號鏈接,還是一樣的。隨便添加默認文檔就可以了

重啓Apache
service apache2 restart

Task: Start Apache 2 Server /啓動apache服務

/etc/init.d/apache2 start

or
$ sudo /etc/init.d/apache2 start
Task: Restart Apache 2 Server /重啓apache服務

/etc/init.d/apache2 restart

or
$ sudo /etc/init.d/apache2 restart
Task: Stop Apache 2 Server /停止apache服務

/etc/init.d/apache2 stop

or
$ sudo /etc/init.d/apache2 stop

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章