Ubuntu apache2 虚拟主机配置

1、2个文件夹

/etc/apache2/sites-avaliable/ 才是配置文件目录
/etc/apache2/sites-enabled/ 配置文件创建软连接到这个目录下,配置文件才生效

2、 创建配置文件

在sites-avaliable目录下

sudo cp 000-default.conf  gongsc.conf  #gongsc.conf 自己配置文件名

3、修改配置文件:gongsc.conf 只贴需要修改的代码

#域名
ServerName www.gongsc.com

ServerAdmin webmaster@localhost

#入口文件目录
DocumentRoot /var/www/gongsc/public

ErrorLog /var/www/html/gongsc/error.log

CustomLog /var/www/html/gongsc/access.log combined

<Directory "/var/www/gongsc/public">

    Options FollowSymLinks

    DirectoryIndex index.php index.html index.htm

    #注意这个地方的配置,会影响本地目录下的.htaccess的启用。使用 All
    AllowOverride All 

    Order deny,allow

    Allow from All

</Directory>

4、创建链接使配置文件生效

sudo ln -s /etc/apache2/sites-available/gongsc.conf /etc/apache2/sites-enabled/gongsc.conf

5、重启Apache服务器

sudo service apache2 restart

6、修改hosts(/etc/hosts)

127.0.0.1  www.gongsc.com

7、如果需要对目录级的URL重写支持,安装模块rewrite_module

sudo a2enmod rewrite

ps:安装模块rewrite_module后,运行项目就不会出现 The requested URL /regiser was not found on this server.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值