CentOS7 PHP7 oci8.so 설치

PHP 2017. 11. 7. 18:04

1. php70w 설치



[root@centos-linux ellord]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

[root@centos-linux ellord]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm



[root@centos-linux ellord]# yum install php70w



[root@centos-linux ellord]# yum install php70w-mysqlnd php70w-pdo php70w-pgsql php70w-odbc php70w-mbstring php70w-mcrypt php70w-gd php70w-pear php70w-pdo_dblib php70w-pecl-imagick php70w-pecl-imagick-devel php70w-xml php70w-xmlrpc




2. oracle-instantclient 를 다운받는다.


http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html


11.2.0.4.0 버전으로 아래 두개의 파일을 받는다.


oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm


oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm





3. 다운받은 rpm 파일을 설치한다.


[root@centos-linux ellord]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

[root@centos-linux ellord]# rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm




4. oci8모듈 소스를 다운 받는다.


[root@centos-linux ellord]# pecl install oci8

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update

downloading oci8-2.1.8.tgz ...

Starting to download oci8-2.1.8.tgz (194,154 bytes)

.........................................done: 194,154 bytes

11 source files, building

running: phpize

Configuring for:

PHP Api Version:         20151012

Zend Module Api No:      20151012

Zend Extension Api No:   320151012

Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : instantclient,/usr/lib/oracle/11.2/client64/lib



[autodetect] : 부분에 instantclient,/usr/lib/oracle/11.2/client64/lib

와 같이 입력해 준다.


아래와 같이 자동으로 컴파일하고 oci8.so 파일이 만들어진다.


building in /var/tmp/pear-build-root87TwHg/oci8-2.1.8

running: /var/tmp/oci8/configure --with-php-config=/usr/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for a sed that does not truncate output... /usr/bin/sed

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for PHP prefix... /usr

checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib

checking for PHP extension directory... /usr/lib64/php/modules

checking for PHP installed headers prefix... /usr/include/php

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... no

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

checking for gawk... gawk

checking for Oracle Database OCI8 support... yes, shared

checking PHP version... 7.0.24, ok

checking OCI8 DTrace support... no

checking size of long int... 8

checking checking if we're on a 64-bit platform... yes

checking Oracle Instant Client directory... /usr/lib/oracle/11.2/client64/lib

checking Oracle Instant Client SDK header directory... /usr/include/oracle/11.2/client64

checking Oracle Instant Client library version compatibility... 11.1

checking how to print strings... printf

checking for a sed that does not truncate output... (cached) /usr/bin/sed

checking for fgrep... /usr/bin/grep -F

checking for ld used by cc... /usr/bin/ld

checking if the linker (/usr/bin/ld) is GNU ld... yes

checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B

checking the name lister (/usr/bin/nm -B) interface... BSD nm

checking whether ln -s works... yes

checking the maximum length of command line arguments... 1572864

checking whether the shell understands some XSI constructs... yes

checking whether the shell understands "+="... yes

checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop

checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop

checking for /usr/bin/ld option to reload object files... -r

checking for objdump... objdump

checking how to recognize dependent libraries... pass_all

checking for dlltool... no

checking how to associate runtime and link libraries... printf %s\n

checking for ar... ar

checking for archiver @FILE support... @

checking for strip... strip

checking for ranlib... ranlib

checking for gawk... (cached) gawk

checking command to parse /usr/bin/nm -B output from cc object... ok

checking for sysroot... no

checking for mt... no

checking if : is a manifest tool... no

checking for dlfcn.h... yes

checking for objdir... .libs

checking if cc supports -fno-rtti -fno-exceptions... no

checking for cc option to produce PIC... -fPIC -DPIC

checking if cc PIC flag -fPIC -DPIC works... yes

checking if cc static flag -static works... no

checking if cc supports -c -o file.o... yes

checking if cc supports -c -o file.o... (cached) yes

checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes

checking whether -lc should be explicitly linked in... no

checking dynamic linker characteristics... GNU/Linux ld.so

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... no

configure: creating ./config.status

config.status: creating config.h

config.status: executing libtool commands

running: make

/bin/sh /var/tmp/pear-build-root87TwHg/oci8-2.1.8/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8.c -o oci8.lo

libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8.c  -fPIC -DPIC -o .libs/oci8.o

/bin/sh /var/tmp/pear-build-root87TwHg/oci8-2.1.8/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_lob.c -o oci8_lob.lo

libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_lob.c  -fPIC -DPIC -o .libs/oci8_lob.o

/bin/sh /var/tmp/pear-build-root87TwHg/oci8-2.1.8/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_statement.c -o oci8_statement.lo

libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_statement.c  -fPIC -DPIC -o .libs/oci8_statement.o

