OSX php7.4 설치

PHP 2022. 4. 21. 15:07

1. 설치

 

$ brew upgrade php@7.4

 

==> Downloading https://www.freetds.org/files/stable/freetds-1.3.10.tar.gz
Error: php@7.4: Failed to download resource "freetds"
Download failed: Homebrew-installed `curl` is not installed for: https://www.freetds.org/files/stable/freetds-1.3.10.tar.gz
Chan-ui-Mac-mini:httpd ds1ttc$ brew install curl
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.

Warning: You are using macOS 10

curl 이 설치 안되어 있어서 freetds 가 설치가 안된다.

 

curl 을 설치

 

$ brew install curl

 

다시 php 설치

 

$ brew upgrade php@7.4

 

설치 후 php restart

 

$ brew services restart php@7.4

 

버전 확인

 

Chan-ui-Mac-mini:httpd ds1ttc$ php -v
PHP 7.1.33 (cli) (built: Jan 18 2020 13:49:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
Chan-ui-Mac-mini:httpd ds1ttc$

여전히 예전 버전이 나옴.

 

.profile 에 등록해 주자.

 

 

$ echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.profile
$ echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.profile

$ source .profile

 

다시 버전 확인

 

Chan-ui-Mac-mini:~ ds1ttc$ php -v
PHP 7.4.29 (cli) (built: Apr 21 2022 07:59:48) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.29, Copyright (c), by Zend Technologies
Chan-ui-Mac-mini:~ ds1ttc$

 

그래도 예전 버전이 나온다면 

터미널을 새로 열어서 해 볼 것.

 

블로그 이미지

엘로드넷

,

OSX mariadb 설치

Mac 2022. 4. 21. 15:03

 

1. 설치

$ brew install mariadb

 

2. 서비스시작

$ brew services start mariadb

 

3. root비전 설정

$ sudo mariadb-secure-installation

 

Chan-ui-Mac-mini:www ds1ttc$ sudo mariadb-secure-installation
Password:


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n  
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the 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!
Chan-ui-Mac-mini:www ds1ttc$

 

 

4. mariadb 서버에 접속해 보자

$ mysql -u root -p mysql

Chan-ui-Mac-mini:www ds1ttc$ 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 11
Server version: 10.7.3-MariaDB Homebrew

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

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

MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.001 sec)

MariaDB [mysql]>

최신 버전이 잘 설치되었다.

 

'Mac' 카테고리의 다른 글

OSX Mojave freetype install error  (0) 2023.03.18
Change OSX ssh port 맥OS ssh 포트 변경  (0) 2022.11.04
osx apache httpd는 어디에 설치?  (0) 2022.04.21
osx 원격제어설정  (0) 2022.04.15
OSX ssh 포트 변경  (0) 2022.04.14
블로그 이미지

엘로드넷

,

1. 설치방법 

 

$ brew install httpd

 

 

2. httpd.conf 위치는 ?

 

/usr/local/etc/httpd

 

 

 

3. 홈 디렉토리는 ?

 

/usr/local/var/www

 

블로그 이미지

엘로드넷

,

1. Apache 설치

[root@localhost yum.repos.d]# yum list httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.navercorp.com
 * extras: mirror.navercorp.com
 * updates: mirror.navercorp.com
Available Packages
httpd.x86_64                     2.4.6-97.el7.centos.5                     updates

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

설치완료 후 버전확인

[root@localhost yum.repos.d]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Mar 24 2022 14:57:57

 

 

2. MariaDB 10.7 설치

기본 버전은 5.5 버전이므로 10.7 설치를 위해서는 repo 를 등록해야 한다.

# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ll
합계 40
-rw-r--r--. 1 root root 1664 11월 24  2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11월 24  2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 11월 24  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  630 11월 24  2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11월 24  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 11월 24  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  314 11월 24  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  616 11월 24  2020 CentOS-x86_64-kernel.repo


[root@localhost yum.repos.d]# vi MariaDB.repo
# MariaDB 10.7 CentOS repository list - created 2022-04-16 21:02 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirror.yongbok.net/mariadb/yum/10.7/centos7-amd64
gpgkey=https://mirror.yongbok.net/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

MariaDB-repo 가 추가되었다.

[root@localhost yum.repos.d]# ll
합계 44
-rw-r--r--. 1 root root 1664 11월 24  2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11월 24  2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 11월 24  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  630 11월 24  2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11월 24  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 11월 24  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  314 11월 24  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  616 11월 24  2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root  271  4월 17 06:00 MariaDB.repo
[root@localhost yum.repos.d]#

 

설치

[root@localhost yum.repos.d]# yum install MariaDB-server MariaDB-client

서버 start

[root@localhost yum.repos.d]# systemctl start mariadb

 

root password 설정

[root@localhost yum.repos.d]# mysqladmin -u root password

 

시작프로그램에 등록(서버 시작시 자동실행)

