티스토리 뷰

laravel

Laravel 프로젝트 생성 가이드

서니짱 2025. 10. 8. 09:42
반응형

Laravel 프로젝트 생성 가이드

1. 기본 환경 설정

필요한 패키지 설치

 
 
bash
# PHP, Composer, Nginx 설치
sudo apt update
sudo apt install php8.2 php8.2-fpm php8.2-mysql php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip unzip nginx

Composer 설치

 
 
bash
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

2. Laravel 프로젝트 생성

 
 
bash

 

# 프로젝트 생성
composer create-project laravel/laravel site

# 프로젝트 디렉토리로 이동
cd site

# 권한 설정
sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache

3. Nginx 설정

/etc/nginx/sites-available/site

 
 
nginx
server {
    listen 80;
    server_name site.local;
    root /var/www/site/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.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Nginx 활성화

 
 
bash
sudo ln -s /etc/nginx/sites-available/site /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

4. 환경 설정

.env 파일 설정

 
 
env
APP_NAME=Site
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://site.local

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=site
DB_USERNAME=root
DB_PASSWORD=

키 생성

 
 
bash
php artisan key:generate

완료! 추가로 필요한 설정 있으면 말씀해주세요.

반응형
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2026/05   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함
반응형