/bin/sh /var/tmp/pear-build-root87TwHg/oci8-2.1.8/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_collection.c -o oci8_collection.lo

libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_collection.c  -fPIC -DPIC -o .libs/oci8_collection.o

/bin/sh /var/tmp/pear-build-root87TwHg/oci8-2.1.8/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_interface.c -o oci8_interface.lo

libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_interface.c  -fPIC -DPIC -o .libs/oci8_interface.o

/bin/sh /var/tmp/pear-build-root87TwHg/oci8-2.1.8/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_failover.c -o oci8_failover.lo

libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_failover.c  -fPIC -DPIC -o .libs/oci8_failover.o

/bin/sh /var/tmp/pear-build-root87TwHg/oci8-2.1.8/libtool --mode=link cc -DPHP_ATOM_INC -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/include -I/var/tmp/pear-build-root87TwHg/oci8-2.1.8/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -o oci8.la -export-dynamic -avoid-version -prefer-pic -module -rpath /var/tmp/pear-build-root87TwHg/oci8-2.1.8/modules  oci8.lo oci8_lob.lo oci8_statement.lo oci8_collection.lo oci8_interface.lo oci8_failover.lo -Wl,-rpath,/usr/lib/oracle/11.2/client64/lib -L/usr/lib/oracle/11.2/client64/lib -lclntsh

libtool: link: cc -shared  -fPIC -DPIC  .libs/oci8.o .libs/oci8_lob.o .libs/oci8_statement.o .libs/oci8_collection.o .libs/oci8_interface.o .libs/oci8_failover.o   -L/usr/lib/oracle/11.2/client64/lib -lclntsh  -O2 -Wl,-rpath -Wl,/usr/lib/oracle/11.2/client64/lib   -Wl,-soname -Wl,oci8.so -o .libs/oci8.so

libtool: link: ( cd ".libs" && rm -f "oci8.la" && ln -s "../oci8.la" "oci8.la" )

/bin/sh /var/tmp/pear-build-root87TwHg/oci8-2.1.8/libtool --mode=install cp ./oci8.la /var/tmp/pear-build-root87TwHg/oci8-2.1.8/modules

libtool: install: cp ./.libs/oci8.so /var/tmp/pear-build-root87TwHg/oci8-2.1.8/modules/oci8.so

libtool: install: cp ./.libs/oci8.lai /var/tmp/pear-build-root87TwHg/oci8-2.1.8/modules/oci8.la

libtool: finish: PATH="/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /var/tmp/pear-build-root87TwHg/oci8-2.1.8/modules

----------------------------------------------------------------------

Libraries have been installed in:

   /var/tmp/pear-build-root87TwHg/oci8-2.1.8/modules


If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable

     during execution

   - add LIBDIR to the `LD_RUN_PATH' environment variable

     during linking

   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag

   - have your system administrator add LIBDIR to `/etc/ld.so.conf'


See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------


Build complete.

Don't forget to run 'make test'.


running: make INSTALL_ROOT="/var/tmp/pear-build-root87TwHg/install-oci8-2.1.8" install

Installing shared extensions:     /var/tmp/pear-build-root87TwHg/install-oci8-2.1.8/usr/lib64/php/modules/

running: find "/var/tmp/pear-build-root87TwHg/install-oci8-2.1.8" | xargs ls -dils

  1252758   0 drwxr-xr-x. 3 root root     17 11월  7 17:46 /var/tmp/pear-build-root87TwHg/install-oci8-2.1.8

101046009   0 drwxr-xr-x. 3 root root     19 11월  7 17:46 /var/tmp/pear-build-root87TwHg/install-oci8-2.1.8/usr

  1252759   0 drwxr-xr-x. 3 root root     17 11월  7 17:46 /var/tmp/pear-build-root87TwHg/install-oci8-2.1.8/usr/lib64

 34473647   0 drwxr-xr-x. 3 root root     21 11월  7 17:46 /var/tmp/pear-build-root87TwHg/install-oci8-2.1.8/usr/lib64/php

 67823917   0 drwxr-xr-x. 2 root root     21 11월  7 17:46 /var/tmp/pear-build-root87TwHg/install-oci8-2.1.8/usr/lib64/php/modules

 67823918 584 -rwxr-xr-x. 1 root root 595672 11월  7 17:46 /var/tmp/pear-build-root87TwHg/install-oci8-2.1.8/usr/lib64/php/modules/oci8.so


Build process completed successfully

Installing '/usr/lib64/php/modules/oci8.so'

install ok: channel://pecl.php.net/oci8-2.1.8

configuration option "php_ini" is not set to php.ini location

You should add "extension=oci8.so" to php.ini




해당 디렉토리로 가 본다.


[root@centos-linux conf.d]# cd /usr/lib64/php/modules/

