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

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