阿里云服务器(centos)用公网IP访问php项目步骤

雨点打透心脏的1/2处 2023-07-17 07:26 158阅读 0赞

阿里云服务器用公网IP访问php项目步骤

使用的框架为lumen5.6,服务器阿里云centos7,配置了路由群组。

公网IP查看的方式

1.登录阿里控制台,云服务器ECS->实例id即可查看

2.命令查看,登录服务器(Xshell,putty,小编这里用的是Ubuntu为开发环境,可以使用终端登录服务器)

curl httpbin.org/ip

1.首先在阿里云服务器搭建所需的环境lnmp,教程有很多,也可以参考小编的

https://blog.csdn.net/weixin_43713498/article/details/84139899

2.配置PHPStorm将项目上传到服务器的对应目录,小编的是/home/wwwroot

PhpStorm上传下载服务器项目配置步骤可以参考小编写的

https://blog.csdn.net/weixin_43713498/article/details/103302053

3.在/vhost目录下新建一个对应次项目的配置文件xxx.conf(有可能多个项目在一台服务器)

xxx.conf文件写法

  1. server
  2. {
  3. listen 8000;
  4. server_name 127.0.0.1;
  5. index index.html index.htm index.php default.html default.htm default.php;
  6. root /home/wwwroot/项目名称/public;
  7. #error_page 404 /404.html;
  8. # Deny access to PHP files in specific directory
  9. #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
  10. location / {
  11. try_files $uri $uri/ /index.php?$query_string;
  12. }
  13. #新增 支持php 的配置
  14. location ~ \.php$ {
  15. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  16. fastcgi_pass unix:/tmp/php-cgi.sock;
  17. fastcgi_index index.php;
  18. include fastcgi_params;
  19. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  20. }
  21. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  22. {
  23. expires 30d;
  24. }
  25. location ~ .*\.(js|css)?$
  26. {
  27. expires 12h;
  28. }
  29. location ~ /.well-known {
  30. allow all;
  31. }
  32. location ~ /\.
  33. {
  34. deny all;
  35. }
  36. access_log /home/wwwlogs/xxx.com.log;
  37. }

4.使用公网IP即可访问

ip:8000/yhadmin/p

20200320165248905.jpg

发表评论

表情:
评论列表 (有 0 条评论,158人围观)

还没有评论,来说两句吧...

相关阅读