【发布时间】:2022-01-05 23:21:59
【问题描述】:
我目前正在将一个 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 - 也没有用。
/etc/apache2/sites-available/ 中的我的 conf 文件如下所示:
名称虚拟主机 *: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.
我不明白为什么文档根目录是错误的,应该是正确的
【问题讨论】:
标签: php laravel apache ubuntu deployment