您好,登錄后才能下訂單哦!
序:這次項目主要是為了給微信客戶端添加一個地址,在微信公眾號里面添加一個可以訪問的app下載頁面,說起來很簡單,但總不能為了這么小的一個網站新建一個web服務器吧!
現在開始配置,首先必須確認已經在Linux上搭建好了LAMP環境,并且有一個站點可以正常訪問,以我的apache-ubuntu為例,默認目錄是:/var/www/html/
來先明確這個新的站點該放在哪兒,我絕不建議繼續放到默認目錄下一個目錄,應該放在www下面,我這么做的,
sudo mkdir /var/www/sunjob-app //新建一個站點目錄
沒錯,我的新小網站的目錄就在這個sunjob-app下面吧
接下來先別著急去配置文件,去域名購買站點修改解析,我的是萬網,添加域名解析,如圖:
注意把記錄類型修改為cname,不是圖中的A,記錄就是域名前綴,默認是www,我修改成了app,那么最終訪問時候的請求地址就是:app.ygdiy.com(注意前綴變了)
域名解析結束,保存!
回到ubuntu服務器,開始配置這個域名解析的新站點:
cd /etc/apache2/sites-available/ //進入可獲取站點配置目錄下
//vim新建并修改一個配置文件,我直接命名成了新站點,但注意后綴是.conf,因為在apache.conf中默認是include "*.conf"文件的
//而nginx中nginx.conf配置了“include sites-enable/*”所以所有文件都會被加載,apache只加載.conf后綴的
vim ./app.ygdiy.conf
修改配置文件代碼如下:
# The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to# match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName app.ygdiy.com ServerAdmin webmaster@localhost DocumentRoot /var/www/sunjob-app # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combinedOptions Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all# For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf
保存退出到bash中,把站點鏈接到enable中:
sudo ln -s /etc/apache2/sites-available/app.ygdiy.conf /etc/apache2/sites-enabled/app.ygdiy.conf
配置ok了,注意配置文件中,DocumentRoot 必須是存在并且可以訪問的目錄,因為新站點存放在這里頭,被apache提供給用戶訪問
另外,servername,設置成剛剛解析的新域名名字,cname的那個,注意了喲
重啟apache
sudo service apache2 restart
最后把新網站的文件拷貝到/var/www/sunjob-app/下,你們拷貝到自己命名配置的目錄下即可,瀏覽器輸入站點新域名即可訪問了,最后獻上我的效果圖,晚安
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。