顯示具有 drupal 標籤的文章。 顯示所有文章
顯示具有 drupal 標籤的文章。 顯示所有文章

2013年7月17日 星期三

Varnish 3 in CentOS 6 with apache and Drupal 7


1. Installation Varnish 3 in CentOS6


https://www.varnish-cache.org/installation/redhat
  
rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm

yum install varnish

2. modified /etc/sysconfig/varnish


 VARNISH_LISTEN_PORT=6081
to
VARNISH_LISTEN_PORT=80

3. modified /etc/varnish/default.vcl to suit drupal


https://fourkitchens.atlassian.net/wiki/display/TECH/Configure+Varnish+3+for+Drupal+7

注意
backend default {
  .host = "127.0.0.1";
  .port = "8080";
}
 

4. modified  httpd.conf


change httpd listen port to default.vcl backend port (8080)

5. service restart apache / varnish

chkconfig --level 3 varnish on
service httpd restart
service varnish restart

6. install drupal varnish module 


https://drupal.org/project/varnish

drush dl varnish
drush en varnish -y

7. modified drupal settings.php


$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc';
$conf['cache_class_cache_page'] = 'VarnishCache';
$conf['reverse_proxy'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;
$conf['cache'] = 1;
$conf['cache_lifetime'] = 0;
$conf['page_cache_maximum_age'] = 21600;
$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
$conf['omit_vary_cookie'] = TRUE;


reference:
http://andrewdunkle.com/how-install-varnish-drupal-7


8. check varnish status


varnishstatus

reference:
http://kly.no/posts/2009_12_08__Varnishstat_for_dummies__.html

9. 假設要 telnet 到 管理port (例如 6082)


Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
107 59
xglonvpwnvqqkwqeqjqnkgqumdciwxnv

Authentication required.

 

 需要auth 的話

假設secret file (/etc/varnish/secret) 內容是  foo

在另一個 shell裡面
[root@varnish-server ~]# cat > _ 
xglonvpwnvqqkwqeqjqnkgqumdciwxnv    (上面的challenge)
foo
xglonvpwnvqqkwqeqjqnkgqumdciwxnv
^D

[root@varnish-server ~]# hexdump -C _
00000000  78 67 6c 6f 6e 76 70 77  6e 76 71 71 6b 77 71 65  |xglonvpwnvqqkwqe|
00000010  71 6a 71 6e 6b 67 71 75  6d 64 63 69 77 78 6e 76  |qjqnkgqumdciwxnv|
00000020  0a 66 6f 6f 0a 78 67 6c  6f 6e 76 70 77 6e 76 71  |.foo.xglonvpwnvq|
00000030  71 6b 77 71 65 71 6a 71  6e 6b 67 71 75 6d 64 63  |qkwqeqjqnkgqumdc|
00000040  69 77 78 6e 76 0a                                 |iwxnv.|
00000046




 
[root@varnish-server ~]# sha256sum _
27eef6997eeb47c5e26dfb72dc8f32715a8d39265becdfdedc1edc2365d5624b  _

再回到 telnet 的shell裡面鍵入
auth 27eef6997eeb47c5e26dfb72dc8f32715a8d39265becdfdedc1edc2365d5624b

就可以登入

10. Apache 會抓到 127.0.0.1 IP, 造成IP阻擋與 http.log 錯誤的問題

重要!!!安全性問題

安裝 mod_rpaf
(http://blog.roozbehk.com/post/24568560912/nginx-as-reverse-proxy-to-apache-server)

 wget -q -O - http://www.atomicorp.com/installers/atomic | sh 
yum install mod_rpaf
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1 NGINX_SERVER_IP
RPAFheader X-Forwarded-For 

 sudo service /usr/sbin/httpd restart 




2013年6月7日 星期五

Drupal 7 Note

Drush

https://drupal.org/project/drush
執行drush 要在drupal目錄下

 

Customize Views templates


administrator -> structure -> views -> viewsname
Advanced -> Theme: Information

look for the templates name :

ex : views-view--myvewsname.tpl.php

cp   sites/all/modules/views/theme/views-view.tpl.php   /sites/all/themes/mysubtheme1/templates/views-view--myvewsname.tpl.php

Rescan template files

check if the templates name bolded















相關連結



http://evolvingweb.ca/story/theming-views-drupal-templates-and-preprocess-functions

http://www.interworks.com/blogs/carmstrong/2013/02/27/quick-tutorial-overriding-drupal-views-using-templates


CSS:

http://www.w3schools.com/cssref/css_selectors.asp
http://www.w3schools.com/cssref/css_colornames.asp
http://www.w3schools.com/cssref/css3_browsersupport.asp



http://yunol.com.tw/phpbb3/viewtopic.php?f=24&t=25548


Floating Block
QuickTab

Node view count

2013年6月2日 星期日

Install Drupal in CentOS 6.4 with Apache/MySQL/SELinux




1. 要讓httpd 可以存取遠端資料庫(remote database)

     要打開SELinux httpd_can_network_connect
    
   setsebool -P httpd_can_network_connect 1

2.  如果 Enable Clean URL fail


    先確認 RewriteEngine 是否能正常運作
    VirtualHost + RewriteEngine
    A: httpd.conf 要打開  Options  FollowSymLinks


3. httpd.conf 相關與其他安全設定

打開 .htaccess override 讓 apache 去讀drupal的 .htaccess

        AllowOverride All

上面註解了以後,autopath 模組應該就不用另外設定rewrite rule 在httpd.conf裡面了


修改Drupal的.htaccess


        Order deny,allow
        Deny from all
        Allow from 127.0.0.1

讓相關檔案只能從local存取

另外依照 https://drupal.org/node/244924 調整目錄權限
[root@localhost]cd /path_to_drupal_installation
[root@localhost]chown -R webadmin:www-data .
[root@localhost]find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
[root@localhost]find . -type f -exec chmod u=rw,g=r,o= '{}' \;

[root@localhost]cd /path_to_drupal_installation/sites
[root@localhost]find . -type d -name files -exec chmod ug=rwx,o= '{}' \;
[root@localhost]for d in ./*/files
do
   find $d -type d -exec chmod ug=rwx,o= '{}' \;
   find $d -type f -exec chmod ug=rw,o= '{}' \;
done 



Summarizing the permissions

  • drupal_admin: the user on the server that administrates Drupal, not necessarily is the root.
  • site_admin: the owner of the hosted site (a customer)

Ownership

Core modules/themes files and directories: drupal_admin:www-data
Hosted sites modules/themes/files files and directories: site_admin:www-data

Permissions

Core modules/themes directories: rwxr-x---
Core modules/themes files: rw-r-----
Hosted sites modules/themes directories: rwxr-x---
Hosted sites modules/themes files: rw-r-----
Hosted sites "files" directory: rwxrwx---
Hosted sites files under "files" directories: rw-rw----
Hosted sites subdirectories under "files" directories: rwxrwx---



參考
http://www.madirish.net/242

 

4. Update Manger with SSH


Just ran into same issue on my CentOS 6 box...
Here's the info...
# su -
# php -m | grep ssh2
# rpm -qa | grep libssh2

If one or both queries are empty, then proceed with following...
# yum install libssh2 libssh2-devel
# pecl install ssh2
   *** Note you'll probably get a PECL error, if so then fix with...
   # pecl install "channel://pecl.php.net/ssh2-0.12"

如果pecl 安裝 ssh2 時出現
 ex :
              sh: phpize: command not found




解法 :   yum install php-devel

如果pecl 安裝 ssh2 時出現
ex:
       configure: error: no acceptable C compiler found in $PATH

解法: yum install gcc

Then enable the extension...
# echo "extension=ssh2.so" > /etc/php.d/ssh2.ini

Finally restart Apache
# /etc/init.d/httpd restart

最後要注意上傳目錄
sites/all/modules/views
sites/all/modules/themes
的寫入權限

必須SSH user 有write
(建議新增一個webadministrator 之類的user)






drush dl views ctools panels advanced_help pathauto token wysiwyg entity ds nivo_slider nivo_formatter media admin_menu omega_tools

drush dl delta context jquery_update libraries link drupalforfirebug devel imce

drush dl css_injector workbench


drush install youtube views_slideshow varnish quicktabs fb_social


Relate Modules:

https://drupal.org/project/views
(http://ftp.drupal.org/files/projects/views-7.x-3.7.tar.gz)

https://drupal.org/project/ctools
 (http://ftp.drupal.org/files/projects/ctools-7.x-1.3.tar.gz)
 
https://drupal.org/project/panels
(http://ftp.drupal.org/files/projects/panels-7.x-3.3.tar.gz)

https://drupal.org/project/advanced_help
(http://ftp.drupal.org/files/projects/advanced_help-7.x-1.0.tar.gz)

http://ftp.drupal.org/files/projects/pathauto-7.x-1.2.tar.gz


http://ftp.drupal.org/files/projects/token-7.x-1.5.tar.gz

https://drupal.org/project/wysiwyg
()
裝普通版(先不要裝dev版)
  • http://download.moxiecode.com/tinymce/tinymce_3.5.8.zip
  • http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.6.4/ckeditor_3.6.4.tar.gz

http://ftp.drupal.org/files/projects/entity-7.x-1.1.tar.gz

http://ftp.drupal.org/files/projects/ds-7.x-2.3.tar.gz

https://drupal.org/project/admin_menu
()

Omega:
https://drupal.org/node/1298616

https://drupal.org/project/omega
(http://ftp.drupal.org/files/projects/omega-7.x-3.1.tar.gz)


omegatool
http://ftp.drupal.org/files/projects/omega_tools-7.x-3.0-rc4.tar.gz
delta
http://ftp.drupal.org/files/projects/delta-7.x-3.0-beta11.tar.gz
context
http://ftp.drupal.org/files/projects/context-7.x-3.0-beta6.tar.gz






nivo_slider:
https://drupal.org/project/nivo_slider
https://drupal.org/project/Jquery_update
https://drupal.org/project/libraries
http://ftp.drupal.org/files/projects/nivo_formatter-7.x-1.x-dev.tar.gz
http://dev7studios.com/wp-content/uploads/downloads/2013/01/nivo-slider3.2.zip


views slideshow
https://drupal.org/project/views_slideshow
(http://ftp.drupal.org/files/projects/views_slideshow-7.x-3.0.tar.gz)
https://drupal.org/project/libraries
(http://ftp.drupal.org/files/projects/libraries-7.x-2.1.tar.gz)
https://github.com/malsup/cycle/downloads
(
  1. Locate/download the jQuery cycle plugin from the internet, download jquery.cycle.all.latest.min.js and rename it to jquery.cycle.all.min.js
)
https://drupal.org/project/link
(http://ftp.drupal.org/files/projects/link-7.x-1.1.tar.gz)


responsive :
https://drupal.org/project/views_responsive_grid
https://drupal.org/project/cs_adaptive_image