问题
I had just upgraded to Ubuntu 13.10 earlier today. The version of Apache2 is 2.4.6 now. I removed the old site config file and tried to create a new one. When I was trying to copy default.conf, I found the format had been changed significantly. And here is an example of the new conf file. As lots of people do, I also have the forbidden problem even if I set my folder permission to 777.
1 <VirtualHost *:80>
2 # The ServerName directive sets the request scheme, hostname and port th at
3 # the server uses to identify itself. This is used when creating
4 # redirection URLs. In the context of virtual hosts, the ServerName
5 # specifies what hostname must appear in the request's Host: header to
6 # match this virtual host. For the default virtual host (this file) this
7 # value is not decisive as it is used as a last resort host regardless.
8 # However, you must set it for any further virtual host explicitly.
9 ServerName www.janicezhang.me
10
11 ServerAdmin webmaster@localhost
12 DocumentRoot /home/yifan/www/janice
13
14 # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
15 # error, crit, alert, emerg.
16 # It is also possible to configure the loglevel for particular
17 # modules, e.g.
18 #LogLevel info ssl:warn
19
20 ErrorLog ${APACHE_LOG_DIR}/error.log
21 CustomLog ${APACHE_LOG_DIR}/access.log combined
22
23 # For most configuration files from conf-available/, which are
24 # enabled or disabled at a global level, it is possible to
25 # include a line for only one particular virtual host. For example the
26 # following line enables the CGI configuration for this host only
27 # after it has been globally disabled with "a2disconf".
28 #Include conf-available/serve-cgi-bin.conf
29 </VirtualHost>
I am just wondering if there is some toturial to set up virtual host for apache 2.4.6 in ubuntu 13.10. Thanks.
回答1:
OK, I solved the problem by myself. Two things need to be done. First, add lines in your site config file like this:
<Directory "/home/yifan/www/janice">
Options ExecCGI
AllowOverride all
Require all granted
</Directory>
After this, I can browse into the site without the forbidden error. However, the php file is displayed as plain text. I check the folder mods-enabled and find php5 is not here. I have no idea why php5 is lost during upgrading. So just reinstall it by
sudo apt-get install libapache2-mod-php5
Then, the site is recovered.
来源:https://stackoverflow.com/questions/19697041/new-site-conf-file-for-apache-2-4-6