[root@centos-linux modules]# ls

bz2.so       exif.so      gmp.so       mcrypt.so          pdo.so          pdo_sqlite.so  simplexml.so  sysvshm.so    xmlrpc.so

calendar.so  fileinfo.so  iconv.so     mysqlnd.so         pdo_dblib.so    pgsql.so       sockets.so    tokenizer.so  xmlwriter.so

ctype.so     ftp.so       imagick.so   mysqlnd_mysqli.so  pdo_mysqlnd.so  phar.so        sqlite3.so    wddx.so       xsl.so

curl.so      gd.so        json.so      oci8.so            pdo_odbc.so     posix.so       sysvmsg.so    xml.so        zip.so

dom.so       gettext.so   mbstring.so  odbc.so            pdo_pgsql.so    shmop.so       sysvsem.so    xmlreader.so


oci8.so 파일이 만들어져 있다.


퍼미션을 조절해 준다.

[root@centos-linux modules]# chmod 755 oci8.so




5. php.ini 파일에 extension 을 추가해 준다.


;;;;;;;;;;;;;;;;;;;;;;

; Dynamic Extensions ;

;;;;;;;;;;;;;;;;;;;;;;

extension=oci8.so





6. 아파치를 재시작하고 phpinfo 를 해본다.


아래와 같이 등록되어 있다.


oci8

OCI8 Supportenabled
OCI8 DTrace Supportdisabled
OCI8 Version2.1.8
Revision$Id: 8a26cf66ca0f9556b6376408c8f71ead69bdbcbf $
Oracle Run-time Client Library Version11.2.0.4.0
Oracle Compile-time Instant Client Version11.2
DirectiveLocal ValueMaster Value
oci8.connection_classno valueno value
oci8.default_prefetch100100
oci8.eventsOffOff
oci8.max_persistent-1-1
oci8.old_oci_close_semanticsOffOff
oci8.persistent_timeout-1-1
oci8.ping_interval6060
oci8.privileged_connectOffOff
oci8.statement_cache_size2020
Statistics
Active Persistent Connections0
Active Connections0




끝.











'PHP' 카테고리의 다른 글

단방향 암호화 문자열 crypt sha512 암호화  (0) 2019.01.08
CentOS7 에서 php7.2 yum 설치  (0) 2018.06.07
php-mcrypt 설치가 안될 때  (0) 2017.11.05
페이징 및 함수이용  (0) 2016.03.01
MySQL 트랜잭션  (0) 2016.02.29
블로그 이미지

엘로드넷

,

이니시스 결제모듈연동시 mcrypt 가 필요하다.



yum install php-mcrypt 하니 아래와 같은 에러가 발생하고 설치되지 않는다.


[root@localhost ~]# yum list php-mcrypt

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: ftp.daumkakao.com

 * extras: centos.mirror.cdnetworks.com

 * updates: centos.mirror.cdnetworks.com

Error: No matching Packages to list




epel-release 를 먼저 설치한 후 시도하면 된다.

[root@localhost ~]# yum install epel-release

Loaded plugins: fastestmirror

base                                                                    | 3.6 kB  00:00:00     

extras                                                                  | 3.4 kB  00:00:00     

mariadb                                                                 | 2.9 kB  00:00:00     

updates                                                                 | 3.4 kB  00:00:00     

(1/3): extras/7/x86_64/primary_db                                       | 129 kB  00:00:00     

(2/3): updates/7/x86_64/primary_db                                      | 3.6 MB  00:00:00     

(3/3): mariadb/primary_db                                               |  21 kB  00:00:00     

Loading mirror speeds from cached hostfile

 * base: ftp.daumkakao.com

 * extras: centos.mirror.cdnetworks.com

 * updates: centos.mirror.cdnetworks.com

Resolving Dependencies

--> Running transaction check

---> Package epel-release.noarch 0:7-9 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


===============================================================================================

 Package                    Arch                 Version            Repository            Size

===============================================================================================

Installing:

 epel-release               noarch               7-9                extras                14 k


Transaction Summary

===============================================================================================

Install  1 Package


Total download size: 14 k

Installed size: 24 k

Is this ok [y/d/N]: y 

Downloading packages:

epel-release-7-9.noarch.rpm                                             |  14 kB  00:00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : epel-release-7-9.noarch                                                     1/1 

  Verifying  : epel-release-7-9.noarch                                                     1/1 


Installed:

  epel-release.noarch 0:7-9                                                                    


Complete!

You have new mail in /var/spool/mail/root

[root@localhost ~]# 



php-mcrypt 를 다시 설치해 본다.

[root@localhost ~]# yum install php-mcrypt

Loaded plugins: fastestmirror

epel/x86_64/metalink                                                    | 4.7 kB  00:00:00     

