centosにlaravel5.2をインストールする

まずcomposerを入れます

[vagrant@localhost laravel]$ curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.8.4) successfully installed to: /home/vagrant/local/app/laravel/composer.phar
Use it: php composer.phar

[vagrant@localhost laravel]$ ls
composer.phar

続いてcomposerを入れます。
[vagrant@localhost laravel]$ php composer.phar create-project laravel/laravel blog “5.2.*”
Installing laravel/laravel (v5.2.31)
– Installing laravel/laravel (v5.2.31): Downloading (100%)
Created project in blog
> php -r “copy(‘.env.example’, ‘.env’);”
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 57 installs, 0 updates, 0 removals
– Installing symfony/polyfill-ctype (v1.11.0): Downloading (100%)
– Installing vlucas/phpdotenv (v2.6.1): Downloading (100%)
– Installing symfony/polyfill-mbstring (v1.11.0): Downloading (100%)
– Installing symfony/var-dumper (v3.0.9): Downloading (100%)
– Installing symfony/translation (v3.0.9): Downloading (100%)
– Installing symfony/routing (v3.0.9): Downloading (100%)
– Installing symfony/process (v3.0.9): Downloading (100%)
– Installing symfony/polyfill-util (v1.11.0): Downloading (100%)
– Installing symfony/polyfill-php56 (v1.11.0): Downloading (100%)
– Installing psr/log (1.1.0): Downloading (100%)
– Installing symfony/debug (v3.0.9): Downloading (100%)
– Installing paragonie/random_compat (v1.4.3): Downloading (100%)
– Installing symfony/http-foundation (v3.0.9): Downloading (100%)
– Installing symfony/event-dispatcher (v3.4.24): Downloading (100%)
– Installing symfony/http-kernel (v3.0.9): Downloading (100%)
– Installing symfony/finder (v3.0.9): Downloading (100%)
– Installing symfony/console (v3.0.9): Downloading (100%)
– Installing swiftmailer/swiftmailer (v5.4.12): Downloading (100%)
– Installing jakub-onderka/php-console-color (v0.2): Loading from cache
– Installing jakub-onderka/php-console-highlighter (v0.3.2): Loading from cache
– Installing dnoegel/php-xdg-base-dir (0.1): Loading from cache
– Installing nikic/php-parser (v2.1.1): Downloading (100%)
– Installing psy/psysh (v0.7.2): Downloading (100%)
– Installing nesbot/carbon (1.36.2): Downloading (100%)
– Installing mtdowling/cron-expression (v1.2.1): Downloading (100%)
– Installing monolog/monolog (1.24.0): Downloading (100%)
– Installing league/flysystem (1.0.51): Downloading (100%)
– Installing jeremeamia/superclosure (2.4.0): Downloading (100%)
– Installing doctrine/inflector (v1.3.0): Loading from cache
– Installing classpreloader/classpreloader (3.2.0): Downloading (100%)
– Installing laravel/framework (v5.2.45): Downloading (100%)
– Installing fzaninotto/faker (v1.8.0): Loading from cache
– Installing hamcrest/hamcrest-php (v1.2.2): Downloading (100%)
– Installing mockery/mockery (0.9.11): Downloading (100%)
– Installing sebastian/version (1.0.6): Downloading (100%)
– Installing sebastian/global-state (1.1.1): Downloading (100%)
– Installing sebastian/recursion-context (1.0.5): Downloading (100%)
– Installing sebastian/exporter (1.2.2): Downloading (100%)
– Installing sebastian/environment (1.3.8): Downloading (100%)
– Installing sebastian/diff (1.4.3): Downloading (100%)
– Installing sebastian/comparator (1.2.4): Downloading (100%)
– Installing symfony/yaml (v3.3.18): Downloading (100%)
– Installing doctrine/instantiator (1.2.0): Downloading (100%)
– Installing webmozart/assert (1.4.0): Loading from cache
– Installing phpdocumentor/reflection-common (1.0.1): Loading from cache
– Installing phpdocumentor/type-resolver (0.4.0): Loading from cache
– Installing phpdocumentor/reflection-docblock (4.3.0): Loading from cache
– Installing phpspec/prophecy (1.8.0): Loading from cache
– Installing phpunit/php-text-template (1.2.1): Loading from cache
– Installing phpunit/phpunit-mock-objects (2.3.8): Downloading (100%)
– Installing phpunit/php-timer (1.0.9): Downloading (100%)
– Installing phpunit/php-token-stream (1.4.12): Downloading (100%)
– Installing phpunit/php-file-iterator (1.4.5): Loading from cache
– Installing phpunit/php-code-coverage (2.2.4): Downloading (100%)
– Installing phpunit/phpunit (4.8.36): Downloading (100%)
– Installing symfony/css-selector (v3.0.9): Downloading (100%)
– Installing symfony/dom-crawler (v3.0.9): Downloading (100%)
symfony/var-dumper suggests installing ext-symfony_debug
symfony/translation suggests installing symfony/config
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/routing suggests installing symfony/dependency-injection (For loading routes from a service)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/class-loader
symfony/http-kernel suggests installing symfony/config
symfony/http-kernel suggests installing symfony/dependency-injection
psy/psysh suggests installing ext-posix (If you have PCNTL, you’ll want the POSIX extension as well.)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
nesbot/carbon suggests installing friendsofphp/php-cs-fixer (Needed for the `composer phpcs` command. Allow to automatically fix code style.)
nesbot/carbon suggests installing phpstan/phpstan (Needed for the `composer phpstan` command. Allow to detect potential errors.)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver and SES mail driver (~3.0).)
laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (~2.4).)
laravel/framework suggests installing guzzlehttp/guzzle (Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~5.3|~6.0).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (~1.0).)
laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (~3.0).)
laravel/framework suggests installing predis/predis (Required to use the redis cache and queue drivers (~1.0).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (~2.0).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to use psr7 bridging features (0.2.*).)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
> php artisan key:generate
Application key [base64:sUn17M/EiRwxEa7zX4KeegTu28WLYvPgTY47Sdj85/A=] set successfully.
[vagrant@localhost laravel]$ ls
blog composer.phar

