我們的目錄是網站根目錄,用webpath表示,下面所有遇到webpath的地方都表示網站的站點所在根目錄
1 下載
git clone https://github.com/honraytech/VueThink.git
2 導入數據
將webpath/VueThink/php/install.sql導入到你的數據庫
3 配置數據庫鏈接
修改webpath/VueThink/php/config/database.php,將數據庫配置信息修改正確
4 創建runtime目錄,並設置爲可讀寫
mkdir webpath/VueThink/php/runtime
chmod 777 webpath/VueThink/php/runtime
4 修改main.js
在webpath/VueThink/frontEnd/src/main.js中搜索
axios.defaults.baseURL = HOST
修改爲
axios.defaults.baseURL = 'http://localhost/VueThink/php/index.php/'
搜索
window.HOST = HOST
修改爲
window.HOST = 'http://localhost/VueThink/php/index.php/'
5 安裝依賴
cd webpath/VueThink/frontEnd/
npm install
6 運行開發
npm run dev
nginx配置
如果你用nginx可能需要配置跨域,server中添加以下配置,注意一定要根據自己服務器的情況修改,不要盲目複製粘貼
#add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Origin, DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept, authKey, sessionId';
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '$http_origin';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Origin, DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept, authKey, sessionId';
return 204;
}
index index.php;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Origin, DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept, authKey, sessionId';
return 204;
}
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# With php-cgi (or other tcp sockets):
fastcgi_pass 127.0.0.1:9000;
}