epel                                                                    | 4.7 kB  00:00:00     

epel/x86_64/updateinfo         FAILED                                          B  --:--:-- ETA 

http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/repodata/0227446f2304402f8c35b5249d193d1ce408d171eaaa4750f8391db462d429ce-updateinfo.xml.bz2: [Errno 14] HTTP Error 404 - Not Found

Trying other mirror.

To address this issue please refer to the below knowledge base article 


https://access.redhat.com/articles/1320623


If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/


epel/x86_64/primary_db         FAILED                                          

http://kartolo.sby.datautama.net.id/EPEL/7/x86_64/repodata/5a9079da4e65782bcad40e6bc28b7cc431191a1ce1bcb67d137fbebaffbc9744-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found

Trying other mirror.

(1/3): epel/x86_64/group_gz                                             | 261 kB  00:00:00     

(2/3): epel/x86_64/primary_db                                           | 6.1 MB  00:00:01     

(3/3): epel/x86_64/updateinfo                                           | 841 kB  00:00:17     

Loading mirror speeds from cached hostfile

 * base: ftp.daumkakao.com

 * epel: mirror.nes.co.id

 * extras: centos.mirror.cdnetworks.com

 * updates: centos.mirror.cdnetworks.com

Resolving Dependencies

--> Running transaction check

---> Package php-mcrypt.x86_64 0:5.4.16-7.el7 will be installed

--> Processing Dependency: libmcrypt.so.4()(64bit) for package: php-mcrypt-5.4.16-7.el7.x86_64

--> Running transaction check

---> Package libmcrypt.x86_64 0:2.5.8-13.el7 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


===============================================================================================

 Package                 Arch                Version                   Repository         Size

===============================================================================================

Installing:

 php-mcrypt              x86_64              5.4.16-7.el7              epel               20 k

Installing for dependencies:

 libmcrypt               x86_64              2.5.8-13.el7              epel               99 k


Transaction Summary

===============================================================================================

Install  1 Package (+1 Dependent package)


Total download size: 119 k

Installed size: 331 k

Is this ok [y/d/N]: y

Downloading packages:

경고: /var/cache/yum/x86_64/7/epel/packages/libmcrypt-2.5.8-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY

Public key for libmcrypt-2.5.8-13.el7.x86_64.rpm is not installed

(1/2): libmcrypt-2.5.8-13.el7.x86_64.rpm                                |  99 kB  00:00:00     

(2/2): php-mcrypt-5.4.16-7.el7.x86_64.rpm                               |  20 kB  00:00:00     

-----------------------------------------------------------------------------------------------

Total                                                          154 kB/s | 119 kB  00:00:00     

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

Importing GPG key 0x352C64E5:

 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"

 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5

 Package    : epel-release-7-9.noarch (@extras)

 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

Is this ok [y/N]: y

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : libmcrypt-2.5.8-13.el7.x86_64                                               1/2 

  Installing : php-mcrypt-5.4.16-7.el7.x86_64                                              2/2 

  Verifying  : libmcrypt-2.5.8-13.el7.x86_64                                               1/2 

  Verifying  : php-mcrypt-5.4.16-7.el7.x86_64                                              2/2 


Installed:

  php-mcrypt.x86_64 0:5.4.16-7.el7                                                             


Dependency Installed:

  libmcrypt.x86_64 0:2.5.8-13.el7                                                              


Complete!

[root@localhost ~]# 



정상적으로 설치가 되었다.



phpinfo(); 를 해보면 아래와 같이 모듈이 올라와 있다.



mcrypt

mcrypt supportenabled
mcrypt_filter supportenabled
Version 2.5.8 
Api No 20021217 
Supported ciphers cast-128 gost rijndael-128 twofish arcfour cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes 
Supported modes cbc cfb ctr ecb ncfb nofb ofb stream 


DirectiveLocal ValueMaster Value
mcrypt.algorithms_dirno valueno value
mcrypt.modes_dirno valueno value





끝.






'PHP' 카테고리의 다른 글

CentOS7 에서 php7.2 yum 설치  (0) 2018.06.07
CentOS7 PHP7 oci8.so 설치  (0) 2017.11.07
페이징 및 함수이용  (0) 2016.03.01
MySQL 트랜잭션  (0) 2016.02.29
php 5.4 number_format  (0) 2016.01.27
블로그 이미지

엘로드넷

,

root로 작업



1. semanage 설치


[root@localhost ellord]# yum install policycoreutils-python




2. 현재 사용중인 sshd 포트 확인 (당연히 22가 나온다)

[root@localhost ellord]# semanage port -l | grep ssh

ssh_port_t                     tcp       22




3. 22233 을 추가하려고 한다.



