把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