第一次安装laravel(windows集成环境下)

laravel安装

  • 网上资源很多,我是直接

    composer create-project laravel/laravel --prefer-dist

  • 然后composer install 安装所需要的安装包
  • 设置虚拟主机,目录在public下
  • 然后就报错啦

    PHP Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/default/laravel/bootstrap/autoload.php) is not within the allowed path(s): (/home/wwwroot/default/laravel/public:/tmp/:/var/tmp/:/proc/) in /home/wwwroot/default/laravel/public/index.php on line 22 PHP Warning: require(/home/wwwroot/default/laravel/bootstrap/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/default/laravel/public/index.php on line 22 PHP Fatal error: require(): Failed opening required '/home/wwwroot/default/laravel/public/../bootstrap/autoload.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/default/laravel/public/index.php on line 22

  • 然后百度发现有人跟我的一样,因为我环境用的是一键安装包(http://lnmp.org), 而vhost里的open_basedir限制了只能访问public下的文件,而laravel的index.php里要访问上一级的,所以就出错了
  • 这个问题叫open_basedir 限制站点目录防止跨站然后百度了结果

    fastcgi_param PHP_VALUE "open_basedir=$document_root:/tmp/:/proc/";

    通常nginx的站点配置文件里用了include fastcgi.conf;,这样的,把这行加在fastcgi.conf里就OK了。 如果某个站点需要单独设置额外的目录,把上面的代码写在include fastcgi.conf;这行下面就OK了,会把fastcgi.conf中的设置覆盖掉。 这种方式的设置需要重启nginx后生效。 方法2)在php.ini中加入:

    [HOST=www.]
    open_basedir=/home/www/www.iphpt.com:/tmp/:/proc/
    [PATH=/home/www/www.iphpt.com]
    open_basedir=/home/www/www.iphpt.com:/tmp/:/proc/

    这种方式的设置需要重启php-fpm后生效。 方法3)在网站根目录下创建.user.ini并写入:

    open_basedir=/home/www/www.iphpt.com:/tmp/:/proc/

    这种方式不需要重启nginx或php-fpm服务。安全起见应当取消掉.user.ini文件的写权限。 关于.user.ini文件的详细说明: http://php.net/manual/zh/configuration.file.per-user.php 设置open_basedir的同时最好禁止下执行命令的函数,比如: shell_exec('ls /etc')仍然查看到/etc目录的文件列表 shell_exec('cat /etc/passwd')仍可查看到/etc/passwd文件的内容 建议禁止的函数如下:

    disable_functions = pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority, eval, popen, passthru, exec, system, shell_exec, proc_open, proc_get_status, chroot, chgrp, chown, ini_alter, ini_restore, dl, pfsockopen, openlog, syslog, readlink, symlink, popepassthru, stream_socket_server, fsocket, chdir
  • 我用的方法是 第一种,直接在 一键环境里 /usr/local/nginx/conf/vhost/你的虚拟主机.conf 里 直接添加第一句 就行了
  • 接着,访问虚拟主机,出现500..............
  • 解决方案,要把storage这个目录权限改为777 即chmod -R 777 storage
  • ok laravel装好了

欢迎转载,但请附上原文地址哦,尊重原创,谢谢大家 本文地址: http://www.iphpt.com/detail/9/

当你能力不能满足你的野心的时候,你就该沉下心来学习