[root@localhost ellord]# semanage port -a -t ssh_port_t -p tcp 22233





4. 추가되었는지 다시 확인해 본다.


[root@localhost ellord]# semanage port -l | grep ssh

ssh_port_t                     tcp      22233, 22



22233이 추가되었다.



5. sshd 데몬에도 추가한다.


root@localhost ellord]# vi /etc/ssh/sshd_config 



[root@localhost ellord]# vi /etc/ssh/sshd_config 

#       $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $


# This is the sshd server system-wide configuration file.  See

# sshd_config(5) for more information.


# This sshd was compiled with PATH=/usr/local/bin:/usr/bin


# The strategy used for options in the default sshd_config shipped with

# OpenSSH is to specify options with their default value where

# possible, but leave them commented.  Uncommented options override the

# default value.


# If you want to change the port on a SELinux system, you have to tell

# SELinux about this change.

# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER

#

Port 22233


주석처리된 Port 22 에 주석을 풀고 22233으로 변경해 준다.



5. sshd 를 재시작한다.


[root@localhost ellord]# systemctl restart sshd



6. 접속해 본다.


ELLORDNET-MPR:~ ellord$ ssh 서버아이피 -p 22233




끝.

'Linux' 카테고리의 다른 글

rsync @ERROR: chroot failed  (0) 2019.01.08
CentOS7 apache 2.4 mod_deflate  (0) 2017.11.26
아파치 OpenSSL 사설인증서 적용  (0) 2016.12.06
iconv euckr to utf8 파일명  (0) 2016.12.06
텍스트파일 텍스트 치환  (0) 2016.12.06
블로그 이미지

엘로드넷

,

Spring JUnit4.12 버전에서 에러 나올 때,


아래 경로에서


hamcrest-core.jar 를 다운받아서 빌드패스에 Add External JARs 눌러서 추가해주면 된다.



https://github.com/junit-team/junit4/wiki/Download-and-Install




블로그 이미지

엘로드넷

,

1. nginx 설치


[root@localhost yum.repos.d]# vi /etc/yum.repos.d/nginx.repo 


