• Centos6.5中 一键安装LNMP 安装Yii2.0 手工配置


    1、一键安装LNMP

    cd /usr
    wget -c http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz 
    tar zxf lnmp1.2-full.tar.gz 
    cd lnmp1.2-full 
    ./install.sh lnmp

    进入安装状态后按照提示做安装选择( 参考 http://lnmp.org/install.html )

     2、安装Yii2.0 

    a 先安装好composer

    //进入/usr目录
    curl -sS https://getcomposer.org/installer | php
    //移动(mv)composer到/usr/local/bin/ 并让它全局可执行(sudo)
    sudo mv composer.phar /usr/local/bin/composer

    b 然后在 /home/wwwroot 目录中运行 (参考 http://www.yiichina.com/doc/guide/2.0/start-installation)

    composer global require "fxp/composer-asset-plugin:~1.0.0"
    composer create-project --prefer-dist yiisoft/yii2-app-basic basic

    可能的错误:

    [SymfonyComponentProcessExceptionRuntimeException]
    The Process class relies on proc_open, which is not available on your PHP installation.

    解决办法:vim php.ini 查找proc,把禁用函数列表中proc相关的两个函数删除即可解决

    c 出现:

    > yiicomposerInstaller::postCreateProject

    chmod('runtime', 0777)...done.
    chmod('web/assets', 0777)...done.
    chmod('yii', 0755)...done.

    就安装好了

    安装过程中可能提示:

    Could not fetch https://api.github.com/repos/RobinHerbots/jquery.inputmask/contents/bower.json?ref=4551607fef63fd4bcd675479a8c347b668b915eb, please create a GitHub OAuth token to go over the API rate limitHead to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+localhost.localdomain+2015-12-24+1743to retrieve a token. It will be stored in "/root/.composer/auth.json" for future use by Composer.Token (hidden):

    是要Github验证,参考http://www.cnblogs.com/jiufen/p/5073887.html即可

    d 检查一下看看下载的文件,确实安装好了

    [root@localhost wwwroot]# ll
    total 16
    drwxr-xr-x. 13 root root 4096 Dec 24 18:05 basic
    drwxr-xr-x. 11 root root 4096 Dec 24 16:33 blog
    drwxr-xr-x. 3 www www 4096 Dec 24 15:52 default
    drwxrwxrwx. 13 root root 4096 Dec 24 15:53 yiibasic
    [root@localhost wwwroot]# cd basic
    [root@localhost basic]# ll
    total 104
    drwxr-xr-x. 2 root root 4096 Aug 6 06:23 assets
    drwxr-xr-x. 2 root root 4096 Aug 6 06:23 commands
    -rw-r--r--. 1 root root 1637 Aug 6 06:23 composer.json
    -rw-r--r--. 1 root root 32056 Dec 24 18:05 composer.lock

    3、手工配置基于域名的虚拟主机

    a 打开/usr/local/nginx/conf/nginx.conf文件,复制 server{} 整体,粘贴在它的下面,修改部分见代码的注释

    server
        {
            listen 80;
            #listen [::]:80 default_server ipv6only=on;
            server_name www.blog.com;
            index index.html index.htm index.php;
            root  /home/wwwroot/blog/public;
    
    
            #error_page   404   /404.html;
            include enable-php.conf;
    
            location /nginx_status
            {
                stub_status on;
                access_log   off;
            }
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }
    
            location ~ .*.(js|css)?$
            {
                expires      12h;
            }
    
            location ~ /.
            {
                deny all;
            }
    
            access_log  /home/wwwlogs/access.www.blog.com.log  access;
        }
    
    server
        {
            listen 80;
            #listen [::]:80 default_server ipv6only=on;
            server_name www.basic.com;//虚拟域名!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            index index.html index.htm index.php;
            root  /home/wwwroot/basic/web;//网站index.php目录,一定要注意不是根目录,而且要有访问权限(yii2.0不用调整权限了可忽略)!!!!!!!!!!
    
    
            #error_page   404   /404.html;
            include enable-php.conf;
    
            location /nginx_status
            {
                stub_status on;
                access_log   off;
            }
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }
    
            location ~ .*.(js|css)?$
            {
                expires      12h;
            }
    
            location ~ /.
            {
                deny all;
            }
    
            access_log  /home/wwwlogs/access.www.basic.com.log  access;//日志文件的位置!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        }

    b 重启服务器

    service nginx restart    

    用这个方式可以查找相关服务的位置,如果在/usr/bin/中有,就可以在任何地方直接执行这个服务相关的命令

    [root@localhost web]# whereis nginx
    nginx: /usr/bin/nginx /usr/local/nginx
    [root@localhost web]#

    c 在本机注册这个域名(这个不注册也可以啊,有点奇怪)

    vim /etc/hosts

    在文件中加入

    127.0.0.1 www.basic.com

    在本机(nginx主机)浏览器访问www.basic.com即可看到yii2.0的主页

    可能的错误

    Invalid Parameter – yiiaseInvalidParamException
    The file or directory to be published does not exist: /home/wwwroot/basic/vendor/bower/jquery/dist

    解决办法(然而,并不靠谱,试过不行,但在新系统中,先执行这里的命令在安装yii就没有错误)

    composer self-update 1.0.0-alpha11
    composer clear-cache

    参考 http://www.yiichina.com/topic/6077

  • 相关阅读:
    Android大牛
    在学习oauth时学到的
    using-jade-and-grunt-to-speed-up-html-production
    build-your-microservices-api-with-swagger
    json-web-token-apache-shiro
    WebSocket对象特性和方法
    芝麻教程
    how to export multiple SVG graphics in illustrator
    直播后台
    关于在chrome中响应不出现在XHR里的远影
  • 原文地址:https://www.cnblogs.com/jiufen/p/5073892.html
Copyright © 2020-2023  润新知