Ubuntu下安装和配置Apache2,小编觉得挺不错的,现在就分享给大家

  本篇文章主要介绍了详解Ubuntu下安装和配置Apache2,小编觉得挺不错的,现在就分享给大家,也给大家做个参考。有兴趣的朋友可以了解一下。(http://xz.8682222.com

  在Ubuntu中安装apache

  安装指令:

  sudo apt-get install apache2

  安装结束后:

  产生的启动和停止文件是:/etc/init.d/apache2

  启动:

  sudo apache2ctl -k start

  停止:

  sudo apache2ctl -k stop

  重新启动:

  sudo apache2ctl -k restart

  配置文件保存在:/etc/apache2

  需要说明的是,普通的apache发行版本配置文件是:httpd.conf

  Ubuntu发行版本的主配置文件是:apache2.conf

  在apache2.conf引用到了以下文件:

  # 包含动态模块的配置:Include /etc/apache2/mods-enabled/*.loadInclude /etc/apache2/mods-enabled/*.conf# 包含用户自己的配置:Include /etc/apache2/httpd.conf# 包含端口监听的配置:Include /etc/apache2/ports.conf# 包含一般性的配置语句片断:Include /etc/apache2/conf.d/# 包含虚拟主机的配置指令:Include /etc/apache2/sites-enabled/

  修改httpd.conf

  增加以下内容:

  ServerName 127.0.0.1:80

  ubuntu apache2配置

  1.apache2.conf 是主配置文件,httpd.conf 用户配置文件

  2.虚拟目录在 httpd.conf 中

  DocumentRoot "路径"ServerName 名称 allow from all Options +Indexes

  3.根设置(默认主目录)在 /etc/apache2/sites-available/default

  4.重启命令

  sudo /etc/init.d/apache2 restart或者cd /etc/init.dsudo apache2 -k restart

  stop 停止;start 启动5.日志文件在 /var/log/apache2/

  ServerName www.kimoqi.com DocumentRoot /home/vsftpd/kimoqi ServerName www.arwenedu.com DocumentRoot /home/vsftpd/wangguan/webapps ServerName www.arwenedu.org.cn DocumentRoot /home/vsftpd/wangguan/chem

  vi /etc/httpd/conf/httpd.conf

  在Windows下,Apache的配置文件通常只有一个,就是httpd.conf。但我在Ubuntu Linux上用apt-get install apache2命令安装了Apache2后,竟然发现它的httpd.conf(位于/etc/apache2目录)是空的!进而发现Ubuntu的 Apache软件包的配置文件并不像Windows的那样简单,它把各个设置项分在了不同的配置文件中,看起来复杂,但仔细想想设计得确实很合理。

  严格地说,Ubuntu的Apache(或者应该说Linux下的Apache?我不清楚其他发行版的apache软件包)的配置文件是 /etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如 httpd.conf等,则是通过Include指令包含进来。在apache2.conf中可以找到这些Include行:

  引用

  # Include module configuration: Include /etc/apache2/mods-enabled/*.load Include /etc/apache2/mods-enabled/*.conf# Include all the user configurations: Include /etc/apache2/httpd.conf# Include ports listing Include /etc/apache2/ports.conf……# Include generic snippets of statements Include /etc/apache2/conf.d/# Include the virtual host configurations: Include /etc/apache2/sites-enabled/

posted @ 2019-05-03 11:03  Kana酱  阅读(111)  评论(0编辑  收藏  举报