Yêu cầu thg 10 5, 2022 4:06 CH 274 2 3
  • 274 2 3
0

laravel không chạy

Chia sẻ
  • 274 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 CÂU TRẢ LỜI


Đã trả lời thg 10 12, 2022 2:24 SA
Đã được chấp nhận
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.

Chia sẻ
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 ạ?

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;
    }
}
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é.

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

thg 10 17, 2022 1:36 SA

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

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

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

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 😅

Đã trả lời thg 10 6, 2022 2:28 SA
0

webserver

Chia sẻ
Đã trả lời 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
Chia sẻ
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ỉ?

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí