CentOS 7.3.1611にphp7.0.20をアンインストールするメモ

# php -v
PHP 7.0.20 (cli) (built: Jun 7 2017 07:50:14) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
# yum remove php
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
–> Running transaction check
—> Package php.x86_64 0:7.0.20-1.el7.remi will be erased
–> Finished Dependency Resolution
base/7/x86_64 | 3.6 kB 00:00:00
extras/7/x86_64 | 3.4 kB 00:00:00
extras/7/x86_64/primary_db | 188 kB 00:00:00
remi-safe | 2.9 kB 00:00:00
updates/7/x86_64 | 3.4 kB 00:00:00
updates/7/x86_64/primary_db | 7.7 MB 00:00:00

Dependencies Resolved

===========================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================
Removing:
php x86_64 7.0.20-1.el7.remi @remi-php70 8.3 M

Transaction Summary
===========================================================================================================================
Remove 1 Package

Installed size: 8.3 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : php-7.0.20-1.el7.remi.x86_64 1/1
Verifying : php-7.0.20-1.el7.remi.x86_64 1/1

Removed:
php.x86_64 0:7.0.20-1.el7.remi

Complete!

# yum –enablerepo=remi-php70 remove php\*
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
–> Running transaction check
—> Package php-cli.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-common.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-fpm.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-json.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-mbstring.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-mcrypt.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-mysqlnd.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-pdo.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-pear.noarch 1:1.10.5-2.el7.remi will be erased
—> Package php-process.x86_64 0:7.0.20-1.el7.remi will be erased
—> Package php-xml.x86_64 0:7.0.20-1.el7.remi will be erased
–> Finished Dependency Resolution
remi-php70 | 2.9 kB 00:00:00

Dependencies Resolved

===========================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================
Removing:
php-cli x86_64 7.0.20-1.el7.remi @remi-php70 13 M
php-common x86_64 7.0.20-1.el7.remi @remi-php70 7.9 M
php-fpm x86_64 7.0.20-1.el7.remi @remi-php70 4.2 M
php-json x86_64 7.0.20-1.el7.remi @remi-php70 80 k
php-mbstring x86_64 7.0.20-1.el7.remi @remi-php70 2.8 M
php-mcrypt x86_64 7.0.20-1.el7.remi @remi-php70 89 k
php-mysqlnd x86_64 7.0.20-1.el7.remi @remi-php70 888 k
php-pdo x86_64 7.0.20-1.el7.remi @remi-php70 381 k
php-pear noarch 1:1.10.5-2.el7.remi @remi-php70 2.1 M
php-process x86_64 7.0.20-1.el7.remi @remi-php70 187 k
php-xml x86_64 7.0.20-1.el7.remi @remi-php70 854 k

Transaction Summary
===========================================================================================================================
Remove 11 Packages

Installed size: 32 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : 1:php-pear-1.10.5-2.el7.remi.noarch 1/11
Erasing : php-cli-7.0.20-1.el7.remi.x86_64 2/11
Erasing : php-process-7.0.20-1.el7.remi.x86_64 3/11
Erasing : php-xml-7.0.20-1.el7.remi.x86_64 4/11
Erasing : php-fpm-7.0.20-1.el7.remi.x86_64 5/11
warning: /etc/php-fpm.d/www.conf saved as /etc/php-fpm.d/www.conf.rpmsave
Erasing : php-mcrypt-7.0.20-1.el7.remi.x86_64 6/11
Erasing : php-mysqlnd-7.0.20-1.el7.remi.x86_64 7/11
Erasing : php-pdo-7.0.20-1.el7.remi.x86_64 8/11
Erasing : php-mbstring-7.0.20-1.el7.remi.x86_64 9/11
Erasing : php-json-7.0.20-1.el7.remi.x86_64 10/11
Erasing : php-common-7.0.20-1.el7.remi.x86_64 11/11
Verifying : php-pdo-7.0.20-1.el7.remi.x86_64 1/11
Verifying : php-common-7.0.20-1.el7.remi.x86_64 2/11
Verifying : php-mbstring-7.0.20-1.el7.remi.x86_64 3/11
Verifying : php-mysqlnd-7.0.20-1.el7.remi.x86_64 4/11
Verifying : 1:php-pear-1.10.5-2.el7.remi.noarch 5/11
Verifying : php-cli-7.0.20-1.el7.remi.x86_64 6/11
Verifying : php-mcrypt-7.0.20-1.el7.remi.x86_64 7/11
Verifying : php-xml-7.0.20-1.el7.remi.x86_64 8/11
Verifying : php-process-7.0.20-1.el7.remi.x86_64 9/11
Verifying : php-fpm-7.0.20-1.el7.remi.x86_64 10/11
Verifying : php-json-7.0.20-1.el7.remi.x86_64 11/11

