O/S : CenotsOS 7.x 64bit
APACHE : 2.4.39 ( tls 1.1 / 1.2 지원 / TLS 1.3 미지원 )
PHP : 7.3.8
MYSQL : mariadb 10.4.7
1. mariadb 설치 yum repo에 추가 후 설치 진행
1 2 3 4 5 6 7 8 |
[root@localhost ~]# vi /etc/yum.repos.d/MariaDB.repo #추가 [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.4/centos7-amd64 gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck = 1 |
2. yum으로 mariadb 10.4.7 install
1 |
[root@localhost ~]# yum -y install MariaDB |
3. mariadb는 설치가 완료되었으며 이제 시작만 하면 되지만 사용자마다 mysql 을 설치하는 디렉토리가 모두 다르므로 해당 경로를 지정해서 설치해주자
기본 바로 시작을 하게 되면 경로는 /var/lib/mysql 이 기본경로이다
설치는 우리는 /free/mysql_data 에 진행하려고 한다 / 설치 진행 후 권한을 변경
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@localhost ~]# mysql_install_db --datadir=/free/mysql_data ### 데이터저장소가 /home/mysql_data에 지정하려고 하면 다음과 같이 명령어 [root@localhost ~]# mysql_install_db --datadir=/home/mysql_data [root@localhost ~]# ls -l /free/mysql_data/ -rw-rw---- 1 root root 24576 8??14 16:03 aria_log.00000001 -rw-rw---- 1 root root 52 8??14 16:03 aria_log_control -rw-rw---- 1 root root 972 8??14 16:03 ib_buffer_pool -rw-rw---- 1 root root 134217728 8??14 16:03 ib_logfile0 -rw-rw---- 1 root root 134217728 8??14 16:03 ib_logfile1 -rw-rw---- 1 root root 134217728 8??14 16:03 ib_logfile2 -rw-rw---- 1 root root 77594624 8??14 16:03 ibdata1 drwx------ 2 root root 4096 8??14 16:03 mysql drwx------ 2 root root 20 8??14 16:03 performance_schema drwx------ 2 root root 20 8??14 16:03 test |
4. 해당 데이터베이스의 USER 권한이 root 이므로 이것을 mysql로 변경해주자
1 |
[root@localhost ~]# chown mysql /home/mysql_data/ |
5. 기본 여러지 환경설정값을 변경해서 사용하므로 /etc/my.cnf.d/server.cnf 해당 파일을 아래와 같이 수정해준다
기본 엔진 myisam / 만약 innodb를 사용하려면 6번의 server.cnf 파일을 참고한다
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
[server] [mysqld] bind-address=0.0.0.0 skip-external-locking key_buffer_size = 384M max_allowed_packet = 512M table_open_cache = 2048 sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M myisam_sort_buffer_size = 64M thread_cache_size = 8 #dns query skip-name-resolve #connection max_connections = 1000 max_connect_errors = 1000 wait_timeout= 60 #slow-queries #slow_query_log = /var/lib//mysql/slow-queries.log #long_query_time = 3 #log-slow-queries = /var/lib/mysql/mysql-slow-queries.log ##timestamp explicit_defaults_for_timestamp symbolic-links=0 ###chracter character-set-client-handshake=FALSE init_connect = SET collation_connection = utf8_general_ci init_connect = SET NAMES utf8 character-set-server = utf8 collation-server = utf8_general_ci ### MyISAM Spectific options default-storage-engine = myisam key_buffer_size = 32M bulk_insert_buffer_size = 64M myisam_sort_buffer_size = 128M myisam_max_sort_file_size = 10G myisam_repair_threads = 1 ### INNODB Spectific options #default-storage-engine = InnoDB skip-innodb #innodb_additional_mem_pool_size = 16M #innodb_buffer_pool_size = 1024MB #innodb_data_file_path = ibdata1:10M:autoextend #innodb_write_io_threads = 8 #innodb_read_io_threads = 8 #innodb_thread_concurrency = 16 #innodb_flush_log_at_trx_commit = 1 #innodb_log_buffer_size = 8M #innodb_log_file_size = 128M #innodb_log_files_in_group = 3 #innodb_max_dirty_pages_pct = 90 #innodb_lock_wait_timeout = 120 [mysqldump] #default-character-set = utf8 max_allowed_packet = 512M [myisamchk] key_buffer_size = 512M sort_buffer_size = 512M read_buffer = 8M write_buffer = 8M # # * Galera-related settings # [galera] # Mandatory settings #wsrep_on=ON #wsrep_provider= #wsrep_cluster_address= #binlog_format=row #default_storage_engine=InnoDB #innodb_autoinc_lock_mode=2 # Optional setting #wsrep_slave_threads=1 |
6. 기본 여러지 환경설정값을 변경해서 사용하므로 /etc/my.cnf.d/server.cnf 해당 파일을 아래와 같이 수정해준다
기본 엔진 innodb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
[server] [mysqld] bind-address=0.0.0.0 skip-external-locking key_buffer_size = 384M max_allowed_packet = 512M table_open_cache = 2048 sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M myisam_sort_buffer_size = 64M thread_cache_size = 8 #dns query skip-name-resolve #connection max_connections = 1000 max_connect_errors = 1000 wait_timeout= 60 #slow-queries #slow_query_log = /var/lib//mysql/slow-queries.log #long_query_time = 3 #log-slow-queries = /var/lib/mysql/mysql-slow-queries.log ##timestamp explicit_defaults_for_timestamp symbolic-links=0 ###chracter character-set-client-handshake=FALSE init_connect = SET collation_connection = utf8_general_ci init_connect = SET NAMES utf8 character-set-server = utf8 collation-server = utf8_general_ci ### MyISAM Spectific options #default-storage-engine = myisam key_buffer_size = 32M bulk_insert_buffer_size = 64M myisam_sort_buffer_size = 128M myisam_max_sort_file_size = 10G myisam_repair_threads = 1 ### INNODB Spectific options default-storage-engine = InnoDB #skip-innodb #innodb_additional_mem_pool_size = 16M innodb_buffer_pool_size = 1024MB innodb_data_file_path = ibdata1:10M:autoextend innodb_write_io_threads = 8 innodb_read_io_threads = 8 innodb_thread_concurrency = 16 innodb_flush_log_at_trx_commit = 1 innodb_log_buffer_size = 8M innodb_log_file_size = 128M innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 [mysqldump] #default-character-set = utf8 max_allowed_packet = 512M [myisamchk] key_buffer_size = 512M sort_buffer_size = 512M read_buffer = 8M write_buffer = 8M # * Galera-related settings # [galera] # Mandatory settings #wsrep_on=ON #wsrep_provider= #wsrep_cluster_address= #binlog_format=row #default_storage_engine=InnoDB #innodb_autoinc_lock_mode=2 # Optional setting #wsrep_slave_threads=1 |
7. 이제 mysql ( mariadb)를 시작해보자
1 |
[root@localhost ~]# systemctl start mysql |
8. mysql을 접속해서 환경를 확인해보자
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
[root@localhost ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 10.4.7-MariaDB MariaDB Server 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 [(none)]> \s -------------- mysql Ver 15.1 Distrib 10.4.7-MariaDB, for Linux (x86_64) using readline 5.1 Connection id: 3 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 10.4.7-MariaDB MariaDB Server Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 38 sec Threads: 2 Questions: 4 Slow queries: 0 Opens: 16 Flush tables: 1 Open tables: 9 Queries per second avg: 0.105 -------------- MariaDB [(none)]> MariaDB [(none)]> MariaDB [(none)]> SHOW VARIABLES LIKE 'max%'; +----------------------------+----------------------+ | Variable_name | Value | +----------------------------+----------------------+ | max_allowed_packet | 536870912 | | max_binlog_cache_size | 18446744073709547520 | | max_binlog_size | 1073741824 | | max_binlog_stmt_cache_size | 18446744073709547520 | | max_connect_errors | 1000 | | max_connections | 1000 | | max_delayed_threads | 20 | | max_digest_length | 1024 | | max_error_count | 64 | | max_heap_table_size | 16777216 | | max_insert_delayed_threads | 20 | | max_join_size | 18446744073709551615 | | max_length_for_sort_data | 1024 | | max_long_data_size | 536870912 | | max_password_errors | 4294967295 | | max_prepared_stmt_count | 16382 | | max_recursive_iterations | 4294967295 | | max_relay_log_size | 1073741824 | | max_rowid_filter_size | 131072 | | max_seeks_for_key | 4294967295 | | max_session_mem_used | 9223372036854775807 | | max_sort_length | 1024 | | max_sp_recursion_depth | 0 | | max_statement_time | 0.000000 | | max_tmp_tables | 32 | | max_user_connections | 0 | | max_write_lock_count | 4294967295 | +----------------------------+----------------------+ 27 rows in set (0.002 sec) |
9. 리부팅 또는 서버가 시작될 경우 자동으로 해당 데몬을 서비스하게 구성
1 2 3 4 |
[root@localhost ~]# systemctl enable mysql ### 또는 [root@localost ~]# systemctl enable mariadb |
10. apache 2.4.39 install yum epel-release 설치 후 yum repo 추가 후 설치 진행
1 2 3 4 5 6 7 |
[root@localhost ~]# yum -y install epel-release [root@localhost ~]# wget https://centos7.iuscommunity.org/ius-release.rpm [root@localhost ~]# rpm -Uvh ius-release.rpm [root@localhost ~]# yum --enablerepo=ius install httpd24u httpd24u-tools httpd24u-mod_ssl |
11. 기본 설치 했으면 추가적으로 환경설정값을 변경해줘야 한다.
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@localhost ~]# vi /etc/httpd/conf.d/userdir.conf <IfModule mod_userdir.c> UserDir html </IfModule> <Directory "/home/*/html"> AllowOverride FileInfo AuthConfig Limit Options Require method GET POST Options MultiViews SymLinksIfOwnerMatch IncludesNoExec </Directory> |
웹서비스 시작 등록 및 서비스 시작
1 2 3 |
[root@localhost ~]# systemctl enable httpd [root@localhost ~]# systemctl start httpd |
12. php 설치를 진행하기 위해서 동일하게 remi yum을 추가해준다
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@localhost ~]# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm [root@localhost ~]# yum install -y yum-utils [root@localhost ~]# yum-config-manager --disable remi-php54 [root@localhost ~]# yum-config-manager --enable remi-php73 [root@localhost ~]# yum install php73-php.x86_64 php-cli-7.3.8-1.el7.remi.x86_64 php73-scldevel.x86_64 php73-php-xml.x86_64 php73-php-xmlrpc.x86_64 php73-php-soap.x86_64 php73-php-process.x86_64 \ php73-php-pgsql.x86_64 php73-php-pdo.x86_64 php73-php-opcache.x86_64 php73-php-odbc.x86_64 \ php73-php-mysqlnd.x86_64 php73-php-mbstring.x86_64 php73-php-ldap.x86_64 \ php73-php-ldap.x86_64 php73-php-json.x86_64 php73-php-ioncube-loader.x86_64 \ php73-php-intl.x86_64 php73-php-gmp.x86_64 php73-php-gd.x86_64 php73-php-fpm.x86_64 \ php73-php-devel.x86_64 php73-php-dba.x86_64 php73-php-common.x86_64 \ php73-php-cli.x86_64 php73-php-bcmath.x86_64 php73-php-pecl-zip.x86_64 \ php73-php-phpiredis.x86_64 php73-php-pecl-imagick* php73-php-pecl-igbinary.x86_64 \ php73-php-pecl-igbinary-devel.x86_64 php73-php-pecl-geoip.x86_64 php73-php-pecl-xdebug.x86_64 |
13. 기본 php.ini 파일을 수정해주는데 /etc/php.ini 파일이 아닌 remi 경로의 파일을 수정해줘야 한다
1 2 3 4 5 6 |
[root@localhost ]# vi /etc/opt/remi/php73/php.ini short_open_tag = On date.timezone = "Asia/Seoul" error_reporting = "E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED" upload_max_filesize = 12M |
14. php는 apache (httpd)의 mod 방식으로 설치가 진행된게 아닌 fcgi/fpm 모드로 설치가 되었다 그래서 해당 부분의 데몬을 설치 진행해주면된다
1 |
[root@localhost ~]# systemctl start php73-php-fpm |
15. 이제 웹상에서 그럼 php info 화면을 출력해보자
16. 기본값으로 php-fpm을 운용하게 되면 메모리 부족현상이 나올수 있다
환경설정값을 수정해준다 / 적정값 값을 메모리 상태에 따라 적용하면 된다 / 추후 이 부분은 다시 포스팅 할것이다.
1 2 3 4 5 6 7 |
pm = static pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 ;pm.process_idle_timeout = 10s; ;pm.max_requests = 500 |