[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/$basearch/

gpgcheck=0

enabled=1

~                                                                                                                                         

[root@localhost yum.repos.d]# yum install nginx


Loaded plugins: fastestmirror, replace

http://nginx.org/packages/OS/OSRELEASE/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

Trying other mirror.

To address this issue please refer to the below knowledge base article 


https://access.redhat.com/articles/1320623


If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/




 One of the configured repositories failed (nginx repo),

 and yum doesn't have enough cached data to continue. At this point the only

 safe thing yum can do is fail. There are a few ways to work "fix" this:


     1. Contact the upstream for the repository and get them to fix the problem.


     2. Reconfigure the baseurl/etc. for the repository, to point to a working

        upstream. This is most often useful if you are using a newer

        distribution release than is supported by the repository (and the

        packages for the previous distribution release still work).


     3. Run the command with the repository temporarily disabled

            yum --disablerepo=nginx ...


     4. Disable the repository permanently, so yum won't use it by default. Yum

        will then just ignore the repository until you permanently enable it

        again or use --enablerepo for temporary usage:


            yum-config-manager --disable nginx

        or

            subscription-manager repos --disable=nginx


     5. Configure the failing repository to be skipped, if it is unavailable.

        Note that yum will try to contact the repo. when it runs most commands,

        so will have to try and fail each time (and thus. yum will be be much

        slower). If it is a very temporary problem though, this is often a nice

        compromise:


            yum-config-manager --save --setopt=nginx.skip_if_unavailable=true


failure: repodata/repomd.xml from nginx: [Errno 256] No more mirrors to try.

http://nginx.org/packages/OS/OSRELEASE/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

[root@localhost yum.repos.d]# vi /etc/yum.repos.d/nginx.repo

[root@localhost yum.repos.d]# yum install nginx

Loaded plugins: fastestmirror, replace

base                                                                                                               | 3.6 kB  00:00:00     

epel/x86_64/metalink                                                                                               | 6.2 kB  00:00:00     

extras                                                                                                             | 3.4 kB  00:00:00     

nginx                                                                                                              | 2.9 kB  00:00:00     

updates                                                                                                            | 3.4 kB  00:00:00     

webtatic                                                                                                           | 3.6 kB  00:00:00     

nginx/x86_64/primary_db                                                                                            |  18 kB  00:00:00     

Loading mirror speeds from cached hostfile

 * base: mirror.oasis.onnetcorp.com

 * epel: mirror.premi.st

 * extras: mirror.oasis.onnetcorp.com

 * updates: mirror.oasis.onnetcorp.com

 * webtatic: sp.repo.webtatic.com

Resolving Dependencies

--> Running transaction check

---> Package nginx.x86_64 1:1.10.2-1.el7.ngx will be installed

--> Finished Dependency Resolution


Dependencies Resolved


==========================================================================================================================================

 Package                      Arch                          Version                                    Repository                    Size

==========================================================================================================================================

Installing:

 nginx                        x86_64                        1:1.10.2-1.el7.ngx                         nginx                        643 k


Transaction Summary

==========================================================================================================================================

Install  1 Package


Total download size: 643 k

Installed size: 2.2 M

Is this ok [y/d/N]: y

Downloading packages:

nginx-1.10.2-1.el7.ngx.x86_64.rpm                                                                                  | 643 kB  00:00:02     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : 1:nginx-1.10.2-1.el7.ngx.x86_64                                                                                        1/1 

----------------------------------------------------------------------


Thanks for using nginx!


Please find the official documentation for nginx here:

* http://nginx.org/en/docs/


Commercial subscriptions for nginx are available on:

* http://nginx.com/products/


----------------------------------------------------------------------

  Verifying  : 1:nginx-1.10.2-1.el7.ngx.x86_64                                                                                        1/1 


Installed:

  nginx.x86_64 1:1.10.2-1.el7.ngx                                                                                                         


Complete!




[root@localhost yum.repos.d]# service nginx start

Redirecting to /bin/systemctl start  nginx.service






2. MariaDb 10 설치



[root@localhost yum.repos.d]# vi /etc/yum.repo.d/MariaDB.repo



[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.2/rhel7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1




[root@localhost yum.repos.d]# yum install -y mariadb mariadb-server




[root@localhost etc]# systemctl enable mariadb

[root@localhost etc]# systemctl start mariadb




설정파일 변경


2.1 /etc/my.cnf.d/mysql-clients.cnf


[mysql] 아래에

default-character-set=utf8 추가


[root@localhost etc]# vi /etc/my.cnf.d/mysql-clients.cnf 


[mysql]


default-character-set=utf8





2. /etc/my.cnf.d/server.cnf


[mysqld] 아래에 아래와 같이 추가하고

[mysqld_safe] 를 만들고 아래와 같이 추가


[root@localhost etc]# vi /etc/my.cnf.d/server.cnf 



[mysqld]



max_connections = 512

wait_timeout = 30

character-set-server = utf8



datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock


symbolic-links=0



[mysqld_safe]

log-error=/var/log/mariadb/mariadb.log

pid-file=/var/run/mariadb/mariadb.pid






3. 기본 보안 설정 


root 비밀번호 설정 등


Enter current password for root (enter for none): 그냥엔터(아직 root 비번을 설정하지 않았으므로) 



새로운 루트비밀번호 설정


Set root password? [Y/n] Y 

New password: 

Re-enter new password: 

Password updated successfully!

Reloading privilege tables..

 ... Success!


나머지들 엔터

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.


Remove anonymous users? [Y/n]Y  

 ... Success!


Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.


Disallow root login remotely? [Y/n] Y

 ... Success!


By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.


Remove test database and access to it? [Y/n] Y

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!


Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.


Reload privilege tables now? [Y/n] Y

 ... Success!


Cleaning up...


All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.


Thanks for using MariaDB!




재시작

[root@localhost run]# systemctl restart mariadb.service



[root@localhost run]# systemctl status mariadb.service

mariadb.service - MariaDB database server

   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)

  Drop-In: /etc/systemd/system/mariadb.service.d

           └─migrated-from-my.cnf-settings.conf

   Active: active (running) since 목 2017-01-05 03:12:14 KST; 19min ago

  Process: 1230 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)

  Process: 1163 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)

  Process: 1160 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)

 Main PID: 1198 (mysqld)

   Status: "Taking your SQL requests now..."

   CGroup: /system.slice/mariadb.service

           └─1198 /usr/sbin/mysqld


 1월 05 03:12:14 localhost.localdomain mysqld[1198]: 2017-01-05  3:12:14 139739293591744 [Note] InnoDB: 32 non-redo rollback seg...ctive.

 1월 05 03:12:14 localhost.localdomain mysqld[1198]: 2017-01-05  3:12:14 139739293591744 [Note] InnoDB: Waiting for purge to start

 1월 05 03:12:14 localhost.localdomain mysqld[1198]: 2017-01-05  3:12:14 139739293591744 [Note] InnoDB: 5.7.14 started; log sequ...226662

 1월 05 03:12:14 localhost.localdomain mysqld[1198]: 2017-01-05  3:12:14 139738111538944 [Note] InnoDB: Loading buffer pool(s) f...r_pool

 1월 05 03:12:14 localhost.localdomain mysqld[1198]: 2017-01-05  3:12:14 139739293591744 [Note] Plugin 'FEEDBACK' is disabled.

 1월 05 03:12:14 localhost.localdomain mysqld[1198]: 2017-01-05  3:12:14 139738111538944 [Note] InnoDB: Buffer pool(s) load comp...:12:14

 1월 05 03:12:14 localhost.localdomain mysqld[1198]: 2017-01-05  3:12:14 139739293591744 [Note] Server socket created on IP: '::'.

 1월 05 03:12:14 localhost.localdomain mysqld[1198]: 2017-01-05  3:12:14 139739293591744 [Note] /usr/sbin/mysqld: ready for connections.

 1월 05 03:12:14 localhost.localdomain mysqld[1198]: Version: '10.2.3-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306 ...Server

 1월 05 03:12:14 localhost.localdomain systemd[1]: Started MariaDB database server.