Removed:
php-cli.x86_64 0:7.0.20-1.el7.remi php-common.x86_64 0:7.0.20-1.el7.remi php-fpm.x86_64 0:7.0.20-1.el7.remi
php-json.x86_64 0:7.0.20-1.el7.remi php-mbstring.x86_64 0:7.0.20-1.el7.remi php-mcrypt.x86_64 0:7.0.20-1.el7.remi
php-mysqlnd.x86_64 0:7.0.20-1.el7.remi php-pdo.x86_64 0:7.0.20-1.el7.remi php-pear.noarch 1:1.10.5-2.el7.remi
php-process.x86_64 0:7.0.20-1.el7.remi php-xml.x86_64 0:7.0.20-1.el7.remi

Complete!

 

# rpm -q php
package php is not installed

phpのバージョンを再度確認する
# php -v
-bash: /usr/bin/php: No such file or directory

CentOS6(7)にhttpd操作コマンドメモ

CentOS6の場合
# sudo service httpd start
# sudo chkconfig httpd on

CentOS7の場合
sudo systemctl start httpd.service
sudo systemctl enable httpd.service

CentOS7.3.1611にphp7.0.20 + nginx1.10.2 + php-fpmをインストールするメモ

1.epelリポジトリのインストール
# yum -y install epel-release
# vi /etc/yum.repos.d/epel.repo
修正前
enabled=1
修正後
enabled=0

2.remiリポジトリの追加
# rpm –import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

3.nginxインストール
# yum install –enablerepo=epel nginx

4.nginx設定
# cd /etc/nginx/conf.d
# vi sample.conf
サンプルコード
server {
listen 80;
server_name xxxx.net;
root /usr/share/nginx/data/xxx;
index index.php;

charset utf-8;

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
}

5.nginx起動
# nginx -t
# systemctl start nginx

nginx自動起動設定
# systemctl enable nginx

6.php7インストール
# yum install –enablerepo=epel,remi-php70 php php-mbstring php-pear php-fpm php-mcrypt php-mysql

phpバージョン確認
# php -v

7.php-fpm設定
# cd /etc/php-fpm.d/
# cp -p www.conf www.conf_yyyymmdd
# vi www.conf

修正前
user = apache
group = apache

修正後
user = nginx
group = nginx

8.php-fpm起動
# systemctl start php-fpm
php-fpm自動起動設定
# systemctl enable php-fpm

9.MariaDBインストール
# yum install mariadb mariadb-server

MariaDB起動
# systemctl start mariadb

MariaDB自動設定
# systemctl enable mariadb

MariaDB設定
# mysql_secure_installation

文字コード設定
# cd /etc/my.cnf.d/
# cp -p server.cnf server.cnf_yyyymmdd
# vi server.cnf

追記
[mysqld]
character-set-server = utf8

「Struts2」BeanUtil.getClone()でオブジェクトをコピーするサンプル

サンプルコード

SAMPLE0100Bean nextForm = (SAMPLE0100Bean)next.getModel();
Object obj = BeanUtil.getClone(nextForm);

getSession().setAttribute(“KmDemoKey”, obj);

CentOSにyumでmysqlをインストールするメモ

 

