把PHP项目(yii2)放入阿里云ECS(linux,LNMP)

1、在ECS上修改nginx配置

1.1输入:vi /etc/nginx/nginx.conf,按i键修改文件,替换部分如下:

server {

    listen 80; 

    server_name localhost; 

    index index.php index.html; 

    error_log /data/logs/dm.error.log; 

    access_log /data/logs/dm.access.log; 

    root /etc/nginx/html; 

#项目所在路径,例:我的项目是MMS,路径 /etc/nginx/html/MMS

    #nginx  header头信息的下划线支持 

    underscores_in_headers on; 



    location / { 

        try_files $uri $uri/ /index.php$is_args$args; 

    } 



    location ~ \.php { 

        try_files $uri =404; 

        fastcgi_split_path_info ^(.+\.php)(/.+)$; 

        include fastcgi_params; 

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

        fastcgi_param SCRIPT_NAME $fastcgi_script_name;fastcgi_param RUN_ENV development; 

        fastcgi_index index.php; 

        fastcgi_pass 127.0.0.1:9000; 

    } 

}

1.2、按esc输入::wq并按回车保存且退出

2、把项目权限改为777

2.1到项目所在目录:cd  /etc/nginx/html

2.2修改权限:chmod -R 777 MMS(MMS是我的项目)


3、在浏览器输入阿里云ECS的外网+index.php路径,就访问自己的项目啦

例:http://33.96.58.222/MMS/frontend/web/index.php

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • [toc] 在公司的网站上推荐使用 docker 容器来安装环境,一个项目一个 docker 容器。 、、 百度百...
    Mdvtrw阅读 1,523评论 0 1
  • CGI 通用网关接口(Common Gateway Interface)是一个Web服务器主机提供信息服务的标准接...
    没我找不到电子书阅读 1,970评论 1 4
  • Nginx简介 解决基于进程模型产生的C10K问题,请求时即使无状态连接如web服务都无法达到并发响应量级一万的现...
    魏镇坪阅读 2,090评论 0 9
  • 常用命令 查看系统版本: head -n 1 /etc/issue lsb_release-a (centos ...
    Notonlyphper阅读 1,992评论 1 4
  • 相对于昨天,自己脑子里还一片混沌,思绪混乱,经过今天一天,现在坐下来静静思考,感觉渐渐清晰了许多,终其原因,好像是...
    希亚阅读 426评论 0 0