入りました。

xargs

The command “xargs” reads the list from standard input or a file, and creates and executes a command line.
For example, the output of one command can be piped into an xargs command and specified as an argument of another command.

[vagrant@localhost ~]$ cd /var/www/cgi-bin
[vagrant@localhost cgi-bin]$ find . -name “*” | xargs grep select
grep: .: ディレクトリです
./app.cgi:my $sth = $db->prepare(“select * from name;”);

Perl DBIでselect

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| items          |
| name           |
| news           |
| user           |
+----------------+
4 rows in set (0.00 sec)

mysql> select * from items;
+---------+---------+-------+
| item_id | name    | price |
+---------+---------+-------+
|       1 | U+1F363 |  NULL |
+---------+---------+-------+
1 row in set (0.00 sec)

#!/usr/bin/perl --

use CGI;
use DBI;

print "Content-type:text/html\n\n";
print "hello";
my $user = 'root';
my $passwd = '';
my $db = DBI->connect('DBI:mysql:test:localhost', $user, $passwd);
my $sth = $db->prepare("select * from items;");
$sth->execute();
while (my $ary_ref = $sth->fetchrow_arrayref){
	my($a, $b) = @$ary_ref;
	print "$a, $b\n";
}
$sth->finish;
$dbh->disconnect;

OKなんだけど、これ、tableで表示するとき、whileが2つになるけど、どうするんだっけ?

print "<table>";
while (my $ary_ref = $sth->fetchrow_arrayref){
	my($a, $b) = @$ary_ref;
	print "<tr><td>$a</td><td>$b</td></tr>\n";
}
print "</table>";

tableはtableで良いんだが。。

Perl mysqlで文字化けするとき

Perlで入れて、文字化けしてる!?

