Rocky Linux 9 / Apache, PHP, MariaDB 설치
Created 2022-12-31
Last Modified 2025-06-29
Apache
설치
- Apache를 설치합니다. 패키지 이름은 httpd입니다.
# dnf install httpd
- httpd 서비스를 시작한다.
# systemctl start httpd
시스템 재부팅 후에도 자동으로 시작되게 하고 싶다면 다음과 같이 명령합니다.
# systemctl enable httpd
방화벽 설정
- http 서비스(80 포트)를 영구적으로 엽니다.
# firewall-cmd --permanent --add-service=http
- https 서비스(443 포트)를 영구적으로 연다.
# firewall-cmd --permanent --add-service=https
- 방화벽을 다시 로드해야 방화벽 설정이 반영됩니다.
# firewall-cmd --reload
테스트
- 웹브라우저로 서버 IP에 접속한다. 다음과 같이 나오면 제대로 설치되고 서비스가 시작된 것입니다.
PHP
설치
- PHP를 설치합니다.
# dnf install php
- Apache를 다시 시작합니다.
# systemctl restart httpd
테스트
- /var/www/html/ 디렉토리에 다음의 내용을 가진 파일을 만들고, phpinfo.php라는 이름으로 저장합니다.
<?php
phpinfo();
?>
- http://<server-ip>/phpinfo.php로 접속했을 때 다음과 같이 나오면 PHP가 제대로 설치된 것입니다.
MaraiDB
설치
- MariaDB를 설치한다. 패키지 이름은 mariadb-server입니다.
# dnf install mariadb-server
- 서비스를 시작합니다. 서비스 이름은 mariadb입니다.
# systemctl start mariadb
시스템 재부팅 후에도 자동으로 시작되게 하고 싶다면 다음과 같이 명령합니다.
# systemctl enable mariadb
기본 설정
- 다음과 같이 명령하여 관리자 비밀번호를 만드는 등 몇 가지 설정을 합니다.
# mysql_secure_installation
- 어떻게 설정해야 할지 모르겠다면, 기본값으로 진행합니다. 과정은 다음과 같습니다.
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]
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n]
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]
... 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]
... 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]
- 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]
... 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!