패키지 기본 설치
설치 전 확인
명령어
rpm -qa | egrep "^(httpd|php|mysql)"
설치 전 mysql 5.7 패키지 추가
명령어
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
설치 전 php 5.6 패키지 추가
명령어
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
remi repo 수정
vi /etc/yum.repos.d/remi.repo
[remi]
enabled=1 | 0 에서 1 수정
[remi-php56]
enabled=1 | 0 에서 1 수정
설치
명령어
yum install httpd mysql mysql-server yum install php php-common
설치 후 확인
명령어
rpm -qa | egrep "^(httpd|php|mysql)" | sort -n
서비스 등록 확인
명령어
service httpd status service mysqld status php -v
httpd 시작 및 설정
명령어
service httpd start
정상이지만, 경고 메시지를 없애고 싶다.
명령어
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.default sed -i 's/\#ServerName www.example.com:80/ServerName www.example.com:80/g' /etc/httpd/conf/httpd.conf diff /etc/httpd/conf/httpd.conf.default /etc/httpd/conf/httpd.conf
"www.example.com" 대신 자신의 도메인을 기입한다. 도메인이 없다면 그대로 두어도 무방하다.
기본사이트 설정
touch /var/www/html/index.html
이제 httpd를 다시 시작
service httpd restart
SQL 설정 부분
mysqld 시작 테스트
service mysqld start
MySQL 초기화 및 패스워드 설정
명령어
/usr/bin/mysql_secure_installation
Root Password 설정 후 기본값으로 실행
기본 언어 설정(UTF-8)
명령어
vi /etc/my.cnf
[mysqld] 항목에 2줄 추가
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
mysql 5.7 이상
validate-password=off
default-time-zone='Asia/Seoul'
재부팅시 자동시작 설정
명령어
chkconfig --list | egrep "mysqld|httpd" chkconfig mysqld on chkconfig httpd on chkconfig --list | egrep "mysqld|httpd" reboot
PHP 기본 설정 부분
MY-SQL PHP 연동 모듈 설치
명령어
yum install php-mysql
이미지 모듈 설치
명령어
yum install php-gd
다국어 모듈 설치
명령어
yum install php-mbstring
추가 모듈 목록 확인
명령어
yum search php-
방화벽 설정
방화벽 포트추가
명령어
vi /etc/sysconfig/iptables
◎ -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT (추가)
방화벽 서비스 재시작
명령어
service iptables restart
방화벽 포트 확인
명령어
iptables -nL
HTTPD용 계정 생성 및 기본 설정
계정생성 및 비밀번호 설정
명령어
useradd [ID] passwd [ID]
계정용 webroot 생성
명령어
su -l [ID] mkdir [디렉토리] exit
Httpd 기본 폴더 지정
명령어
vi /etc/httpd/conf/httpd.conf
아래내용 추가
<VirtualHost *:80>
DocumentRoot
"/home/laelbe/www"
ServerName laelbe.com
ServerAlias www.laelbe.com
<Directory
/home/laelbe/www/
>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
require all granted
<
/Directory
>
<
/VirtualHost
>
Httpd 기본 설정파일 문법 검사
명령어
service httpd configtest
Httpd 기본 설정파일 적용
명령어
service httpd reload 또는 service httpd restart
Httpd 기본 webroot 권한 설정
명령어
chmod 701 /home/*
리눅스 보안강화 모듈 해제하기
명령어
setenforce 0 vi /etc/sysconfig/selinux
파일 중간의 SELINUX=enforcing 을 SELINUX=disabled 로 변경 후 저장