Linux

[Linux] CentOS7 에 APM(Apache + PHP + Mysql) + Wordpress 설치

오늘보다 더 나은 내일을 위해 2017. 9. 24. 12:59

버전 정보

apache : 2.4.6

php : 7.1.9

mysql : 5.7.19


Apache                                                    

버전 : 2.4.6


1.

# yum -y update

# yum -y upgrade


2. Apache 설치

# yum -y install httpd


3. Apache 시작

# systemctl start httpd


4. 시스템 시작시 Apache가 실행되도록 하려면

systemctl enable httpd



5. 방화벽 설정도 해줍니다.

firewall-cmd --add-service=http --permanent

firewall-cmd --add-service=https --permanent

firewall-cmd --reload 



여기까지 설정 한 뒤에 웹브라우저에 http:// ip 주소 로 접속했을때 아래와 같은 화면이 나오면 성공!







PHP                                                        

버전 : 7.1.9


CentOS7에서 yum으로 바로 설치해주면 편하지만 그렇게 설치하면 php5 가 설치되기 때문에 번거롭지만 파일을 다운받아서 설치해줘야 합니다.



# yum install wget

# wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm

# rpm -Uvh remi-release-7.rpm

# yum install yum-utils -y

# yum-config-manager --enable remi-php71


# yum -y install php php-mysql php-gd


설치가 잘 됐는지 확인해봅시다. 

아래 경로에 파일을 하나 만들어서 내용을 입력해줍니다.

# vi /var/www/html/index.php


<?php

phpinfo();

?>


 

그리고 http://IP주소 로 접속했을 때 아래와 같은 화면이 나오면 성공! 아래 패이지가 나온거 확인 했으면 보안을 위해 index.php 파일은 지워주세요~






MySQL                                                    

버전 : 5.7.19


Centos7 부터 데이터베이스가 Mariadb로 바뀌어서 MySql을 yum 으로 바로 설치 할 수 없게되었습니다.

그렇기 때문에 아래 명령을 차례로 입력해줍니다.



1. yum repository Package 다운

# wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm


2. Package 설치

# yum localinstall mysql57-community-release-el7-7.noarch.rpm



3. MySQL yum repository 활성화

# yum repolist enabled | grep "mysql.*-community.*"

mysql-connectors-community/x86_64       MySQL Connectors Community           33

mysql-tools-community/x86_64            MySQL Tools Community                47

mysql57-community/x86_64                MySQL 5.7 Community Server          187


4. MySQL 설치

# yum install mysql-community-server mysql mysql-libs mysql-devel mysql-server


5. MySQL 시작

# systemctl start  mysqld.service

# systemctl enable  mysqld.service


6. 임시 비밀번호 확인

sudo grep 'temporary password' /var/log/mysqld.log

2017-09-13T07:43:15.625115Z 1 [Note] A temporary password is generated for root@localhost: 패스워드



7. Secure 환경 설정

sudo mysql_secure_installation

6번에서 확인했던 패스워드를 여기에서 입력해주면 됩니다. 그리고 root계정 패스워드 설정한 뒤에 나머지 다 y 해주면 됩니다




Wordpress                                               

버전 : 4.8.1


1. wordpress를 다운받은 후 풀어줍니다.

# cd /var/www/html

# wget https://wordpress.org/latest.tar.gz

# tar -zxvf latest.tar.gz
# rm -rf latest.tar.gz
# cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
# mkdir -p /var/www/html/wordpress/wp-content/uploads
# chown -R apache:apache /var/www/html/wordpress/



2. 그리고 나서 DB를 만들어줍니다.


# mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 24

Server version: 5.7.19 MySQL Community Server (GPL)


Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


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

mysql> create database wordpress;

mysql> show databases;
+-------------------------------+
 |  Database                    | 
+-------------------------------+
 | information_schema    |
 | mysql                           |
 | performance_schema |
 | sys                               |
 | wordpress                    |
 +------------------------------+
 5 rows in set (0.00 sec)

mysql> grant all privileges on wordpress.* to root@localhost identified by '패스워드';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye


3. DB까지 만들었으면 설정파일을 수정 해줘야 합니다.

# vi /var/www/html/wp-config.php


// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'mysql에서 생성한 계정의 패스워드 입력합니다');


/** MySQL hostname */

define('DB_HOST', 'localhost');


/** Database Charset to use in creating database tables. */

define('DB_CHARSET', 'utf8');


/** The Database Collate type. Don't change this if in doubt. */

define('DB_COLLATE', '');



:wq 



그리고 나서 http:// IP 주소 /wordpress 로 접속하면 아래와 같은 화면이 나옵니다.

만약 이 페이지가 나오지 않았다면 설정하는 과정에서 오타나 빼먹은 부분이 없는지 확인해보세요.




페이지 이름과 사용자 이름, 패스워드, 이메일을 입력해주면 이렇게 나옵니다~!!




그리고 다시 http:// IP 주소 /wordpress 로 접속하면 아래와 같은 페이지가 나옵니다!




위의 페이지가 나왔다면 성공입니다~!!