ubuntu Lamp环境开启伪静态

**在ubuntu 下的设置方法为:** **1.先执行加载rewrite模块** **```** **sudo a2enmod rewrite** **```** **2.打开Apache2.conf** **```** sudo vi /etc/apache2/apache2.conf ``` **> 重启Apache服务:service apache2 restart  或 sudo /etc/init.d/apache2 restart(可看到重启结果)** **** ****然后在/etc/apache2/apache2.conf   中166行 **** **## 寻找到下一段代码 ##** **```** ** Options Indexes FollowSymLinks        ** ** AllowOverride  None** ** Require all granted** **```** **** **改为** **```** Options Indexes FollowSymLinks AllowOverride All Require all granted ``` ![](http://upload-images.jianshu.io/upload_images/2665727-aabe027959f4877c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 注意:如果有开两个虚拟服务器的话这边设置完成后,服务器上面的虚拟主机都会开启了伪静态。 3.将站点根目录上传编辑好的.htaccess 这个文件一般情况写整列就OK了! 4.其实这一步不算一步!因为设置好了要重启一下服务! ##最后重启服务## > service apache2 restart在ubuntu 下的设置方法为:

1.先执行加载rewrite模块

```

sudo a2enmod rewrite

```

2.打开Apache2.conf

```

sudo vi /etc/apache2/apache2.conf

```

> 重启Apache服务:service apache2 restart  或 sudo /etc/init.d/apache2 restart(可看到重启结果)


然后在/etc/apache2/apache2.conf   中166行 

## 寻找到下一段代码 ##

```

 Options Indexes FollowSymLinks        

 AllowOverride  None

 Require all granted

```


改为

```

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

```

ubuntu Lamp环境开启伪静态_第1张图片

注意:如果有开两个虚拟服务器的话这边设置完成后,服务器上面的虚拟主机都会开启了伪静态。

3.将站点根目录上传编辑好的.htaccess 这个文件一般情况写整列就OK了!

4.其实这一步不算一步!因为设置好了要重启一下服务!

##最后重启服务##

> service apache2 restart

你可能感兴趣的:(ubuntu Lamp环境开启伪静态)