PGメモ

非エンジニアの記録

さくらクラウドでメモリを増やしたらmysqlに繋がらない

solrが思ったよりメモリをくっていたので増強した。
その後起動してブラウザで見れるかと思ったら見れない。

エラーログを見ると・・

exception 'PDOException' with message 'could not find driver' in

メモリを増やす前は普通に動いてたのに・・なんだこれはと思い
pdo関係のものをごにょごにょした

# yum reinstall php*
# yum reinstall mysql*
# yum reinstall php-pdo

するとエラー内容が変わった

exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

とりあえず再起動

Another MySQL daemon already running with the same unix socket.
Starting mysqld:                                           [FAILED]

なんでかわからんがとりあえずキルしよう

ps aux | grep mysqld
root      6765  0.0  0.0   4356   728 pts/0    S+   17:35   0:00 grep mysqld

絶望。

どうしたらいいのかわからず調べたおしたら解決しました

# mv /var/lib/mysql.sock /var/lib/mysql.sock.bk
# chmod 777 /tmp
# service mysqld start

これでつながるようになります。
古いソケットを使う事をやめ、新しいものを作らせることで道の現象は解決。

ただなんで今回こうなったのか意味がわからない・・

solrで日本語形態素解析を使う

<?xml version="1.0" ?>

<schema name="title and description" version="1.1">
  <types>
    <fieldtype name="string"  class="solr.StrField" sortMissingLast="true" omitNorms="true" />
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0" />
    <fieldType name="text_ja" class="solr.TextField">
      <analyzer>
        <tokenizer class="solr.JapaneseTokenizerFactory" mode="search" userDictionary="lang/userdict_ja.txt" />
      </analyzer>
    </fieldType>
  </types>

 <fields>
  <!-- general -->
  <field name="id"  type="string"   indexed="true"  stored="true"  multiValued="false" required="true"/>
  <field name="title"  type="text_ja"   indexed="true"  stored="true"  multiValued="false" required="true"/>
  <field name="description"  type="text_ja"   indexed="true"  stored="true"  multiValued="false" required="true"/>
  <field name="_version_" type="long"      indexed="true"  stored="true"/>
 </fields>

こんな感じでsolr.JapaneseTokenizerFactoryを使う事で日本語形態素解析が使えるので
後は使いたいフィールドに適用するだけです。

※要solrの再起動とインデックスの張り直し

laravelで画面が真っ白になった時の解決法

プロジェクトの場所を移動した後画面が真っ白になってしまった。
routes.phpやコントローラーでのechoは表示される。
レンダリングがされていないのである。

解決方法としてはapp/storageの権限を書き込み可能に変えてやる。

単純にmvしただけでは権限ごと移動しないということでした。

さくらクラウドを始めた

さくらクラウド始めた。メモ

ユーザー追加

# useradd hoge
# passwd hoge

sshのセキュリティ

# vim /etc/ssh/sshd_config

Port xxx
PermitRootLogin no
PermitEmptyPasswords no
PasswordAuthentication no

# etc/init.d/sshd restart

Laravelを始める

話題かどうかはわからないがLaravelを始めてみる

ちなみにPHPは5.3.8以上が必要

Laravelプロジェクトを作るにはいくつか方法があるが
今回はLaravel Installerというのを使う。

# cd /usr/local/bin
# wget http://laravel.com/laravel.phar
# mv laravel.phar laravel
# chmod u+x laravel
# laravel
Laravel Craft version 1.0.0

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.

Available commands:
  help   Displays help for a command
  list   Lists commands
  new    Create a new Laravel application

あとはプロジェクトを作りたいディレクトリへ移動

# cd /var/www/blog
# laravel new blog
Crafting application...
Application ready! Build something amazing.

パーミッションを変更

# cd blog/app
# chmod -R 777 storage/

httpdをよしなに編集して見てみると・・

f:id:pg_sugarless:20131226150140j:plain

できました!