安装yii2碰到的问题总结

Yii2 2018-06-06 浏览(2226 评论(0

安装yii遇到的常见问题

在用composer安装yii框架时候,当出现The Process class relies on proc_open, which is not available on your PHP installation.这个问题

在php.ini中,找到disable_functions选项,看看后面是否有proc_open函数被禁用了,如果有的话,去掉即可,disable_functions中proc_open,proc_get_status去掉,http://www.cnblogs.com/crisenchou/p/6237781.html

yii安装好后,如果打不开页面,不报错,出现500错误,把php error log打开

find / -name "php.ini"
vim /usr/local/php/etc/init.d/php.ini->把display_error=Off改成On
重启php-->/etc/init.d/php-fpm restart

当遇到下面错误时候,是自动加载文件没有加载进来,需要composer update

Warning: require(/home/www/yii2-blog/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php): failed to open stream: No such file or directory in /home/www/yii2-blog/vendor/composer/autoload_real.php on line 66
Fatal error: require(): Failed opening required '/home/www/yii2-blog/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php' (include_path='.:') in /home/www/yii2-blog/vendor/composer/autoload_real.php on line 66

当打开PHP error后,出现open_basedir restriction in effect问题

这个问题说明你修改了yii安装目录,没有安装在wwwroot中,此时找到fastcgi.conf
find / -name "fastcgi.conf"
vim /usr/local/nginx/conf/fastcgi.conf最后一行把$document_root修改成你的代码目录
fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/www/hxq/:/tmp/:/proc/";
重启nginx-->/usr/local/nginx/sbin/nginx -s reload

yii url优化问题->Nginx.conf在serverz中添加

    #yii框架使用代码
    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php?$args;
    }

安装fxp/composer-asset-plugin

这步我费了好大力气才搞定的,Yii2就是安装“fxp/composer-asset-plugin”插件。
composer global require "fxp/composer-asset-plugin:~1.1"

上面的是官网的命令,我使用该命令一直无法成功。我是使用的下面的命令才成功
composer global require "fxp/composer-asset-plugin:@dev"

https://github.com/myloveGy/yii2-ace-admin

yii访问后台页面出现The file or directory to be published does not exist: /home/www/test/vendor/bower/bootstrap/dist

只要对定义 @bower的地方做下修改就好了。

vim vendor/yiisoft/yii2/base/Application.php

public function setVendorPath($path)
{
    $this->_vendorPath = Yii::getAlias($path);
    Yii::setAlias('@vendor', $this->_vendorPath);
    //Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower');注释掉
    Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . 'bower-asset');
    Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm');
}


打赏

如果此文对你有所帮助,请随意打赏鼓励作者^_^

黄信强博客