Hint: Some lines were ellipsized, use -l to show in full.


접속해 본다.

[root@localhost run]# mysql -u root -p mysql

Enter password: 

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 8

Server version: 10.2.3-MariaDB MariaDB Server


Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MariaDB [mysql]> 

MariaDB [mysql]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)


MariaDB [mysql]> 


캐릭터셋 확인

MariaDB [mysql]> show variables like 'char%';

+--------------------------+----------------------------+

| Variable_name            | Value                      |

+--------------------------+----------------------------+

| character_set_client     | utf8                       |

| character_set_connection | utf8                       |

| character_set_database   | utf8                       |

| character_set_filesystem | binary                     |

| character_set_results    | utf8                       |

| character_set_server     | utf8                       |

| character_set_system     | utf8                       |

| character_sets_dir       | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

8 rows in set (0.00 sec)


MariaDB [mysql]> 



wait_timeout

MariaDB [mysql]> show global variables like 'wait%';

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| wait_timeout  | 30    |

+---------------+-------+

1 row in set (0.00 sec)


MariaDB [mysql]> 





3. PHP-FPM 7.0 설치

#yum update
#rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm


[root@localhost src]# yum update

Loaded plugins: fastestmirror, replace

Loading mirror speeds from cached hostfile

 * base: mirror.oasis.onnetcorp.com

 * epel: mirror.premi.st

 * extras: mirror.oasis.onnetcorp.com

 * updates: mirror.oasis.onnetcorp.com

 * webtatic: sp.repo.webtatic.com

No packages marked for update



[root@localhost src]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm(을)를 복구합니다

준비 중...                         ################################# [100%]

epel-release-7-8.noarch 패키지는 이미 설치되어 있습니다


https://mirror.webtatic.com/yum/el7/webtatic-release.rpm(을)를 복구합니다

준비 중...                         ################################# [100%]

webtatic-release-7-3.noarch 패키지는 이미 설치되어 있습니다

[root@localhost src]# 




php70w-fpm php70w-opcache 설치

[root@localhost src]# yum install php70w-fpm php70w-opcache



추가 설치

[root@localhost src]# yum install php70w-mysql php70w-gd php70w-curl php70w-mbstring php70w-mcrypt php70w-gettext php70w-pear





설치 확인

[root@localhost src]# php -v

PHP 7.0.14 (cli) (built: Dec 10 2016 11:35:27) ( NTS )

Copyright (c) 1997-2016 The PHP Group

Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

    with Zend OPcache v7.0.14, Copyright (c) 1999-2016, by Zend Technologies

[root@localhost src]# 



설정파일 변경

/etc/php.ini 파일을 열어서 아래 항목들 변경

cgi.fix_pathinfo = 0
allow_url_fopen = Off
expose_php = Off
display_errors = Off
upload_max_filesize = 10M
date.timezone = Asia/Seoul

/etc/php-fpm.d/www.conf 열어서 아래 항목들 변경

user = nginx
group = nginx
listen.owner = nginx 
listen.group = nginx 
listen.mode = 0664
listen = /var/run/php70w-fpm.sock






시작

[root@localhost php-fpm.d]# systemctl start php-fpm



확인

[root@localhost run]# ls /var/run/php70*

/var/run/php70w-fpm.sock

[root@localhost run]# 


[root@localhost php-fpm.d]# systemctl status php-fpm

php-fpm.service - The PHP FastCGI Process Manager

   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)

   Active: active (running) since 목 2017-01-05 03:32:06 KST; 20s ago

 Main PID: 11345 (php-fpm)

   Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"

   CGroup: /system.slice/php-fpm.service

           ├─11345 php-fpm: master process (/etc/php-fpm.conf)

           ├─11346 php-fpm: pool www

           ├─11347 php-fpm: pool www

           ├─11348 php-fpm: pool www

           ├─11349 php-fpm: pool www

           └─11350 php-fpm: pool www


 1월 05 03:32:05 localhost.localdomain systemd[1]: Starting The PHP FastCGI Process Manager...

 1월 05 03:32:06 localhost.localdomain systemd[1]: Started The PHP FastCGI Process Manager.