my $user = 'root';
my $passwd = '';
my $db = DBI->connect('DBI:mysql:click:localhost', $user, $passwd);
my $sth = $db->prepare("INSERT INTO _mng(user_id, password, last_name, first_name, dept) VALUES (?, ?, ?, ?, ?)");
$sth->execute($user_id, $password, $last_name, $first_name, $dept);
+---------+----------+----------------+--------------+---------------------+----------------------+------------------------+----------------+----------------------+-----------------------+---------------------------+---------------+-------------+---------------+-------------+
| aaa     | hoge     | �田         | 太郎       | 管�部           | NULL                 | NULL                   |           NULL | NULL                 | NULL                  | NULL                      | NULL          | NULL        | NULL          | NULL        |
| eda     | hoge     | 江藤         | �          | 管�部           | NULL                 | NULL                   |           NULL | NULL                 | NULL                  | NULL                      | NULL          | NULL        | NULL          | NULL        |
| hoge    | hoge     | 山田         | 太郎       | 管�部           | NULL                 | NULL                   |           NULL | NULL                 | NULL                  | NULL                      | NULL          | NULL        | NULL          | NULL        |
| ykk     | hoge     | 高橋         | �          | 管�部           | NULL                 | NULL                   |           NULL | NULL                 | NULL                  | NULL                      | NULL          | NULL        | NULL          | NULL        |
+---------+----------+----------------+--------------+---------------------+----------------------+------------------------+----------------+----------------------+-----------------------+---------------------------+---------------+-------------+---------------+-------------+
4 rows in set (0.00 sec)

set name utf8がない模様

my $user = ‘root’;
my $passwd = ”;
my $db = DBI->connect(‘DBI:mysql:click:localhost’, $user, $passwd);
my $sth = $db->prepare(“INSERT INTO mng(user_id, password, last_name, first_name, dept) VALUES (?, ?, ?, ?, ?)”);
$db->do(“set names utf8”);
$sth->execute($user_id, $password, $last_name, $first_name, $dept);

+———+———-+—————-+————–+———————+———————-+————————+—————-+———————-+———————–+—————————+—————+————-+—————+————-+
| aaa | hoge | �田 | 太郎 | 管�部 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| eda | hoge | 江藤 | � | 管�部 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| hoge | hoge | 山田 | 太郎 | 管�部 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| sakura | sakura | さくら | たかし | 管理部 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| ykk | hoge | 高橋 | � | 管�部 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
+———+———-+—————-+————–+———————+———————-+————————+—————-+———————-+———————–+—————————+—————+————-+—————+————-+
5 rows in set (0.00 sec)

日本語で入りましたねー

jsからCanvas

<!DOCTYPE html>
<html lang="ja">
<head>
	<meta charset="UTF-8">
	<title>JavaScriptでスクリーンショット</title>
</head>

<body>
	<hr>
	<div style="background-color : #AAEEDD"><h1>JavaScriptで撮るスクリーンショット</h1></div>
	<div id="target">
	<h2>導入方法と処理概要</h2>
	<table border="1" width="500" cellspacing="0" cellpadding="5" bordercolor="#333333" style="table-layout: fixed;">
	<tr>
		<th bgcolor="#7b9ad0" width="40"><font color="#FFFFFF">No</font></th>
		<th bgcolor="#7b9ad0" width="230"><font color="#FFFFFF">概要</font></th>
		<th bgcolor="#7b9ad0" width="230"><font color="#FFFFFF">補足</font></th>
	</tr>
	<tr>
		<td bgcolor="#b1d7e4" width="40" align="right">1</td>
		<td bgcolor="#7b9ad0" width="230">任意のタイミングでhtml2canvas関数を呼ぶ</td>
		<td bgcolor="#7b9ad0" width="230">※今回はオンロード処理</td>
	</tr>
	<tr>
		<td bgcolor="#b1d7e4" width="40" align="right">2</td>
		<td bgcolor="#7b9ad0" width="230">任意のタイミングでhtml2canvas関数を呼ぶ</td>
		<td bgcolor="#7b9ad0" width="230">※今回はオンロード処理</td>
	</tr>
	<tr>
		<td bgcolor="#b1d7e4" width="40" align="right">3</td>
		<td bgcolor="#7b9ad0" width="230">onrendered処理にて指定のElementに画像を追記</td>
		<td bgcolor="#7b9ad0" width="230">※[img]タグの[src]や、[a]タグの[href]など</td>
	</tr>
</table>
</div>
<br>
<hr>
<h3>↓↓ここから画像↓↓ (上の対象のDIVを画像化)</h3>
<img src="" id="result">
<h3>↑↑ここまで画像↑↑</h3>

<hr>

<a href="" id="ss" download="html_ss.png">スクリーンショット(document.body全体)をダウンロード</a>
<hr>
<h3>注意</h3>
<ul>
	<li>実際にはスクリーンショットを撮っているわけではない</li>
	<li>html2canvasは、HTML内のDOMやCCSを解釈してCanvas上に描画するライブラリ</li>
	<li>つまり、レンダリングエンジンに近い動作をする</li>
	<li>そのため、ブラウザと異なる表示がされる場合がある</li>
	<li>flashやapplet, iframe(別URL)はうまくキャプチャできない</li>
