查看google adsense 帳戶是否為premium
參考文章:
https://productforums.google.com/forum/#!msg/adsense/vyHp1mV5xPM/HQTm6zpb4rkJ
基本上會先要求授權adsense,然後按執行就可以看到結果,看完後,記得要去google帳戶設定那邊,把授權取消。
參考文章:
https://productforums.google.com/forum/#!msg/adsense/vyHp1mV5xPM/HQTm6zpb4rkJ
基本上會先要求授權adsense,然後按執行就可以看到結果,看完後,記得要去google帳戶設定那邊,把授權取消。
一般如果使用php的session設定,在ubuntu下可以修改/etc/php5/apache2/php.ini這個檔案。
有兩個值要設定:
session.gc_maxlifetime
session.cookie_lifetime
參考來源:
php session
.form-control input:focus { box-shadow:0; border-color: #FF0000; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 0.6); }
參考文章:http://stackoverflow.com/questions/14820952/change-bootstrap-input-focus-blue-glow
不需要頁面刷新才更新圖片,程式碼大致上如下
$.ajax({ url: '/upload', type: 'POST', cache: false, data: new FormData($('#uploadForm')[0]), processData: false, contentType: false, dataType:'json' }).done(function(res) { }).fail(function(res) { });
xmlrpc.php是用來做遠端call用的,但會被攻擊,若要全部擋掉,可以在apache裡加上以下:
< Files xmlrpc.php >
Require all denied
< /Files >
解法:
session_start(); if($_GET["state"){ $_SESSION["FBRLH_state"]=$_GET['state']; }
參考:
https://github.com/facebook/facebook-php-sdk-v4/issues/473
https://github.com/facebook/facebook-php-sdk-v4/blob/4.0.16/src/Facebook/FacebookRedirectLoginHelper.php#L205
https://github.com/facebook/facebook-php-sdk-v4/issues/470#issuecomment-212561488
https://github.com/facebook/facebook-php-sdk-v4/issues/572
https://github.com/facebook/facebook-php-sdk-v4/issues/470
https://github.com/facebook/facebook-php-sdk-v4/issues/529
基本上安裝過程都可以透過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。
以前用capistrano做deploy很方便,但那是ruby on rails,也是可以用capistrano替妳的php專案做deploy,但總覺得這樣很不直覺,於是最近新找了一套deploy工具,就是deployer啦。摸了好幾天,發生一些錯誤,總算安裝完成。
開發環境為:ubuntu 14.0
php專案:cakephp
以下是完整安裝步驟:
“deployer/deployer”:”^3.0″,
“herzult/php-ssh”:”^1.1″,
“extssh2″:”*”,
“phpseclib/phpseclib”: “^2.0”
官方教學可看:
https://github.com/deployphp/deployer
sudo apt-get install php5-ssh2 sudo service apache2 restart #在php.ini加入以下: extension=ssh2.so; #確定一下php有載入ssh2 php -m | grep ssh2
<?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,這樣就可以了。
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys2
這個user是用來之後做deploy這件事的user,要跟你deploy.php裡的user一模一樣。
eval `ssh-agent -s` ssh-add
要確定正確,可以直接用deploy這個user去建立該目錄,就沒有問題。
通過以上,應該就可以完整deploy了。
參考:
http://deployer.org/
https://github.com/deployphp/deployer