gpt4 book ai didi

php - 从 localhost 更改为服务器 IP 不起作用

转载 作者:行者123 更新时间:2023-12-04 18:48:16 24 4
gpt4 key购买 nike

我目前正在将一个 laravel 应用程序部署到一个 ubuntu 虚拟机,经过一番头疼后它终于工作了,我可以在运行 php artisan serve 后看到 127.0.0.1:8000 中的网站! :)
但是,我尝试将地址从 localhost 更改为服务器的 IP。
我的 ´/etc/hosts` 文件如下所示:

127.0.0.1 localhost
132.231.36.101 laravel.dev
127.0.1.1 lehner-grund01
我还尝试将 127... 地址作为一个整体删除,但它并没有改变任何东西。
在我的 .env文件我有这个:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=<my_key>
APP_DEBUG=true
APP_URL=http://132.231.36.101
我尝试更改 ServeCommand.php 中的 IP文件以及 - 也没有工作。
我的 conf文件在 /etc/apache2/sites-available/看起来像这样:
名称虚拟主机 *:8080
听8080
<VirtualHost *:8080>
ServerAdmin admin@example.com
ServerName laravel.dev
ServerAlias www.laravel.dev
DocumentRoot grup1/project/tose-gruppe-1/public

<Directory /home/user/projects/laravel_project/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>

LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我尝试在运行 php artisan serve 时“手动”执行此操作像这样添加主机: php artisan serve --host=<my_ip> --port这是我第一次在 ubuntu 机器上部署一些东西,我已经完成了哈哈。现在尝试了七个小时,任何帮助表示赞赏!
编辑:
使用状态命令时的消息:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-01-05 21:43:04 UTC; 1h 59min ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 47274 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Process: 48577 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
Main PID: 47278 (apache2)
Tasks: 8 (limit: 4575)
Memory: 17.2M
CGroup: /system.slice/apache2.service
├─47278 /usr/sbin/apache2 -k start
├─48581 /usr/sbin/apache2 -k start
├─48582 /usr/sbin/apache2 -k start
├─48583 /usr/sbin/apache2 -k start
├─48584 /usr/sbin/apache2 -k start
├─48585 /usr/sbin/apache2 -k start
├─48820 /usr/sbin/apache2 -k start
└─48826 /usr/sbin/apache2 -k start

Jan 05 21:43:04 lehner-tse01 systemd[1]: Starting The Apache HTTP Server...
Jan 05 21:43:04 lehner-tse01 apachectl[47277]: AH00112: Warning: DocumentRoot [/var/www/html/tose-gruppe-1/public] does not exist
Jan 05 21:43:04 lehner-tse01 systemd[1]: Started The Apache HTTP Server.
Jan 05 22:03:58 lehner-tse01 systemd[1]: Reloading The Apache HTTP Server.
Jan 05 22:03:58 lehner-tse01 apachectl[48580]: AH00112: Warning: DocumentRoot [/var/www/html/tose-gruppe-1/public] does not exist
Jan 05 22:03:58 lehner-tse01 apachectl[48580]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabl>
Jan 05 22:03:58 lehner-tse01 apachectl[48580]: AH00112: Warning: DocumentRoot [/etc/apache2/grup1/project/tose-gruppe-1/public] does not exist
Jan 05 22:03:58 lehner-tse01 systemd[1]: Reloaded The Apache HTTP Server.
我不明白为什么文档根目录是错误的,应该是正确的

最佳答案

APP_URL=http://132.231.36.101 不必更改为公共(public)地址,因为当您将端口 80 转发到您的服务器时,它会自动重定向到您的服务器。意思是它去本地主机。不需要公共(public)地址

关于php - 从 localhost 更改为服务器 IP 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70600741/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com