Warning: Cannot modify header information - headers already sent in /home/dacelo/html/DocumentRoot/wp-includes/feed-rss2.php on line 8
vi(vim)で編集していて、他のソースからコピペして貼り付けようとすると、インデントが重なってものすごくネストが深くなってしまいます。 (例) こんなソースが… こうなってしまう! これは、vimの設定で「autoindent」という項目がONになっているから起こる現象です。 :set noautoindent
と入力すればOKです。 ちなみに、 :set
のコマンドで、現在有効になっている設定の一覧が表示されます。 No related posts. Related posts brought to you by Yet Another Related Posts Plugin. tableに1000件くらいデータが入ってるんだけど、その中でtypeというキーに何種類くらいの値があるか知りたい…。そんなときに使います。
SELECT DISTINCT (type), * No related posts. Related posts brought to you by Yet Another Related Posts Plugin. subversionでコミットしようとしたら失敗した。 svn updateは問題なくできているので、環境のせいではなさそう。 SVNコミットする際は、必ずコミット時メッセージが必要になるので、こまんどでメッセージを挿入するか、外部エディタを設定すればよい。 外部エディタにviを指定する方法でもOK。 Related posts:<div class="content">
<h2>見出し</h2>
<p>本文本文</p>
<ul>
<li>リスト1</li>
<li>リスト2 </li>
</ul>
</div>
<div class="content">
<h2>見出し</h2> <p>本文本文</p> <ul> <li>リスト1</li>
<li>リスト2 </li>
</ul> </div>
解除するためには、コマンドモードで
FROM `table`

Related posts brought to you by Yet Another Related Posts Plugin.]]>[dacelo@info]$ svn commit
svn: コミットに失敗しました (詳しい理由は以下のとおりです):
svn: ログメッセージを取得するのに外部エディタを使えませんでした。$SVN_EDITOR 環境変数を設定するか、--message (-m) か --file (-F) オプションを用いてみてください
svn: 環境変数 SVN_EDITOR, VISUAL, EDITOR のどれも設定されていなく、実行時の設定オプション 'editor-cmd' も見つかりません
エラーメッセージによると、メッセージを編集するためのエディタが指定されていない、ということだった。svn commit -m 'ここにコメント'
[dacelo@info CMScontroler]$ svn commit -m 'sidebar exclude設定'
送信しています CMS/content.php
ファイルのデータを送信中です.....
リビジョン 3794 をコミットしました。
# EDITOR=vi svn commit
Related posts brought to you by Yet Another Related Posts Plugin.
]]>PHPの開発効率を上げる10個の関数 – PHP,MySQL,Flexな日々+イラストとか
変数、配列の内容をキレイに表示する関数「d」
変数や配列の内容をHTML構文でキレイに表示してくれます。
しかも、var_dumpと書くとタイピングが大変なので「d($hoge)」として簡単に記述。
これだけでも作業効率8倍
PHPの便利な関数色々。
こうして、自分のよく使う処理をオリジナル関数として持っておくと使い回せて便利そうですね。

No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
]]>Webサイトの移転で必須のRedirect設定、.htaccessでやることが多いですが、
Apacheの設定ファイル・httpd.confでやってしまうと一括指定できて早いです。
<VirtualHost 192.168.0.200> ServerName old.example.jp Redirect permanent / http://www.example.com/ </VirtualHost>
上記例では、使わなくなったサブドメイン「old」をwwwに恒久的リダイレクトさせています。
複数のサブドメインを指定する際には、ServerAliasで設定すればOKです。