[root@localhost yum.repos.d]# systemctl enable mariadb

 

버전확인

[root@localhost yum.repos.d]# mysql -v
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.7.3-MariaDB MariaDB Server

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

Reading history-file /root/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

exit 또는 컨트롤 + c 로 빠져나온다.

 

 

3. PHP7.4 설치

MariaDB 처럼 기본 버전이 낮으므로 (5.4) 7.x 버전 설치를 위한 repo를 등록한다.

[root@localhost yum.repos.d]# yum list php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.navercorp.com
 * extras: mirror.navercorp.com
 * updates: mirror.navercorp.com
Available Packages
php.x86_64                           5.4.16-48.el7                            base

 

[root@localhost yum.repos.d]# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@localhost yum.repos.d]# ll
합계 112
-rw-r--r--. 1 root root 1664 11월 24  2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11월 24  2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 11월 24  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  630 11월 24  2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11월 24  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 11월 24  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  314 11월 24  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  616 11월 24  2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root  271  4월 17 06:00 MariaDB.repo
-rw-r--r--. 1 root root 1050 10월  3  2017 epel-testing.repo
-rw-r--r--. 1 root root  951 10월  3  2017 epel.repo
-rw-r--r--. 1 root root  446  2월 15 19:37 remi-glpi91.repo
-rw-r--r--. 1 root root  446  2월 15 19:37 remi-glpi92.repo
-rw-r--r--. 1 root root  446  2월 15 19:37 remi-glpi93.repo
-rw-r--r--. 1 root root  446  2월 15 19:37 remi-glpi94.repo
-rw-r--r--. 1 root root  855  2월 15 19:37 remi-modular.repo
-rw-r--r--. 1 root root  456  2월 15 19:37 remi-php54.repo
-rw-r--r--. 1 root root 1314  2월 15 19:37 remi-php70.repo
-rw-r--r--. 1 root root 1314  2월 15 19:37 remi-php71.repo
-rw-r--r--. 1 root root 1314  2월 15 19:37 remi-php72.repo
-rw-r--r--. 1 root root 1314  2월 15 19:37 remi-php73.repo
-rw-r--r--. 1 root root 1314  2월 15 19:37 remi-php74.repo
-rw-r--r--. 1 root root 1314  2월 15 19:37 remi-php80.repo
-rw-r--r--. 1 root root 1314  2월 15 19:37 remi-php81.repo
-rw-r--r--. 1 root root  750  2월 15 19:37 remi-safe.repo
-rw-r--r--. 1 root root 2605  2월 15 19:37 remi.repo

epel-release (Extra Package for Enterprise Linux) 를 업데이트한다.

[root@localhost yum.repos.d]# yum install epel-release

 

 

php repo 버전관리를 위해 yum-utils를 설치한다.

# yum install yum-utils

 

php-repo 를 7.4 버전으로 지정한다.

[root@localhost yum.repos.d]# yum-config-manager --enable remi-php74

 

php를 설치한다.

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

 

php 관련 패키지를 설치한다.

[root@localhost yum.repos.d]# yum install php-fpm php-cli  php-redis  php-brotli php-intl php-gd php-gmp php-imap php-bcmath php-interbase php-json php-mbstring php-mysqlnd php-odbc php-opcache php-memcached php-tidy php-pdo php-pdo-dblib php-pear php-pgsql php-process php-pecl-apcu php-pecl-geoip php-pecl-imagick php-pecl-hrtime php-pecl-json php-pecl-memcache php-pecl-mongodb php-pecl-rar php-pecl-pq php-pecl-redis4 php-pecl-yaml php-pecl-zip

 

버전을 확인해 본다.

[root@localhost yum.repos.d]# php -v
PHP 7.4.29 (cli) (built: Apr 12 2022 10:55:38) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.29, Copyright (c), by Zend Technologies

 

끝.

'PHP' 카테고리의 다른 글

OSX php7.4 설치  (0) 2022.04.21
Codeigniter4 encrypter  (0) 2022.04.16
Codeigniter3 to Codeigniter4 마이그레이션  (0) 2022.04.15
Codeigniter4 파일 명명 규칙  (0) 2022.04.15
오늘이 이번 달 몇째 주인지 확인.  (0) 2022.04.15
블로그 이미지

엘로드넷

,

1. Yum repo 등록

 

# cd /etc/yum.repos.d
# vi MariaDB.repo

# MariaDB 10.7 CentOS repository list - created 2022-04-16 21:02 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirror.yongbok.net/mariadb/yum/10.7/centos7-amd64
gpgkey=https://mirror.yongbok.net/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

 

 

2. 설치

# yum install MariaDB-server MariaDB-client

 

3. 서버시작

# systemctl start mariadb

 

4. root password 설정

# mysqladmin -u root password

 

5. 시작프로그램에 등록

systemctl enable mariadb

 

6. 버전확인

