-
How To Install LEMP? on CentOS 7 [mariadb, php 설치편]Linux 2015. 11. 17. 14:21반응형
안녕하세요.
듀빈입니다. 이번에는 CentOS7 에 LEMP (Linux + Nginx(발음이 엔진이어서 E) 1.8 + MariaDB + php5.6) 설치 방법을 포스팅 하고자 합니다.
설치 환경은 Hyper-v 에 메모리 2기가를 할당하여서 서버를 구동 하였고, 아직 리눅스 초보이기 때문에 모르는 것 투성이니.. 충고나 의견 부탁드립니다~!
Install MariaDB 5.5
첫 번째 단계 : MariaDB 버전 확인
1# yum list mariadb mariadb-servercs
123Available Packagesmariadb.x86_64 1:5.5.44-1.el7_1 updatesmariadb-server.x86_64 1:5.5.44-1.el7_1 updatescs 두 번째 단계 : MariaDB 설치
1# yum install -y mariadb mariadb-servercs
123456789101112131415Installed:mariadb.x86_64 1:5.5.44-1.el7_1mariadb-server.x86_64 1:5.5.44-1.el7_1Dependency Installed:perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7perl-DBD-MySQL.x86_64 0:4.023-5.el7perl-DBI.x86_64 0:1.627-4.el7perl-Data-Dumper.x86_64 0:2.145-3.el7perl-IO-Compress.noarch 0:2.061-2.el7perl-Net-Daemon.noarch 0:0.48-5.el7perl-PlRPC.noarch 0:0.2020-14.el7Complete!cs MariaDB, MariaDB-Server 와 의존 파일들이 설치 된 것을 확인 할 수 있습니다.
세 번째 단계 : MariaDB 시작 및 설정
12# systemctl start mariadb# systemctl enable mariadb.servicecs 네 번째 단계 : MYSQL 보안 설정
1# mysql_secure_installationcs
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou 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): [Enter 입력]OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.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 anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] [y 입력]... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] [y 입력]... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore 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 farwill 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 MariaDBinstallation should now be secure.Thanks for using MariaDB!cs 이렇게 MariaDB 5.5 버전이 설치가 완료 되었습니다. 다음은 php 설치 입니다.
Install PHP 5.6
필자는 php5.6 버전을 설치하도록 하겠습니다. 우선 yum 에 php 5.6가 있는지 확인합니다.
첫 번째 단계 : php5.6 버전 확인
1# yum list phpcs
12Available Packagesphp.x86_64 5.4.16-36.el7_1 updatescs 이용가능한 버전이 5.4 로 뜨게 됩니다. 필자는 5.6을 설치해야 하니 조금 수정하겠습니다.
12# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmcs
1# yum list php56w php56w-mysql php56w-fpm php56w-commoncs 12345Available Packagesphp56w.x86_64 5.6.14-2.w7 webtaticphp56w-common.x86_64 5.6.14-2.w7 webtaticphp56w-fpm.x86_64 5.6.14-2.w7 webtaticphp56w-mysql.x86_64 5.6.14-2.w7 webtaticcs php5.6이 설치가능한 모습을 볼 수 있습니다.
두 번째 단계 : PHP 5.6 설치
1yum -y install php56w php56w-common php56w-mysql php56w-fpm php56w-opcachecs
123456789101112131415Installed:php56w.x86_64 0:5.6.14-2.w7 php56w-common.x86_64 0:5.6.14-2.w7php56w-fpm.x86_64 0:5.6.14-2.w7 php56w-mysql.x86_64 0:5.6.14-2.w7php56w-opcache.x86_64 0:5.6.14-2.w7Dependency Installed:apr.x86_64 0:1.4.8-3.el7apr-util.x86_64 0:1.5.2-6.el7httpd.x86_64 0:2.4.6-31.el7.centos.1httpd-tools.x86_64 0:2.4.6-31.el7.centos.1mailcap.noarch 0:2.1.41-2.el7php56w-cli.x86_64 0:5.6.14-2.w7php56w-pdo.x86_64 0:5.6.14-2.w7Complete!cs PHP 5.6버전과 의존파일들이 설치된 것을 확인할 수 있습니다.
세 번째 단계 : PHP 5.6 과 Nginx 1.8 연동
1# vi /etc/php.inics
12345678910[PHP];;;;;;;;;;;;;;;;;;;; About php.ini ;;;;;;;;;;;;;;;;;;;;~~~~~~~~~~~~~~~~~~~~~~~;cgi.fix_pathinfo=1 // 주석 제거 후 1에서 0으로 수정cgi.fix_pathinfo=0cs
1# vi /etc/php-fpm.d/www.confcs
1234567listen = /var/run/php-fpm/php-fpm.socklisten.owner = nginxlisten.group = nginxuser = nginxgroup = nginxcs 빨간 색 부분을 수정 해 줍니다. 주석이 있을 경우 주석을 제거합니다.
네 번째 단계 : php-fpm 실행 및 자동 실행
12# systemctl start php-fpm# systemctl enable php-fpm.servicecs 다섯 번째 단계 : Nginx 호스트 설정
1# vi /etc/nginx/conf.d/default.confcs
12345678910111213141516171819202122232425server {listen 80;server_name 도메인 이름 or IP or LocalHost;# note that these lines are originally from the "location /" blockroot /usr/share/nginx/html; // 기본적으로 읽어올 폴더index index.php index.html index.htm; // 앞 순서로 파일을 먼저 읽음location / {try_files $uri $uri/ =404;}error_page 404 /404.html;error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}location ~ \.php$ {try_files $uri =404;fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}cs 기본 파일이 있으면 빨간색 부분만 수정 OR 추가 해주시고 없으시면 전체 복사하시면 됩니다.
여섯 번째 단계 : 테스트 프로그램 작성
1# vi /usr/share/nginx/html/index.phpcs
1<?php phpinfo();?>cs 일곱 번째 단계 : 실행 테스트
정상적으로 실행되는 것을 확인 할 수 있습니다! 이로서 LEMP 설치가 완료되었습니다~
반응형'Linux' 카테고리의 다른 글
How To Install LEMP? on CentOS 7 [mariadb, php 설치편] (0) 2015.11.17 How To Install LEMP? on CentOS 7 [Nginx 설치편] (0) 2015.11.16