阿里云服务器用公网IP访问php项目步骤
使用的框架为lumen5.6,服务器阿里云centos7,配置了路由群组。
公网IP查看的方式
1.登录阿里控制台,云服务器ECS->实例id即可查看
2.命令查看,登录服务器(Xshell,putty,小编这里用的是Ubuntu为开发环境,可以使用终端登录服务器)
curl httpbin.org/ip
1.首先在阿里云服务器搭建所需的环境lnmp,教程有很多,也可以参考小编的
Linux安装msyql+php+nginx+redis_太阳上的雨天的博客-
2.配置PHPStorm将项目上传到服务器的对应目录,小编的是/home/wwwroot
PhpStorm上传下载服务器项目配置步骤可以参考小编写的
PhpStorm上传下载服务器项目配置步骤_太阳上的雨天的博客-
3.在/vhost目录下新建一个对应次项目的配置文件xxx.conf(有可能多个项目在一台服务器)
xxx.conf文件写法
server
    {
        listen 8000;
        server_name 127.0.0.1;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/项目名称/public;
        #error_page   404   /404.html;
        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
                location / {
                    try_files $uri $uri/ /index.php?$query_string;
                }
        #新增 支持php 的配置
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
                include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }
        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }
        location ~ /.well-known {
            allow all;
        }
        location ~ /\.
        {
            deny all;
        }
        access_log  /home/wwwlogs/xxx.com.log;
    }4.使用公网IP即可访问
ip:8000/yhadmin/p