</ul>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script>
	window.onload = function(){

		html2canvas(document.getElementById("target"),{
			onrendered: function(canvas){
				var imgData = canvas.toDataURL();
				document.getElementById("result").src = imgData;
			}
		});

		html2canvas(document.body, {
			onrendered: function(canvas){
				var imgData = canvas.toDataURL();
				document.getElementById("ss").href = imgData;
			}
		});
	}
</script>
</body>
</html>

Canvasでiconを作る

<style>
	ul.icon{
		list-style:none;
	}
	ul.icon li {
		position: relative;
		margin-bottom: 0.5em;
	}
	ul.icon li canvas {
		position: absolute;
		top: 0.3em;
		left: -13px;
	}
</style>
<ul class="icon">
	<li>item01</li>
	<li>item02</li>
	<li>item03</li>
	<li>item04</li>
	<li>item05</li>
</ul>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
	var list = $('ul.icon li');
	list.prepend('<canvas width="20" height="20" />');
	var ctx = null;

	list.each(function (i){
		var canvas = $('canvas', list).get(i);
		ctx = canvas.getContext('2d');
		drawIcon();
	});

	function drawIcon(){
		ctx.beginPath();
		ctx.arc(6, 10, 6, 0, Math.PI*2);
		ctx.fillStyle = 'rgb(50, 150, 255)';
		ctx.fill();

		ctx.beginPath();
		ctx.moveTo(5, 7);
		ctx.lineTo(8, 9);
		ctx.lineTo(5, 12);
		ctx.closePath();
		ctx.fillStyle = 'rgb(255, 255, 255)';
		ctx.fill();
	}
});
</script>

なるほどー

SAML

SAML is an abbreviation of Security Assertion Markup Language and is called “Samuru”.

SAML is a standard of authentication information developed by OASIS for authenticating users between different Internet domains. In other words, it refers to a rule protocol that exchanges user credentials.

Idp (= Identify Provider) is a system that provides authentication information. Without SAML, it is necessary to convert the format and format of information when the IdP and SP exchange information. You can save the trouble of that work.

Convenient improvement
With SSO, you can log in to different services with or user authentication. Because you do not need to authenticate each time, you can use the service comfortably.

Security improvements
Some users may be uneasy about the availability of many services with one authentication system. However, considering that most users use the same ID and password for all services and that only one login information needs to be managed securely, it can be said that there are security advantages as well.

apache execute user

To change the user running Apache, you need to change the user specification in httpd.conf. If nothing is specified, the daemon user is specified.

[vagrant@localhost ~]$ ps aux | grep http
root 2040 0.0 2.4 384472 12512 ? Ss 11:44 0: 02 /usr/sbin/httpd
jenkins 2083 0.5 56.8 2273640 285232 ? Ssl 11:45 2: 54 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -D java.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /u sr/lib/jenkins/jenkins.war –logfile=/var/log/jenkins/jenkins. log –webroot=/var/cache/jenkins/war –daemon –httpPort=8080 –debug=5 –handlerCountMax=100 –handlerCountMaxIdle=20
apache 2488 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2489 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2490 0.0 2.0 386112 10300 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2491 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2492 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2493 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2494 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2495 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
vagrant 4449 0.0 0.1 103320 872 pts/0 D+ 20:52 0: 00 grep http
うーん、apacheって書いてあるように見える。。

[vagrant@localhost ~]$ id apache
uid=48(apache) gid=48(apache) 所属グループ=48(apache)

migrationファイルによるカラム修正

<?php

use Illuminate\Support\Facades\Schema\;
use Illuminate\Database\Schema\Blueprint\;
use Innuminate\Database\Migrations\Migration;

class AddColumnSalesHogeTable extends Migration{

	public function up(){
		Schema::table('books', function(Blueprint $table){
			$table->integer('sales')->default(0)->index('index_sales')->after('price')->comment('販売数');
		});
	}

	public function down()
	{
		Schema::table('books', function(Blueprint $table){
			$table->dropColumn('sales');
		});
	}
}