【 30日 回憶計畫 recall project 】Apache 2 設定 Alias 目錄給 laravel


起因


這三個禮拜努力找工作,目前終於有人要付我薪水了 QQ
找工作還真的有點累累的
目前為止還真的沒碰到不用考試,只要面試就可以過關的工作
不過就這樣吧,趁9/10去報到之前再來做一些之前要做的事
這次就來調整laravel的網址吧,總不好把整個app放在外面給別人看,很害羞呢


過程


首先先找apache的設定檔在哪
下意識直接去翻etc
pi@raspberrypi:/ $ ls -al /etc/apache2/
total 100
drwxr-xr-x   9 root root  4096 Sep  2 13:46 .
drwxr-xr-x 116 root root  4096 Jul 29 03:07 ..
-rw-r--r--   1 root root  7224 Jun  2 08:01 apache2.conf
drwxr-xr-x   2 root root  4096 Jul 29 03:02 conf-available
drwxr-xr-x   2 root root  4096 Jun 25  2017 conf-enabled
-rw-r--r--   1 root root  1782 Apr  5 18:32 envvars
-rw-r--r--   1 root root  1770 Jun 25  2017 envvars.dpkg-old
-rw-r--r--   1 root root 31063 Jan 25  2017 magic
drwxr-xr-x   2 root root 16384 Jul 29 03:03 mods-available
drwxr-xr-x   2 root root  4096 Jul 26 18:21 mods-enabled
-rw-r--r--   1 root root   320 Jan 25  2017 ports.conf
drwxr-xr-x   2 root root  4096 Sep  2 13:48 sites-available
drwxr-xr-x   2 root root  4096 Sep  2 13:48 sites-enabled
drwxr-xr-x   2 root root  4096 Jun 25  2017 ssl

然後檢查apache2.conf看有沒有蛛絲馬跡
pi@raspberrypi:/etc/apache2 $ cat apache2.conf 

中略

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

看起來是另外吃檔的
直接進sites-enabled裡面看
pi@raspberrypi:/etc/apache2 $ cd sites-enabled/

pi@raspberrypi:/etc/apache2/sites-enabled $ ls -al
total 8
drwxr-xr-x 2 root root 4096 Sep  2 13:48 .
drwxr-xr-x 9 root root 4096 Sep  2 13:46 ..
lrwxrwxrwx 1 root root   35 Jun 25  2017 000-default.conf -> ../sites-available/000-default.conf
lrwxrwxrwx 1 root root   52 Jun 25  2017 000-default-le-ssl.conf -> /etc/apache2/sites-available/000-default-le-ssl.conf
是link,不過沒關係,繼續處理檔案。看起來這邊實際上檔案是放在sites-available裡面。
pi@raspberrypi:/etc/apache2/sites-enabled $ sudo vim 000-default-le-ssl.conf

在最後面加上

               Alias /weijlab "/var/www/html/weijlab/public"
               
                       AllowOverride all
         Options Indexes FollowSymLinks
         Require all granted
               


然後重啟apache2
pi@raspberrypi:/etc/apache2/sites-enabled $ sudo service apache2 restart

驗證


直接打開url就可以看的到了

留言