laravel 的 apache2 伺服器和 VM 相關設定


除了要把 laravel 的網頁伺服器帶起來以外,還想在連線的時侯不要用記不起來的 ip 而用網址名稱來連線,所以調整 apache 的設定,以及網址的對應。

工作環境:
  Windows 10 + virtualbox
  guest: Ubuntu 18 server
  Windows IP: 192.168.ooo.xxx


laravel 安裝在
  /home/your_name/your_laravel_path/public
網址與 IP 的對應檔案
  C:\Windows\System32\drivers\etc\hosts
其中 apache 使用以名稱對應的虛擬網頁,ServerName 要和網址對應檔的名稱對應
  ServerName      laravel.test    <====>    127.0.0.1    laravel.test
加上 virtualbox 的埠號對應(8080)
  Windows 10 host 瀏覽器 > laravel.test:8080 > VM > 127.0.0.1:8080 

laravel.test.conf
NameVirtualHost *:8080
Listen  8080
<VirtualHost *:8080>
    ServerName      laravel.test
    ServerAlias     www.laravel.test
    # The location of our projects public directory.
    DocumentRoot    /home/your_name/your_laravel_path/public

    # Useful logs for debug.
    LogLevel        debug
    CustomLog       ${APACHE_LOG_DIR}/access.laravel.test.log   combined
    ErrorLog        ${APACHE_LOG_DIR}/error.laravel.test.log

    # Rewrites for pretty URLs, better not to rely on .htaccess.
    <Directory /home/your_name/your_laravel_path/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            Require all granted
    </Directory>
</VirtualHost>

C:\Windows\System32\drivers\etc\hosts
127.0.0.1    laravel.test192.168.ooo.xxx    laravel.test

virtualbox 網路設定 > 連接埠轉送規則,將本機的 8080 port 網頁連線請求轉到 VM 上
  新增 http8080    /    TCP    /    192.168.ooo.xxx    /    8080    /    10.0.2.15    /    8080


收工!

留言

這個網誌中的熱門文章

使用 Excel 計算2個地點之間的直線距離

LINE 儲存的檔案傳到 email 不方便 很不方便 非常不方便 但是有解的筆記

Excel 巨集合併多個 Excel 檔案