对Apache2进行简单配置

Apache2

  1.安装Apache2 

sudo apt-get update

sudo apt-get install apache2

  2.启动服务

sudo  /etc/init.d/apache2 start  # start | restart | stop
或
service apache2 start | restart | stop

  3.配置虚拟站点

  在sites-available目录下配置自己的虚拟站点

cd /etc/apache2/sites-available

  进入sites-avaliable目录后,有两个默认的配置文件

ls

000-default.conf  default-ssl.conf

  对 000-default.conf 进行复制,重命名为自己的域名,但是后缀必须是.conf

cp 000-default.conf  www.91porn.com

  进入自己的的配置文件进行配置

<VirtualHost *:80>
    
ServerName www.91porn.com   #站点域名
  
DocumentRoot /var/www/www.91porn.com   #站点根目录
 
</VirtualHost>

#基本配置,根据需求在此基础上修改

  进入apache2目录下的sites-enabled目录,创建软连接

cd ../sites-enabled

ln -s ../sites-available/www.91porn.com.conf  www.91porn.com.conf

  (更具需求可以修改主配置文件,主配置文件为apache2目录下的apache2.conf)

  重启apache服务,如果不报错就表示配置成功

sudo  /etc/init.d/apache2 start  # start | restart | stop
或
service apache2 start | restart | stop

   配置虚拟站点

cd /var/www/blog

vim index.html #编辑html文件

  在linux下设置域名解析

sudo vim  /etc/hosts

127.0.0.1 www.blog.com

  在windows下设置域名解析

C:\Windows\System32\drivers\etc\ 编写hosts文件

IP地址(站点主机名) www.blog.com

 

  

 

  

猜你喜欢

转载自www.cnblogs.com/huiyichanmian/p/10079555.html
今日推荐