# mysql -v
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.7.3-MariaDB MariaDB Server

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

Reading history-file /root/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

 

끝.

블로그 이미지

엘로드넷

,

Codeigniter4 encrypter

PHP 2022. 4. 16. 19:42

1. encrypt

$encrypter = \Config\Services::encrypter();
$text = "인코딩할 문자열";
$enc_text = bin2hex($encrypter->encrypt($text));

$enc_text 를 database 에 입력하면 된다.

 

 

2. decrypt

$encrypter = \Config\Services::encrypter();
$enc_text = $result->enc_text;//데이터베이스테 입력되어 있는 해쉬값
$dec_text = $encrypter->decrypt(hex2bin($enc_text));
블로그 이미지

엘로드넷

,

1. 컨트롤러 :

 

Codeigniter3 : 

 

파일명 : Welcome.php

class Welcome extends CI_Controller {
	
    public function __construct(){
    	$this->load->model(array("welcome_model", "bbs_model"));
    }
    
    
    public function index(){
    	$data['title'] = "테스트";
        $data['resultList'] = $this->welcome_model->getList();
        
        $this->load->view('inc/header');
        $this->load->view('welcome_message', $data);
        $this->load->view('inc/footer');
        
    }
}

 

Codeigniter4

 

파일명 : Welcome.php

namespace App\Controllers;

class Welcome extends BaseController{

	public function index(){
    	
        $welcomeModel = model('App\Models\WelcomeModel');
        
        $data['title'] = "테스트";
        $data['resultList'] = $welcomeModel->getList();
        
        echo view('inc/header');
        echo view('welcome_message', $data);
        echo view('inc/footer');
        
    }
}

 

 

 

2. 모델

 

Codeigniter3

 

파일명 : Welcome_model.php

class Welcome_model extends CI_Model{

	public function getList(){
    
    	$sql = "SELECT * FROM TEST WHERE ID = ?";
        $param[] = "아이디";
        
        $query = $this->db->query($sql, $param);
        


		//결과 배열인 경우
        if($query->num_rows() > 0){
            return $query->result_array();
        }else{
            return FALSE;
        }
		
        
		//결과 한줄인 경우
		return $query->row();
        
    }
    
    
}

 

Codeigniter4

 

파일명 : WelcomeModel.php

namespace App\Models;

use CodeIgniter\Model;

class WelcomeModel extends Model
{

	public function getList(){
    	$db = \Config\Database::connect();
        
        $sql = "select * from TEST where id = ?";
        $param[] = "아이디";
        
        $query = $db->query($sql, $param);
        
        
        //결과 배열인 경우
        $result = $query->getResultArray();
        
        
        //결과 한 줄인 경우
        $result = $query->getRow();


		return $result;
        
        
    }

}

 

 

3. 뷰

 

파일명 : 기존과 동일

 

 

4. 컨트롤러에서 뷰 호출방법 

 

Codeigniter3 : 

$this->load->view('welcome_message');

 

Codeigniter4 : 

echo view('welcome_message');

 

 

 

5. 세션값확인

 

Codeigniter3 : 

 

$this->session->userdate("값");

 

 

 

Codeigniter4 : 

 

$session = session();

$session->get("값");

 

 

블로그 이미지

엘로드넷

,

1. 카멜 표기법 : camelCase

 

public void camelCase(){

}

소문자로 시작하고 두번째 단어부터 대문자로 시작

 

 

2. 파스칼 표기법 : PascalCase

public class PascalCase{

}

모든 문자는 대문자로 시작

 

 

3. 스네이크 표기법 : snake_case

 

var this_is_snake_case = "Snake";

언더바로 연결

 

 

4. 헝가리안 표기법 : Hungarian Notation

int iAge = 50;
str strName = "홍길동";

변수명 앞에 자료형을 붙임.

 

 

5. 케밥 표기법 : kabab-case

var this-is-kabab-case = true;

하이픈으로 연결함.

 

 

 

 

 

 

 

 

블로그 이미지

엘로드넷

,

공통 : 하이픈 제거, 파스칼 표기법

 

컨트롤러 : 

 

ex)

 

BaseController.php

Home.php

ThisIsPascalCase.php

 

 

모델 : Model.php 로 끝남. 파스칼 표기법

 

HomeModel.php

ThisIsPascalCaseModel.php

 

 

뷰 : 전부 소문자로. 스네이크 표기법

welcome_message.php

home.php

 

 

 

블로그 이미지

엘로드넷

,

osx 원격제어설정

Mac 2022. 4. 15. 13:31

맥에는 vnc가 기본적으로 설치되어 있다.

vnc가 사용하는 포트는 5900이다.

 

원격제어 remote 맥 설정 : 

 

시스템 환경설정 > 공유 > 화면공유 체크

 

 

 

로컬맥에서 remote 접속 : 

 

파인더 상에서 Command + K 

 

끝.

블로그 이미지

엘로드넷

,