Ubuntu 中 Apache2 安装、配置及卸载

一、 安装

 命令:

sudo apt-get update
sudo apt-get update

 

二、 配置

(1)apache2 默认的几个配置文件:

  • /etc/apache2/apache2.conf 是主要配置文件(这个文件的末尾可以看到,include了其它所有的配置文件)。
  • /etc/apache2/ports.conf 始终包含在主配置文件中。它用于确定传入连接的侦听端口,默认为80,我们一般都会重新配置新的端口。
  • 其它配置文件在 /etc/apache2/sites-enabled,/etc/apache2/conf-enabled,/etc/apache2/mods-enabled 目录下。
  • apache2的默认web目录:/var/www/html。(在/etc/apache2/sites-enabled/000-default.conf 里可以看到这个 DocumentRoot /var/www/html 配置)
  • apache2 的默认用户是 www-data,定义在 /etc/apache2/envvars 文件中。
  • 设置默认主页的配置文件/etc/apache2/mods-enabled/dir.conf

(2)修改端口

  • 修改它的监听端口

    sudo vim /etc/apache2/ports.conf

    Ubuntu 中 Apache2 安装、配置及卸载

     

     

  • 修改它的主机端口

    sudo vim /etc/apache2/sites-available/000-default.conf

    Ubuntu 中 Apache2 安装、配置及卸载

     

     

(3)apache2 的几个简单命令:启动、停止、重启、状态

sudo /etc/init.d/apache2 [ start | stop | restart | status ]
service apache2 [ start | stop | restart | status ]

(4)apache2配置成功页面

Ubuntu 中 Apache2 安装、配置及卸载

 

 

三、卸载

sudo apt-get –purge remove apache2
sudo apt-get –purge remove apache2-common
sudo apt-get –purge remove apache2-utils
sudo apt-get autoremove apache2

注: –purge 是不保留配置文件的意思

删掉/etc/apache2文件夹:

sudo rm -rf /etc/apache2

 

删掉/var/www文件夹:

sudo rm -rf /var/www

 

删掉/etc/init.d/apache2文件:

sudo rm -rf /etc/init.d/apache2

 

 

 

Ubuntu 中 Apache2 安装、配置及卸载

上一篇:记录刷题--web前端


下一篇:centos7编辑安装mysql