Composer インストール
①composer.pharをダウンロードする
$ curl -sS https://getcomposer.org/installer | php
動作するかチェック
$ php composer.phar
composer.json composer.lock あるかをチェック
PHP Fatal error: Call to a member function prepare() on a non-object
データベースの接続がうまくいってないのが原因です。
試しで下の接続方法で接続してみた。
$link = pg_connect("host=localhost dbname=db user=usr password=pass");
FATAL: Ident authentication failed for use 'hoge_user' が出ました。
postgresqlがうまく動いているかを確認してみるのがいいと思います。
再起動してみる
#su - postgres
-bash-4.1$pg_ctl start -w
あれれ
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....2016-02-14 14:00:00 GMT [4244]LOG: could not bind IPv4 socket: Address already in use
2016-02-14 14:00:00 GMT [4244]HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2016-02-14 14:00:00 GMT [4244]LOG: could not bind IPv6 socket: Address already in use
2016-02-14 14:00:00 GMT [4244]HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2016-02-14 14:00:00 GMT [4244]WARNING: could not create listen socket for "*"
2016-02-14 14:00:00 GMT [4244]FATAL: could not create any TCP/IP sockets
.... stopped waiting
pg_ctl: could not start server
Examine the log output
起動失敗
-bash-4.1$ lsof -i:5432
-bash-4.1$ kill PID
再度起動(よっうまくいった)
接続みてみたら治った。よかった
AngularJSでPOST
$_POST['hoge']や$this->request->data['hoge']で受け取れない!!調べた結果下記の様になら取れる
postdata = file_get_contents("php://input");
request=json_decode(postada);
AngularJS APIでPOSTのやり方(JS側ね)
<!doctype html> <html land="ja" ng-app="myApp"> <head> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script> //app var app = angular.module('myApp',[]); //controller app.controller('myCtrl',function($scope,$http){ $http.post(url,postdatas,{ headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, }) .success(function(response){ //response $scope.name = response.name; $scope.email = response.email; }); }); </script> </head> <body> <div ng-controller="myCtrl"> {{name}}<br> {{email}} </div> </body> </script>
PHP側受け取る
<?php $name = "default"; $email = "default@test.com"; $postdata = file_get_contents("php://input"); $request = json_decode($postdata);
header("Content-type: application/json"); echo json_encode($res);
Composerでプラグインをインストールする時のエラー
composer update
Your requirements could not be resolved to an installable set of packages.
Problem 1
- cakephp/cakephp 2.6.9 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.8 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.7 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.6 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.5 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.4 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.3 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.2 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.12 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.11 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.10 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.1 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.0 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- cakephp/cakephp 2.6.8 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- Installation request for cakephp/cakephp 2.6.* -> satisfiable by cakephp/cakephp[2.6.0, 2.6.1, 2.6.10, 2.6.11, 2.6.12, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.6.6, 2.6.7, 2.6.8, 2.6.9].
mcryptがないようと怒られる
$sudo apt-get install php5-mcrypt
再度試せばOK
WordPress構築「Vagrant+PHP+Mysql+Apache」
①Vagrant作成
Vagrantfile作成
vagrant init Box名
Vagrantfileが存在するディレクトリでvagrant upを実行
②PHP5.6インストール
Centos6.0用
# For CentOS 6.5, 6.4, ...
% sudo rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
% sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Centos7.0用
# For CentOS 7.0
$ sudo rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
% sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum listパケージを確認する
% yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
インストール
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum --enablerepo=remi --enablerepo=remi-php56 install php php-mbstring php-mysql
*色々コマンドインストール
sudo yum install vim-enhanced git zsh dstat sysstat ccze s3cmd wget
③MySQLインストール
rpmを追加する
yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
インストール
yum install mysql mysql-devel mysql-server mysql-utilities
設定ファイル
MySQL の起動、自動起動設定
セキュリティ強化
データベース作成
データベースを「wordpress」ユーザー名を「wpadmin」パスワードを「password」で作成します。
④Apache のインストール
設定ファイル
⑤WordPress のインストール
https://ja.wordpress.org/ から最新版をダウンロードします。
設定ファイル
動作確認
http://[wordpress.confで設定したドメイン] をブラウザで開きます。
Basic 認証の設定
管理画面にBasic 認証を設定します。
鍵の生成
ユーザー名を「wordpress」 パスワードを「password」にします。
設定を反映
sudo ln -s /vagrant/hoge /var/www/html
* .htaccessを/html の直下に作成
権限を755にする
アクセル確認
http://VagrantFileのIP 設定値/wordpress/wp-admin/install.php