While looking at one of Laravel's introductory tutorials, the author writes:
Configure the Web site root directory as learnlaravel5/public.
In itself, the root directory for Linux under Apache is set to /var/www/html
, while the access directory for Laravel settings is learnlaravel5/public
. Directly under the root directory, the access to hit time need to enter a long string, too cumbersome. So think about also configure, like the author, input www.nine.com
can also be accessed.
1. Modify Httpd.conf
You can add a virtual domain name to Apache by adding the following code directly at the end of the Apache configuration file:
NameVirtualHost *:80<VirtualHost *:80> ServerName www.nine.com DocumentRoot "/var/www/html/learnlaravel/public" <Directory "/var/www/html/learnlaravel/public"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory></VirtualHost>
Of course, a better approach would be to put the above code in a custom file, such as learnlaravel.comf
, and then learnlaravel.comf
include it httpd.conf
in.
2. Modify the Hosts file
Added in hosts127.0.0.1 www.nine.com
Here the method is only suitable for the local test, the release, the corresponding modification.
Reference: http://blog.sina.com.cn/s/blog_94f216d10101l5h6.html
Linux under Apache server configuration virtual domain name