[Linux] centOS7에 AMP 설치하기

 

워드프레스 설치에 앞서 AMP(apache, mysql, php)를 설치하고자 한다.

 

OS는 Centos7이며, 기본적으로 방화벽, SELINUX는 모두 해제하였습니다.

 

 

1단계. Apache 설치

 

아파치 설치는 이전에 작성한 부분이 있어 링크로 대체합니다.

sh-safer.tistory.com/30

 

[Linux] 리눅스(CentOS7) Apache(아파치) 웹서버 설치

실습 환경 CentOS 7.8 - (IP : 192.168.56.102) 방화벽(iptables) - OFF SELINUX - Disabled httpd 설치 확인 rpm 명령어로 Apache 패키지 설치 여부를 확인합니다. 현재 설치가 안된 상태입니다, [root@linux-2 ~..

sh-safer.tistory.com

 

 

2단계. mysql 설치

 

최근 워드프레스 설치 시 mysql대신 mariadb 설치를 하는 추세인 것 같아 동일하게 mariadb로 진행합니다.

기본적인 명령어는 mysql과 동일하게 때문에 사용하시는데에 별 어려움을 없을 것 같습니다.

 

 

mariadb 설치

yum install mariadb-server -y

 

mariadb 부팅시 자동 시작 설정,  및 서비스 구동

systemctl enable mariadb
systemctl start mariadb

 

mariadb 보안 설정

mysql_secure_installation
[root@linux-1 bin]# 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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

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

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

# bariadb 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.

# root 원격 접속 불가
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

 

 

3단계. php 설치

 

php 설치

 yum install php php-mysql -y

 

httpd 재구동을 해줍니다

systemctl restart httpd

 

php가 정상적으로 설치되었는지 확인해 봐야겠죠

apache 홈 디렉터리에 php 테스트 파일 하나를 생성해보겠습니다

 

apache 홈 디렉터리는 /etc/httpd/conf/httpd.conf 설정 파일에 "DocumentRoot" 설정을 참고하시면 됩니다.

DocumentRoot "/var/www/html"

 

그럼, 홈 디렉터리로 이동해서 아래 내용으로 "infophp.php" 파일을 생성합니다.

<?php 
phpinfo(); 
?>

 

그리고, 웹브라우저에서 접속하여 확인해봅니다.

주소는 [서버 IP]/infophp.php입니다.

 

정상적으로 설치가 되셨다면 아래와 같은 화면이 나타납니다.

댓글

Designed by JB FACTORY

loading