본문 바로가기

php 헛다리/Laravel9 헛다리

라라벨9 설치

728x90

 

환경

virtualBox에 centos7설치 (php8.2 , apache , mariadb)


1. Composer 설치

Composer : PHP의 의존성 관리도구이다. 라라벨 프레임워크를 설정하거나 Predis 등의 필요한 확장 기능들을 쉽게 설치할 수 있도록 도와주는 관리도구이다.

root 접속

shell> cd /root

- composer.phar 다운

shell> curl -sS https://getcomposer.org/installer | sudo php

shell> mv composer.phar /usr/local/bin/composer

- composer 전역설정

shell> ln -s /usr/local/bin/composer /usr/bin/composer

- composer 업데이트

shell> composer selfupdate


2. Composer 설치 확인

composer -v

# composer 설치 확인 및 버전 확인


3. user생성

shell> cd /home

- lara5 유저생성

shell> useradd lara5

- 권한변경

shell> chmod 775 lara5


4. laravel 프로젝트 생성 ( lara5 계정실행)

- lara5 계정 전환 ( root로 프로젝트 생성하는경우 소유권 변경해줘야함.)

shell> su lara5

shell> cd /home/lara5

- lara5_A01 이 프로젝트명

shell> composer create-project --prefer-dist laravel/laravel lara5_A01 "^9.0"


5.프로젝트 폴더 소유권 권한 변경 ( lara5 계정실행)

shell> cd /home/lara5/lara5_A01

shell> chmod 777 -R bootstrap/cache/

shell> chmod 777 -R storage/


6. httpd vhost 설정 경로변경 ( root 실행 )

- httpd.conf 파일 열어서 IncludeOptional conf.d/*.conf 가 있는지 확인

shell> cat /etc/httpd/conf/httpd.conf

- vhost 설정파일생성

shell> vi /etc/httpd/conf.d/vhost_lara5.conf

<VirtualHost *:80>

# root 경로 설정

DocumentRoot /home/lara5/lara5_A01/public/

# 도메인,2차도메인

ServerName lara5.jhun.co.kr

<Directory /home/lara5/lara5_A01>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>

<Directory /home/lara5/lara5_A01/public>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

- httpd 재시작

shell> systemctl restart httpd

virtualBox 환경이니 widnow 에서 host 파일 변경

C:\Windows\System32\drivers\etc\hosts

설치 성공!!!!!


다했는데 testing123 페이지가 뜬다면

아래 php 모듈을 추가로 설치하자

#> sudo yum install -y php php-cli php-fpm php-mysqlnd php-zip php-gd php-mbstring php-xml php-bcmath php-json php-pear php-devel

#> systemctl restart httpd


브라우져 실행시 메인화면인 안뜨고

로그파일 권한 오류시 storage/logs/laravel.log" could not be opened

in append mode: Failed

한번더 로그파일 권한을 변경해주자

ssh root접속

#> cd 프로젝트 경로

#> chmod 777 -R storage/


root로 프로젝트 생성하는경우

Do not run Composer as root/super user! See https://getcomposer.org/root for details

루트/슈퍼 유저로 Composer를 실행하지 마세요! 자세한 내용은 https://getcomposer.org/root를 참조하세요.

yes 선택

bootstrap/cache/ , storage/ 권한 777 변경

엥? 잘뜨네......

하지만 ftp 업로드 실패

Failed to transfer file 'E:\PhpstormProjects\vm_ftp\lara4\lara4_A01\laravel9': cant open output connection for file "ftp://192.168.55.160/lara4_A01/laravel9". Reason: "553 Could not create file.".

소유권 변경으로 해결

shell> cd /home

shell> chown lara4:apache -R ./lara4


1. user 폴더 권한변경

shell> cd /home

shell> chmod 775 lara4

2.소유권 변경

shell> cd /home

shell> chown lara4:apache -R ./lara4

3.프로젝트 폴더 권한 변경

shell> cd /프로젝트경로

shell> chmod 777 -R bootstrap/cache/

shell> chmod 777 -R storage/


* 755 변경이 별생각없이 습관적으로 하다보니 root 프로젝트 생성을 정리하면서

어라라 아파치 그룹 등록해야 동작했던거 같던데 왜 그냥됨? 하면서 한참 생각했다.

프로젝트 생성후 user폴더의 권한을 755 -r 로 사용하는경우

cd /home/

chmod 755 -R /lara2/

이경우 사용자계정을 아파치그룹에 등록 하면 된다.

shell> cd /home

- gpasswd -a 사용자계정명 apache

shell> gpasswd -a lara4 apache

728x90