您好,登錄后才能下訂單哦!
序:這次項(xiàng)目主要是為了給微信客戶端添加一個(gè)地址,在微信公眾號(hào)里面添加一個(gè)可以訪問(wèn)的app下載頁(yè)面,說(shuō)起來(lái)很簡(jiǎn)單,但總不能為了這么小的一個(gè)網(wǎng)站新建一個(gè)web服務(wù)器吧!
現(xiàn)在開(kāi)始配置,首先必須確認(rèn)已經(jīng)在Linux上搭建好了LAMP環(huán)境,并且有一個(gè)站點(diǎn)可以正常訪問(wèn),以我的apache-ubuntu為例,默認(rèn)目錄是:/var/www/html/
來(lái)先明確這個(gè)新的站點(diǎn)該放在哪兒,我絕不建議繼續(xù)放到默認(rèn)目錄下一個(gè)目錄,應(yīng)該放在www下面,我這么做的,
sudo mkdir /var/www/sunjob-app //新建一個(gè)站點(diǎn)目錄
沒(méi)錯(cuò),我的新小網(wǎng)站的目錄就在這個(gè)sunjob-app下面吧
接下來(lái)先別著急去配置文件,去域名購(gòu)買站點(diǎn)修改解析,我的是萬(wàn)網(wǎng),添加域名解析,如圖:
注意把記錄類型修改為cname,不是圖中的A,記錄就是域名前綴,默認(rèn)是www,我修改成了app,那么最終訪問(wèn)時(shí)候的請(qǐng)求地址就是:app.ygdiy.com(注意前綴變了)
域名解析結(jié)束,保存!
回到ubuntu服務(wù)器,開(kāi)始配置這個(gè)域名解析的新站點(diǎn):
cd /etc/apache2/sites-available/ //進(jìn)入可獲取站點(diǎn)配置目錄下
//vim新建并修改一個(gè)配置文件,我直接命名成了新站點(diǎn),但注意后綴是.conf,因?yàn)樵赼pache.conf中默認(rèn)是include "*.conf"文件的
//而nginx中nginx.conf配置了“include sites-enable/*”所以所有文件都會(huì)被加載,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中,把站點(diǎn)鏈接到enable中:
sudo ln -s /etc/apache2/sites-available/app.ygdiy.conf /etc/apache2/sites-enabled/app.ygdiy.conf
配置ok了,注意配置文件中,DocumentRoot 必須是存在并且可以訪問(wèn)的目錄,因?yàn)樾抡军c(diǎn)存放在這里頭,被apache提供給用戶訪問(wèn)
另外,servername,設(shè)置成剛剛解析的新域名名字,cname的那個(gè),注意了喲
重啟apache
sudo service apache2 restart
最后把新網(wǎng)站的文件拷貝到/var/www/sunjob-app/下,你們拷貝到自己命名配置的目錄下即可,瀏覽器輸入站點(diǎn)新域名即可訪問(wèn)了,最后獻(xiàn)上我的效果圖,晚安
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。