参考: http://symfony.com/doc/current/book/page_creation.html
在学习documentation / book上的第四章creating your first page in symfony时,尝试做了一下第一个例子没有成功,又查了一些资料,发现是有配置没有做。
官方给的文档还是基于symfony2写的,symfony3的架构发生了变化,部分文件的位置也变了,导致官方提供的有些命令不太适用要相应修改一下。
参考官方给的文档:http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html
(1). 对于apache服务器配置
1. 打开wamp server,找到apache的配置文件httpd.conf
2.在httpd.conf中加入如下代码(图来自于官方手册)
80> servername domain.tld serveralias www.domain.tld documentroot /var/www/project/web var/www/project/web> allowoverride none order allow,deny allow from all mod_rewrite.c> options -multiviews rewriteengine on rewritecond %{request_filename} !-f rewriterule ^(.*)$ app.php [qsa,l] # uncomment the following lines if you install assets as symlinks # or run into problems when compiling less/sass/coffescript assets # var/www/project> # options followsymlinks # # optionally disable the rewriteengine for the asset directories # which will allow apache to simply reply with a 404 when files are # not found instead of passing the request into the full symfony stack var/www/project/web/bundles> mod_rewrite.c> rewriteengine off errorlog /var/log/apache2/project_error.log customlog /var/log/apache2/project_access.log combined
(2). 本地端口配置 通过命令行进入你所创建的项目目录,键入命令:$ php bin/ console server: start localhost: 8000 , 这步操作完成后就可以和官网教程一样,通过在地址栏输入http: // localhost:8000 来访问你的项目了。
以上配置完成后,可以成功跑官方手册上那个lucky/number的例子。
以上就介绍了php\symfony3 学习记录(二)apache服务器配置&创建第一个网页,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
