Asked thg 10 5, 2022 4:06 CH 217 2 3
  • 217 2 3
0

laravel không chạy

Share
  • 217 2 3

Mọi người cho mình hỏi làm sao khi mình chạy dự án laravel trên laragon nó bị chỉ hiện cây thư mục như hình ạ?

image.png

Làm sao để sửa ạ? Thanks.

3 ANSWERS


Answered thg 10 12, 2022 2:24 SA
Accepted
0

Bạn dùng Nginx hay Apache, bạn check lại config của hai cái đó xem, có thể bạn chưa trỏ root của web server vào thư mục /public.

Share
Avatar TMH @hoang55dd
thg 10 14, 2022 8:48 SA

Em hiện dùng nginx. Làm sao để biết nó trỏ vào thư mục /public chưa ạ?

0
| Reply
Share
thg 10 14, 2022 10:01 SA

@hoang55dd Bạn tham khảo: https://laravel.com/docs/9.x/deployment#nginx

server {
    listen 80;
    listen [::]:80;
    server_name example.com;
    root /srv/example.com/public;
 
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
 
    index index.php;
 
    charset utf-8;
 
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
 
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
 
    error_page 404 /index.php;
 
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
 
    location ~ /\.(?!well-known).* {
        deny all;
    }
}
0
| Reply
Share
thg 10 14, 2022 10:04 SA

Dòng root /srv/example.com/public; là dòng cấu hình thư mục root của web. Với laravel là thư mục public nhé.

0
| Reply
Share
Avatar TMH @hoang55dd
thg 10 15, 2022 2:40 SA

@huukimit nó trỏ đúng rồi ạ. my-laravel.test dùng được nhưng khi trỏ trên localhost\my-laravel bị vẫn vậy

0
| Reply
Share
thg 10 17, 2022 1:36 SA

@hoang55dd Bạn show file config của bạn mình xem.

0
| Reply
Share
Avatar TMH @hoang55dd
thg 10 20, 2022 9:34 SA

@huukimit Đây ạ

server {
    listen 80;
    listen 8443 ssl;
    server_name web-laravel.test *.web-laravel.test ;
    root "D:/Workspace/laragon/www/web-laravel/public";
    
    index index.html index.htm index.php;
 
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
		autoindex on;
    }
    
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass php_upstream;		
        #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    # Enable SSL
    ssl_certificate "D:/Workspace/laragon/etc/ssl/laragon.crt";
    ssl_certificate_key "D:/Workspace/laragon/etc/ssl/laragon.key";
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;
	
	
    charset utf-8;
	
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    location ~ /\.ht {
        deny all;
    }
}

# This file is auto-generated.
# If you want Laragon to respect your changes, just remove the [auto.] prefix

0
| Reply
Share
Avatar NDT Caris @caris0132
thg 10 21, 2022 4:54 SA

@hoang55dd

root "D:/Workspace/laragon/www/web-laravel/public";

Dòng trên cấu hình chạy file index tại thư mục web-laravel/public Nên nếu chạy bằng localhost thì trỏ đến thư mục public mà chạy : link: localhost/web-laravel/public/ or localhost/web-laravel/public/index.php

0
| Reply
Share
Avatar TMH @hoang55dd
thg 10 28, 2022 8:17 SA

@caris0132 Chạy được localhost/web-laravel/public/ rồi ạ. Không hiểu sao bữa em chỉ cần chạy localhost/web-laravel/ là được 😅

0
| Reply
Share
Answered thg 10 6, 2022 2:28 SA
0

webserver

Share
Answered thg 10 7, 2022 11:48 SA
0
  • Bạn đã chạy composer install chưa.
  • Trên giao diện laragon thử restart lại apache
  • Trên giao diện laragon setting xem port của apache đúng chưa nếu khác 80 (vd: 85) bạn phải nhập vào địa chỉ là: http://my-domain.test:85
Share
Avatar TMH @hoang55dd
thg 10 8, 2022 2:37 SA

Em chạy trên thì được my-laravel.test được rồi nhưng sao lên localhost\my-laravel\ lại bị lỗi nhỉ?

0
| Reply
Share
Viblo
Let's register a Viblo Account to get more interesting posts.