1.versionの確認
#yum list mysql*

2.MySQLをインストール
#yum install mysql-server* -y

3.mySQL起動
#service mysqld start

4.mysqlにログイン
#mysql uroot -p

 

5.databaseの確認
#show databases;

6.データベースrootユーザの権限を修正

#grant all privileges on *.* to ‘root’@’%’ identified by ‘startNewsPwd#24’ with grant option;
#flush privileges

7.ファイアウォールの管理
有効:chkconfig iptables on
無効:chkconfig iptables off

 

起動:service iptables start
停止:service iptables stop

「Java」break、 return とcontinueの使い方サンプルコード

Javaコード

package itstudy;

public class LoopTest {

public static void main(String[] args) {
funcBreak();
funcContinue();
funcReturn();

}

static void funcBreak() {
for (int i = 0; i < 10; i++) {
if (i % 2 == 0) {
System.out.println(“i=” + i);
} else {
System.out.println(“break running、exit loop”);
break;
}
}
}

static void funcContinue() {
for (int i = 0; i < 10; i++) {
if (i % 2 == 0) {
System.out.println(“continue not run output i=” + i);
} else {
System.out.println(“continue run、exit loop!”);
continue;
}
}
}

@SuppressWarnings(“unused”)
static void funcReturn() {
for (int i = 0; i < 10; i++) {
System.out.println(“return run,exit funcReturn()”);
return;
}
}
}

実行結果

i=0
break running、exit loop
continue not run output i=0
continue run、exit loop!
continue not run output i=2
continue run、exit loop!
continue not run output i=4
continue run、exit loop!
continue not run output i=6
continue run、exit loop!
continue not run output i=8
continue run、exit loop!
return run,exit funcReturn()

「java」java.util.Collections.sort()の使い方

1.インタフェース
package com.changfa;
public class User implements Comparable<User>{
private String name;
private Integer order;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public int compareTo(User arg0) {
return this.getOrder().compareTo(arg0.getOrder());
}
}

 

2.Javaコード
package com.changfa;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class TestInter {

public static void main(String[] args) {

User user1 = new User();
user1.setName(“yamada”);
user1.setOrder(1);
User user2 = new User();
user2.setName(“aso”);
user2.setOrder(2);
List<User> list = new ArrayList<User>();
//要素追加
list.add(user2);
list.add(user1);
Collections.sort(list);
for(User u : list){
System.out.println(u.getName());
}

}

}

3.実行結果
yamada
aso

「Java」Hashmapのソート方法(key)を実行するサンプルコード

Javaコード
Object[] keyArr = hashmap.keySet().toArray();
Arrays.sort(keyArr);
for  (Object key : keyArr) {
Object value = hashmap.get(key);
}

[Java]BufferedImageとbyte「」配列を相互変換するサンプルコード

Javaコード
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Label;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ImageUtil {

/**
* BufferedImage->byte[]
*
* @param bImage
* @param format
* @return byte「」
*/
public static byte[] imageToBytes(BufferedImage bImage, String format) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
ImageIO.write(bImage, format, out);
} catch (IOException e) {
e.printStackTrace();
}
return out.toByteArray();
}

/**
* byte[]->Image
*
* @param bytes
* @return Image
*/
public static Image bytesToImage(byte[] bytes) {
Image image = Toolkit.getDefaultToolkit().createImage(bytes);
try {
MediaTracker mt = new MediaTracker(new Label());
mt.addImage(image, 0);
mt.waitForAll();
} catch (InterruptedException e) {
e.printStackTrace();
}

return image;
}
}

「Android」SQLiteデータベースを使用するトランザクションのサンプルコード

db.beginTransaction();  //トランザクション開始
try{
//パッチ処理
for(Collection c:colls){

insert(db, c);
}

db.setTransactionSuccessful(); //トランザクション実行成功
}catch(Exception e){

MyLog.printStackTraceString(e);

}finally{

db.endTransaction(); //トランザクション完了

}