PHP7编什么程

yii入门

2020-02-06  本文已影响0人  沙蒿同学

疫情尚在,宅家里憋得慌,然yii框架早有耳闻,故花了点时间看了yii2.0安装文档,在虚拟机上搭建了起来。教程写给有一定php基础的大朋友看的,在看此教程前你需掌握以下技术点:

安装yii

安装yii很简单,使用composer一行命令搞定。

composer create-project --prefer-dist yiisoft/yii2-app-basic basic

这将在一个名为 basic 的目录中安装Yii应用程序模板的最新稳定版本。
启动yii,默认情况下Https-server将监听8080

php yii serve

配置环境

nginx 配置:在/etc/nginx/conf.d新增一个yiiBasic.conf配置,内容如下:

server {
    charset utf-8;
    client_max_body_size 128M;

    listen 8080; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    server_name 127.0.0.1;
    root        /vagrant/yii/basic/web;
    index       index.php;

    access_log  /vagrant/yii/basic/log/access.log;
    error_log   /vagrant/yii/basic/log/error.log;

    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php$is_args$args;
    }

    # uncomment to avoid processing of calls to non-existing static files by Yii
    #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    #    try_files $uri =404;
    #}
    #error_page 404 /404.html;

    # deny accessing php files for the /assets directory
    location ~ ^/assets/.*\.php$ {
        deny all;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fastcgi_pass 127.0.0.1:9000;
        #fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        try_files $uri =404;
    }

    location ~* /\. {
        deny all;
    }
}

mysql如果忘记了密码,需要重置下密码,可参考mysql重置密码navicat连接mysqlMariaDB管理MySQL

结果图

image.png
上一篇 下一篇

猜你喜欢

热点阅读