vagrant

vagrant 사이트 추가

먹세 2018. 3. 21. 09:55

우선 VirtualBox 내에서 Homestead Login 이라고 나올때 기본 계정

login : vagrant

pw : vagrant

 

 

1. Homestead.yaml 수정

 

folders : 

      - map: ~/code/mosei/

        to: /home/vagrant/code/mosei/

 

sites :

      - map: mosei1.mydomain.co.kr

        to: /home/vagrant/code/mosei/project1

    

      - map: mosei2.mydomain.co.kr

        to: /home/vagrant/code/mosei/project2

 

위 처럼 sites에 맵핑을 추가해준다.

 

folders 는 vagrant와 C:어쩌구(내 로컬) 경로와 동기화를 시켜주는 경로 세팅이다.

 

위처럼 수정하고나서

#vagrant halt

#vagrant up --provision

 

해야 맵핑 적용됨.

이렇게 하면 vagrant ssh 로 들어가서 확인해본다.

/etc/nginx/sites-available/ 안에 sites에서 입력한 mosei1.mydomain.co.kr 호스트파일과 mosei2.mydomain.co.kr 호스트파일이 생성되어 있을 것이다.

그 안에 내용을 수정해준다

(vagrant up --provision을 하면 호스트파일이 초기화 되기 때문에 항상 재설정 해야함)

 

server { listen 80; server_name .mydomain.co.kr; root "/home/vagrant/code/mosei/myproject1"; index index.html index.htm index.php; charset utf-8; client_max_body_size 200M; sendfile on; # Deny dotfiles (**/.*) location ~ /\. { deny all; } # Deny .php (**/*.php) location ~ \.php$ { rewrite ^.* /index.php; } # rewrite location / { rewrite ^/web_installer/?$ /web_installer/index.php permanent; location ^~ /google0d4dc3cb2864e4ae.html { try_files $uri /index.php?$query_string break; } location ^~ /assets/ { try_files $uri /index.php?$query_string break; } location ^~ /plugins/ { try_files $uri $uri/ /index.php?$query_string; } location ^~ /storage/app/public/ { try_files $uri /index.php?$query_string break; } location ~ ^/favicon* { try_files $uri /index.php?$query_string break; } location /robots.txt { try_files $uri /index.php?$query_string break; } # 자료실 location ^~ /storage/app/plugin/store/dist/ { try_files $uri /index.php?$query_string break; } location ^~ /storage/app/plugin/store/packagist/ { try_files $uri /index.php?$query_string break; } rewrite ^.* /index.php?$query_string; location ~ ^/(web_installer/)?index.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors off; fastcgi_buffer_size 16k; fastcgi_buffers 4 16k; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; } } # static files location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log /var/log/nginx/local.mydomain.co.kr-access.log combined; error_log /var/log/nginx/local.mydomain.co.kr-error.log error; ssl_certificate /etc/nginx/ssl/local.mydomain.co.kr.crt; ssl_certificate_key /etc/nginx/ssl/local.mydomain.co.kr.key; }

 

그리고나서 nginx 재부팅

#sudo service nginx restart

 

그리고 C:\windows\system32\drivers\etc 에서 hosts 파일에 도메인을 추가해준다.

 

192.168.10.10   mosei1-local.mydomain.co.kr

192.168.10.10   mosei2-local.mydomain2.co.kr

 

여기까지 세팅하면 mosei1-local.mydomain.co.kr 과같이 hosts 파일에 저장한 도메인을로 접속하면 내 로컬 vagrant 가상서버에 접속된다.

 

 

 

반응형