APM 구성 방법
가상서버에 APM를 구성하는 방법은 아래와 같습니다.
Last updated
$ sudo yum update$ sudo apt-get update$ yum info httpd
$ sudo yum install httpd$ apt-cache show apache2
$ sudo apt-get install apache2$ sudo systemctl start httpd
$ sudo systemctl enable httpd
$ systemctl status httpd$ sudo systemctl start apache2
$ sudo systemctl enable apache2
$ systemctl status apache2$ yum info php
$ sudo yum install php$ apt-cache show php
$ sudo apt-get install php$ sudo vi /var/www/html/index.php
<?php phpinfo(); ?>
$ sudo systemctl restart httpd$ sudo vi /var/www/html/index.php
<?php phpinfo(); ?>
$ sudo systemctl restart apache2$ yum info php-*
$ sudo yum install php-mysqlnd$ apt-cache show php-*
$ sudo apt-get install php-mysqlnd$ sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
$ sudo yum install mysql-server$ wget https://dev.mysql.com/get/mysql-apt-config_0.8.23-1_all.deb
$ sudo dpkg -i mysql-apt-config_0.8.23-1_all.deb
Which MySQL product to you wish to configure? Ok
$ sudo apt-get update
$ sudo apt-get install mysql-server
Enter root password: 비밀번호 입력
Re-enter root password: 비밀번호 입력
Select default authentication plugin: Use Strong Password Encryption (RECOMMENDED)$ sudo systemctl start mysqld
$ sudo systemctl enable mysqld
$ systemctl status mysqld$ sudo systemctl start mysql
$ sudo systemctl enable mysql
$ systemctl status mysql$ sudo grep 'temporary password' /var/log/mysqld.log
2022-10-05T06:33:51.116320Z 1 [Note] A temporary password is generated for root@localhost: y(>j2pun:AN/
$ mysql -u root -p$ mysql -u root -p$ sudo mysql_secure_installation
=== root 계정의 임시 비밀번호 입력 ===
Enter password for user root:
=== root 계정의 새 비밀번호 입력 ===
New password:
Re-enter new password:
=== root 계정의 비밀번호 변경 여부 ===
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
=== 익명의 사용자 삭제 여부 ===
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
=== 원격 접속 차단 여부 ===
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
=== test DB 및 접속 정보 삭제 여부 ===
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
=== 현재 설정한 값들의 적용 여부 ===
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y$ sudo mysql_secure_installation
=== root 계정의 비밀번호 입력 ===
Enter password for user root:
=== 비밀번호 복잡성 설정 여부 ===
Press y|Y for Yes, any other key for No: n
=== root 계정의 비밀번호 변경 여부 ===
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
=== 익명의 사용자 삭제 여부 ===
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
=== 원격 접속 차단 여부 ===
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
=== test DB 및 접속 정보 삭제 여부 ===
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
=== 현재 설정한 값들의 적용 여부 ===
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y$ mysql -u root -p
mysql> create database test;
mysql> create user 'test'@'%' identified by '비밀번호';
mysql> grant all privileges on test.* to 'test'@'%';$ sudo vi /var/www/html/test.php
<?php
error_reporting(E_ALL);
ini_set("display_errors",1);
$con = mysqli_connect("localhost","test","test 계정의 비밀번호","test");
if(!$con) {
die ("fail: ".mysqli_connect_error());
}
echo "success!";
?>
$ sudo systemctl restart httpd$ sudo vi /var/www/html/test.php
<?php
error_reporting(E_ALL);
ini_set("display_errors",1);
$con = mysqli_connect("localhost","test","test 계정의 비밀번호","test");
if(!$con) {
die ("fail: ".mysqli_connect_error());
}
echo "success!";
?>
$ sudo systemctl restart apache2$ sudo yum remove php*
$ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ sudo yum-config-manager --enable remi-php74
$ sudo yum install php php-mysqlnd
$ php -v
PHP 7.4.32 (cli) (built: Sep 28 2022 09:09:55) ( NTS )
$ sudo systemctl restart httpd$ sudo vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.3 CentOS repository list - created 2022-09-30 08:49 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://tw1.mirror.blendbyte.net/mariadb/yum/10.3/centos7-amd64
gpgkey=https://tw1.mirror.blendbyte.net/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
$ sudo yum install MariaDB-server MariaDB-client$ sudo apt-get install apt-transport-https curl
$ sudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'
$ sudo sh -c "echo 'deb https://ftp.ubuntu-tw.org/mirror/mariadb/repo/10.3/ubuntu focal main' >>/etc/apt/sources.list"
$ sudo apt-get install mariadb-server$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
$ systemctl status mariadb$ mysql -u root$ sudo mysql -u root$ sudo mysql_secure_installation
=== 현재 root 계정의 비밀번호가 없기 때문에 엔터 입력 ===
Enter current password for root (enter for none):
=== root 계정의 비밀번호 설정 ===
Set root password? [Y/n] y
New password:
Re-enter new password:
=== 익명의 사용자 삭제 여부 ===
Remove anonymous users? [Y/n] y
=== 원격 접속 차단 여부 ===
Disallow root login remotely? [Y/n] n
=== test DB 및 접속 정보 삭제 여부 ===
Remove test database and access to it? [Y/n] y
=== 현재 설정한 값들의 적용 여부 ===
Reload privilege tables now? [Y/n] y$ mysql -u root -p
MariaDB [(none)]> create database test;
MariaDB [(none)]> create user 'test'@'%' identified by '비밀번호';
MariaDB [(none)]> grant all privileges on test.* to 'test'@'%';$ sudo vi /var/www/html/test.php
<?php
error_reporting(E_ALL);
ini_set("display_errors",1);
$con = mysqli_connect("localhost","test","test 계정의 비밀번호","test");
if(!$con) {
die ("fail: ".mysqli_connect_error());
}
echo "success!";
?>
$ sudo systemctl restart httpd$ sudo vi /etc/my.cnf
[mysqld]
skip-name-resolvemysql> SHOW VARIABLES LIKE 'skip_name_resolve';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| skip_name_resolve | ON |
+-------------------+-------+
1 row in set (0.001 sec)$ sudo vi /etc/mysql/my.cnf
[mysqld]
skip-name-resolvemysql> SHOW VARIABLES LIKE 'skip_name_resolve';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| skip_name_resolve | ON |
+-------------------+-------+
1 row in set (0.001 sec)