No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
]]>Apacheを再起動した際に、
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
というエラーが出る場合がある。
これでも起動はするので、Apache自体は動くのだが、エラーをそのままにしておくのは気持ちが悪いし、あとあと問題を引き起こす可能性が高い。
日本語訳をすると
ServerNameに127.0.0.1を使用した、FQDN(完全に適切なドメイン名)が確定できませんでした。
といった感じか。
このエラーは、/etc/hosts にlocalhost以外に自分で設定したホスト名が、Apacheの設定ファイルに定義されていないために発生する。
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 dacelo localhost.localdomain localhost
と書いた場合、/etc/httpd/conf/httpd.conf のServerNameの設定にも次のように書いておく。
# ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If this is not set to valid DNS name for your host, server-generated # redirections will not work. See also the UseCanonicalName directive. # # If your host doesn't have a registered DNS name, enter its IP address here. # You will have to access it by its address anyway, and this will make # redirections work in a sensible way. # #ServerName www.example.com:80 ServerName dacelo:80
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>とあるテーブルを違うテーブルに丸々コピーしたいとき。
一度でできる指定はないので、CREATEでテーブルを作ってから、中身をINSERTします。
INSERT INTO `TO_DB`.`TO_TABLE` SELECT * FROM `FROM_DB`.`FROM_TABLE`;
(例)
DB_NAMEというデータベースのconstructionというテーブルのバックアップを作りたい場合。
まずCREATE TABLEでconstructionBAKなどを作り…
INSERT INTO `DB_NAME`.`constructionBAK` SELECT * FROM `DB_NAME`.`construction`;
DB_NAMEのところを変更すれば、違うデータベースからのコピーもできます。
とあるテーブルのフィールドの中身を違うフィールドにコピーするのは簡単です。
UPDATE `TABLE` set `TO_FIELD`=`FROM_FIELD`
(テーブルTABLEのFROM_FIELDの内容がTO_FIELDにコピーされます)
(例)constructionのH1_TEXTをH2_TEXTにコピーする。
UPDATE `construction` set `H2_TEXT`=`H1_TEXT`
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>httpd.confでVirtualHostのアクセスログの保存方法と場所を指定する。
common … 共通のログファイルに書き込む
combined … 個別のログファイルに書き込む
…ということだと思うんですが、事実誤認があったら教えてください。
combinedって「結合」って意味ですよね。そう考えるとなんか個別のってのもおかしいような気がするんですが、今のところこれで動いております。
例
CustomLog /var/www/logs/dacelo.info-access_log common
</pre>
<pre class="mysql">
CustomLog /var/www/logs/blog.dacelo.info-access_log combined
</pre>
使用例
<pre class="mysql">
#DACELO Blog
<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot /home/dacelo/html
ServerName blog.dacelo.info
# ServerAlias test.dacelo.info
ErrorLog /var/www/logs/blog.dacelo.info-error_log
CustomLog /var/www/logs/blog.dacelo.info-access_log combined
</VirtualHost>
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>Linuxのサービスの中で、必須のものは、サーバー起動時に自動的に立ち上がるようにしておく。自動起動になっていないサービスは、サーバー再起動の度に手動で立ち上げなくてはならない。例えばApacheなどは必須中の必須なので、忘れずに自動起動にしておく。
サービスの自動起動設定を見るコマンド
[root@dacelo.info]# chkconfig --list
このコマンドで、サービスの一覧が出てくる。
httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off pand 0:off 1:off 2:off 3:off 4:off 5:off 6:off pcscd 0:off 1:off 2:off 3:off 4:off 5:off 6:off portmap 0:off 1:off 2:off 3:on 4:on 5:on 6:off postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
それぞれのランレベルの定義は、一般的なLinuxディストリビューションでは次の通り。
ランレベル システム状態 0 システム停止 1 シングルユーザモード 2 ローカルマルチユーザモード(NFSなどはなし) 3 フルマルチユーザモード(テキストコンソール) 4 未使用 5 フルマルチユーザモード(グラフィカル環境) 6 システム再起動
起動時に有効にするコマンド
# chkconfig サービス名 on
起動時に無効にするコマンド
# chkconfig サービス名 off
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>サイトの移転やデータの移し替えのときに、いちいちクライアントソフトでFTP接続してデスクトップに保存、また違うサーバーにつないでアップロード、は面倒ですよね。
リナックスサーバーをターミナルで操作できると、直接ファイル移動がセキュアにできて便利です。
scpコマンド
このscpコマンドは、SSHで暗号化してファイル転送をするUnixコマンドです。ローカル(転送元)からリモート(転送先)への転送、もしくはその逆ができます。
書式
scp ファイル名 リモートホストユーザ名@リモートホスト名:パス
オプション
-r ディレクトリを再帰的にコピー。フォルダ転送の場合に。
-p パーミッション、更新時刻などのファイル情報を保持。
-v 転送状況のログを画面に出力。
[使用例]
#./testディレクトリをexample.netの/home/usernameに転送 scp -r ./test username@example.net:/home/username username@ksknet.net's password: (パスワードを入力)
逆の場合
#example.netの/home/username/testを現ディレクトリに転送 scp -r username@example.net:/home/username/test ./
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>