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


       }

   }


}

블로그 이미지

엘로드넷

,