[root@localhost php-fpm.d]# 




4. nginx-php 연동

/etc/nginx/conf.d/default.conf 를 열어서 아래와 같이 변경

server {

    listen       80;

    server_name  192.168.33.252;


    #charset koi8-r;

    #access_log  /var/log/nginx/log/host.access.log  main;



    #location / {

        root   /usr/share/nginx/html;


        index  index.php index.html index.htm;

    #}


    location / {

        try_files $uri $uri/ =404;

    }



    #error_page  404              /404.html;


    # redirect server error pages to the static page /50x.html

    #

    error_page   500 502 503 504  /50x.html;

    location = /50x.html {

        root   /usr/share/nginx/html;

    }


    # proxy the PHP scripts to Apache listening on 127.0.0.1:80

    #

    #location ~ \.php$ {

    #    proxy_pass   http://127.0.0.1;

    #}


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    location ~ \.php$ {

    #    root           html;

    #    fastcgi_pass   192.168.33.252:9000;

        try_files $uri =404;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_pass   unix:/var/run/php70w-fpm.sock;

        fastcgi_index  index.php;

        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        include        fastcgi_params;

    }


    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    #location ~ /\.ht {

    #    deny  all;

    #}

}





phpinfo()  테스트

/usr/share/nginx/html 에 index.php 파일을 만든다.

내용은
<?php

phpinfo()


?>





아래와 같이 나온다.



블로그 이미지

엘로드넷

,


    @IBOutlet var userPhoneNumber: UITextField!



    override func viewDidLoad() {

        super.viewDidLoad()


       

// touch (start editing)

        userPhoneNumber.addTarget(self, action: #selector(self.myTouchEvent), for: UIControlEvents.editingDidBegin)

        



// end editing

        userPhoneNumber.addTarget(self, action: #selector(self.myEndTouchEvent), for: UIControlEvents.editingDidEnd)

        

        

    }




    func myTouchEvent(textfield: UITextField) {

        print("textfield touched")


    }


    func myEndTouchEvent(textfield: UITextField) {

        print("textfield edit end")


    }

블로그 이미지

엘로드넷

,

Swift3  UserDefaults 에 이미지 저장하고 꺼내기


//이미지 저장

        

let testImage = UIImage(named: "testimgae")

        

let jpgImage = UIImageJPEGRepresentation(testImage, 0.1)        // 10분의 1로 축소

        

UserDefaults.standard.set(jpgImage, forKey: "profileImage")

UserDefaults.standard.synchronize()

        




//이미지 꺼내기


@IBOutlet var profileImage: UIImageView!


override func viewWillAppear(_ animated: Bool) {

   if let imgData = UserDefaults.standard.object(forKey: "profileImage") as? NSData

   {

       if let image = UIImage(data: imgData as Data)

       {

                self.profileImage.image = image


       }

   }


}

블로그 이미지

엘로드넷

,

resign keyboard textfield

iOS Swift 2016. 12. 31. 16:37

// uitextfield


    @IBOutlet var userID: UITextField!




    userID.resignFirstResponder()//resign keyboard focus





// global

        UIApplication.shared.sendAction(#selector(UIApplication.resignFirstResponder), to: nil, from: nil, for: nil);

블로그 이미지

엘로드넷

,


@IBOutlet var userID: UITextField!



    

    override func viewDidLoad() {

        super.viewDidLoad()


        // Do any additional setup after loading the view.

        

        userID.underlined()


        

    }





extension UITextField {

    

    func underlined(){

        let border = CALayer()

        let width = CGFloat(1.0)

        border.borderColor = UIColor.lightGray.cgColor

        border.frame = CGRect(x: 0, y: self.frame.size.height - width, width:  self.frame.size.width, height: self.frame.size.height)

        border.borderWidth = width

        self.layer.addSublayer(border)

        self.layer.masksToBounds = true

    }

}



블로그 이미지

엘로드넷

,

@IBOutlet var btnNext: UIButton!




self.btnNext.backgroundColor = hexStringToUIColor(hex:"#1994fc")




func hexStringToUIColor (hex:String) -> UIColor {

        var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()

        

        if (cString.hasPrefix("#")) {

            cString.remove(at: cString.startIndex)

        }

        

        if ((cString.characters.count) != 6) {

            return UIColor.gray

        }

        

        var rgbValue:UInt32 = 0

        Scanner(string: cString).scanHexInt32(&rgbValue)

        

        return UIColor(

            red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,

            green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,

            blue: CGFloat(rgbValue & 0x0000FF) / 255.0,

            alpha: CGFloat(1.0)

        )

    }




블로그 이미지

엘로드넷

,