查看google adsense 帳戶是否為premium

參考文章:

https://productforums.google.com/forum/#!msg/adsense/vyHp1mV5xPM/HQTm6zpb4rkJ

基本上會先要求授權adsense,然後按執行就可以看到結果,看完後,記得要去google帳戶設定那邊,把授權取消。

在ubuntu14.04上安裝redmine

基本上安裝過程都可以透過redmine的how to查看:

1.http://martin-denizet.com/install-redmine-2-5-x-git-subversion-ubuntu-14-04-apache2-rvm-passenger/
2.http://www.redmine.org/projects/redmine/wiki/HowToss

需要特別注意的是,我在安裝過程中沒有替網站加上ssl,裝完後去用,其實也是ok的。

其中要注意的是config/database.yml裡面的檔案:

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "my_password"
  encoding: utf8

上述的username跟password,記得改成進入mysql新增使用時的帳號密碼。然後 /etc/apache2/conf-available/passenger.conf的檔案在執行完passenger-install-apache2-module這行指令後,會顯示給你,加上去即可。記得將你自己的domain name指到/opt/redmine/current/public這個目錄下。

另外在sites-avalible裡新增一個.conf檔案,把redmine安裝過程裡說要加的都加一加。

ServerName redmine.domain.com
 

 ServerAdmin admin@domain.com
 ServerName redmine.domain.com
 
 # Enable SSL with Perfect Forward Secrecy
 SSLEngine on
 SSLProtocol +TLSv1.2 +TLSv1.1 +TLSv1
 SSLCompression off
 SSLHonorCipherOrder on
 SSLCipherSuite "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:RC4-SHA:AES256-GCM-SHA384:AES256-SHA256:CAMELLIA256-SHA:ECDHE-RSA-AES128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:CAMELLIA128-SHA"
 SSLCertificateFile /etc/apache2/ssl/redmine.crt
 SSLCertificateKeyFile /etc/apache2/ssl/redmine.key
 
 DocumentRoot /opt/redmine/current/public/
 
 ## Passenger Configuration
 ## Details at http://www.modrails.com/documentation/Users%20guide%20Apache.html
 
 PassengerMinInstances 6
 PassengerMaxPoolSize 20
 RailsBaseURI /
 PassengerAppRoot /opt/redmine/current
 
 # Speeds up spawn time tremendously -- if your app is compatible. 
 # RMagick seems to be incompatible with smart spawning
 RailsSpawnMethod smart
 
 # Keep the application instances alive longer. Default is 300 (seconds)
 PassengerPoolIdleTime 1000
 
 # Keep the spawners alive, which speeds up spawning a new Application
 # listener after a period of inactivity at the expense of memory.
 RailsAppSpawnerIdleTime 3600
 
 # Additionally keep a copy of the Rails framework in memory. If you're 
 # using multiple apps on the same version of Rails, this will speed up
 # the creation of new RailsAppSpawners. This isn't necessary if you're
 # only running one or 2 applications, or if your applications use
 # different versions of Rails.
 PassengerMaxPreloaderIdleTime 0
 
 # Just in case you're leaking memory, restart a listener 
 # after processing 5000 requests
 PassengerMaxRequests 5000
 
 # only check for restart.txt et al up to once every 5 seconds, 
 # instead of once per processed request
 PassengerStatThrottleRate 5
 
 # If user switching support is enabled, then Phusion Passenger will by default run the web application as the owner if the file config/environment.rb (for Rails apps) or config.ru (for Rack apps). This option allows you to override that behavior and explicitly set a user to run the web application as, regardless of the ownership of environment.rb/config.ru.
 PassengerUser www-data
 PassengerGroup www-data
 
 # By default, Phusion Passenger does not start any application instances until said web application is first accessed. The result is that the first visitor of said web application might experience a small delay as Phusion Passenger is starting the web application on demand. If that is undesirable, then this directive can be used to pre-started application instances during Apache startup.
 PassengerPreStart https://localhost
  
 
 Options +Indexes +FollowSymLinks -MultiViews
 AllowOverride All
 
     Order allow,deny
     Allow from all
 
 = 2.3>
     Require all granted
 
 
 
 AddOutputFilter DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css
 BrowserMatch ^Mozilla/4 gzip-only-text/html
 BrowserMatch ^Mozilla/4.0[678] no-gzip
 BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 
 
 ErrorLog ${APACHE_LOG_DIR}/redmine.error.log
 LogLevel warn
 CustomLog ${APACHE_LOG_DIR}/redmine.access.log combined
 ServerSignature Off
 


註:SSL相關的可以跳過。

其他應該都沒什麼大問題了,有空再來研究加上SSL。

php deploy工具:deployer完整安裝教學

以前用capistrano做deploy很方便,但那是ruby on rails,也是可以用capistrano替妳的php專案做deploy,但總覺得這樣很不直覺,於是最近新找了一套deploy工具,就是deployer啦。摸了好幾天,發生一些錯誤,總算安裝完成。

開發環境為:ubuntu 14.0
php專案:cakephp

以下是完整安裝步驟:

1.用composer裝一些東西:

“deployer/deployer”:”^3.0″,
“herzult/php-ssh”:”^1.1″,
“extssh2″:”*”,
“phpseclib/phpseclib”: “^2.0”

官方教學可看:
https://github.com/deployphp/deployer

2.安裝php5-ssh2

sudo apt-get install php5-ssh2
sudo service apache2 restart

#在php.ini加入以下:
extension=ssh2.so; 

#確定一下php有載入ssh2
php -m | grep ssh2

3.安裝完後,在專案根目錄新增deploy.php,然後寫一些東西

<?php 
require_once 'vendor/autoload.php';
 require_once 'vendor/deployer/deployer/recipe/common.php'; 

set('ssh_type', 'ext-ssh2'); 
set('keep_releases', 10); 

server('prod','host',22) ->user('deploy')                                                   
    ->forwardAgent() ->stage('prod')                                              
    ->identityFile('~/.ssh/id_rsa.pub', '~/.ssh/id_rsa')            
    ->env('deploy_path', '/path/to/deploy')  
    ->env('branch', 'master'); 


task('deploy', [
'deploy:prepare',
'deploy:release',
'deploy:update_code',
'deploy:vendors',
'deploy:shared',
'deploy:symlink',
'cleanup',
])->desc('Deploy your project');  

after('deploy', 'success'); 
set('repository', 'your repository on github or bitbucket'); 

注意:common.php是deployer的基礎程式,通常會需要在他之前載入autoload.php,但若路徑不對,就會抓不到正確的class,之前就發生載不到sshconfiguration class,所以解法為,去common.php那個檔案裡面,再載入一次autoload.php,這樣就可以了。

4.複製一份id_rsa.pub到authorized_keys2

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys2

5.新增一個deploy user

這個user是用來之後做deploy這件事的user,要跟你deploy.php裡的user一模一樣。

6.建立ssh連線

eval `ssh-agent -s`
ssh-add

7.確定deploy的目錄權限正確

要確定正確,可以直接用deploy這個user去建立該目錄,就沒有問題。

通過以上,應該就可以完整deploy了。

 

參考:
http://deployer.org/
https://github.com/deployphp/deployer