2017年6月11日 星期日

Drupal安裝備忘錄

drupal 安裝備忘錄

#安裝php及mysql環境
yum install php php-cli php-common php-gd php-mbstring mysqld zlib

(php-gd和php-mbstring是必要的,當初安裝drupal一直失敗就是這個原因)

#修改/etc/php.ini,找到[Date]區塊,新增以下一行設定(開頭分號要拿掉)
date.timezone = "Asia/Taipei"

#修改/etc/httpd/conf/httpd.conf,找到<Directory "/var/www/html">設定,
#將AllowOverride改成All
<Directory "/var/www/html">
 #AllowOverride None
 AllowOverride All
</Directory>


#到drupal官網下載drupal-8.3.3.tar.gz
cp drupal-8.3.3.tar.gz /var/www/html
cd /var/www/html
tar -zxvf drupal-8.3.3.tar.gz
mv drupal-8.3.3 drupal
rm drupal-8.3.3.tar.gz

#新增Drupal檔案上傳存放資料夾 (使用者上傳的圖檔會放到該資料夾)
cd /var/www/html/drupal/default/
mkdir files
chmod 775 files
chgrp apache files

#新增預設的settings.php
cd /var/www/html/drupal/default/
cp default.settings.php settings.php
chmod 660 settings.php
chgrp apache settings.php

#在settings.php中,加入以下兩行以下設定
ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');


#之後開啟瀏覽器,輸入http://localhost/drupal,進入安裝頁面
#在Requirement review會出現Clean URL和PHP OPCODE CACHING is not enable的警告,
#不要理他,直接下一步到底
#之後會要求輸入MySQL帳號密碼,剛開始可以用root,但上線系統並不建議
#安裝完成後,請修改/var/www/html/drupal/default/settings.php權限為644

產生C語言Call Graph的方法

測試了多個c語言的call-graph產生器,覺得最好用的還是cflow這個指令,
配合htags,能產生超強大的html來瀏覽source code
以下將說明指令使用方式

安裝相關套件:
yum install cflow global


cflow使用方式:
首先先切換到專案底下:
cd myproject;

目錄的結構大約如下,source code分別放在src及lib資料夾
myproject
+--src
+--a.c
+--b.c
+--lib
+--cqji.c
假設我的程式碼分別放在src及lib目錄下,我希望產生所有c檔的call-graph,
cflow src/*.c lib/*.c;

執行後輸出:
main() <int main (int argc, char *argv[]) at src/main.c:319>:
    getopt()
    print_usage() <void print_usage (const char *pro_name) at src/main.c:40>:
        printf()
    time()
    printf()
    ctime()
    packet_queue_init() <BOOL packet_queue_init (void) at src/packet_queue.c:22>:
        pthread_mutex_init()
    flow_init() <int flow_init (void) at src/flow.c:175>:
        flow_hash_init() <int flow_hash_init (void) at src/hash_table.c:30>:
            MALLOC()
            pthread_mutex_init()
        flow_queue_init() <int flow_queue_init (void) at src/flow_queue.c:27>:
            pthread_mutex_init()
    pthread_create()

可以加上-T選項,產生如下
+-main() <int main (int argc, char *argv[]) at src/main.c:319>
  +-getopt()
  +-print_usage() <void print_usage (const char *pro_name) at src/main.c:40>
  | \-printf()
  +-time()
  +-printf()
  +-ctime()
  +-packet_queue_init() <BOOL packet_queue_init (void) at src/packet_queue.c:22>
  | \-pthread_mutex_init()
  +-flow_init() <int flow_init (void) at src/flow.c:175>
  | +-flow_hash_init() <int flow_hash_init (void) at src/hash_table.c:30>
  | | +-MALLOC()
  | | \-pthread_mutex_init()
  | \-flow_queue_init() <int flow_queue_init (void) at src/flow_queue.c:27>
  |   \-pthread_mutex_init()
  +-pthread_create()

配合htags指令,可以產生一個超強大的html
cflow src/*.c -o cflow.txt -f posix
htags -ngoIsv --cflow cflow.txt