[web-server] Centos7 apm install

Centos7 apm install

detail 설정의 경우 별도로 정리할 예정입니다.



mariadb 10.2 설치

mariadb repo 확인


[root@centos74 ~]# vi /etc/yum.repos.d/mariadb.repo
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
[root@centos74 ~]# yum clean all && yum list


mariadb 10.2 설치 

[root@centos74 ~]# yum install -y mariadb mariadb-server


mariadb 10.2 start & enable 

[root@centos74 ~]# systemctl start mariadb.service
[root@centos74 ~]# systemctl enable mariadb.service


mariadb secure_installation 실행 (root 패스워드를 설정합니다.)

[root@centos74 ~]# /usr/bin/mysql_secure_installation


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.

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.

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!
[root@centos74 ~]#


mariadb status 확인

[root@centos74 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.2.11-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> status;
mysql  Ver 15.1 Distrib 10.2.11-MariaDB, for Linux (x86_64) using readline 5.1

Connection id:          16
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server:                 MariaDB
Server version:         10.2.11-MariaDB MariaDB Server
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 1 min 54 sec

Threads: 7  Questions: 27  Slow queries: 0  Opens: 18  Flush tables: 1  Open tables: 12  Queries per second avg: 0.236

MariaDB [(none)]>




[root@centos74 ~]# yum install httpd


apache start & enable 

[root@centos74 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@centos74 ~]# systemctl start httpd


php 7.1 설치

[root@centos74 ~]# yum install -y epel-release
[root@centos74 ~]# rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@centos74 ~]# yum clean all && yum list
[root@centos74 ~]# yum update -y
[root@centos74 ~]# init 6
[root@centos74 ~]# yum-config-manager --enable remi-php71
[root@centos74 ~]# yum -y install php php-opcache
[root@centos74 ~]# yum -y install php-mysql
[root@centos74 ~]# yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel


phpinfo 확인

[root@centos74 ~]# vi /var/www/html/info.php
<?php phpinfo(); ?>


apache 재시작

[root@centos74 ~]# systemctl restart httpd




apache MPM 설정

참고 페이지:https://httpd.apache.org/docs/2.4/ko/mod/prefork.htmlhttps://httpd.apache.org/docs/2.4/ko/mod/worker.html

perfork 와 worker 차이점:



[root@centos74 ~]# httpd -V |grep "^Server MPM"
Server MPM:     prefork

확인 Default 는 perfork 입니다.


worker 로 변경

[root@centos74 ~]# vi /etc/httpd/conf.modules.d/00-mpm.conf
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

LoadModule mpm_worker_module modules/mod_mpm_worker.so

[root@centos74 ~]# vi /etc/httpd/conf.modules.d/10-worker.conf
<IfModule mpm_worker_module>
    ServerLimit             250
    StartServers             10
    MinSpareThreads          75
    MaxSpareThreads         250
    ThreadLimit              64
    ThreadsPerChild          32
    MaxClients             8000
    MaxRequestsPerChild   10000

[root@centos74 ~]# systemctl restart httpd
[root@centos74 ~]# httpd -V |grep "^Server MPM"
Server MPM:     worker


apache httpd.conf 설정 

[root@centos74 ~]# vi /etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd"   / apache root 디렉토리

Listen 80                 / apache Port 

Include conf.modules.d/*.conf  /  apache module 디렉토리

User apache                    / apache 실행유저
Group apache                   / apache 실행구룹

ServerAdmin root@localhost     / Server 관리자 e-mail

ServerName www.test.com:80  / Apache Server Domain:port

<IfModule dir_module>
    DirectoryIndex index.html  /Directory index 설정 

bind 설치시 만든 test.com domain 사용


userdir 설정

Default userdir.conf

<IfModule mod_userdir.c>
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    UserDir disabled

    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disabled" line above, and uncomment
    # the following line instead:
    #UserDir public_html

# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
<Directory "/home/*/public_html">
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS


userdir 사용시

    #UserDir disabled
    UserDir public_html

<Directory "/home/*/public_html">
        Options Indexes Includes FollowSymLinks
        Require all granted

참고페이지: http://blog.camilord.com/2014/12/10/centos-7-enable-apache-userdir/


VirtualHost 설정

[root@centos74 ~]# cd /etc/httpd/conf.d/
[root@centos74 conf.d]# vi vhost.conf
#NameVirtualHost *:80
<VirtualHost *:80>
       ServerAdmin admin@test.com
       DocumentRoot /var/www/html/test.com/public_html
       ServerName test1.com
       ServerAlias www.test1.com
       ErrorLog logs/test1.com-error_log
       CustomLog logs/test1.com-access_log common
<VirtualHost *:80>
       ServerAdmin admin@test.com
       DocumentRoot /var/www/html
       ServerName test.com
       ServerAlias www.test.com
       ErrorLog logs/test.com-error_log
       CustomLog logs/test.com-access_log common

참고페이지: https://linode.com/docs/web-servers/apache/install-and-configure-apache-on-centos-7/


 apache 재시작및 phpinfo 확인

[root@centos74 ~]# systemctl restart httpd
[root@centos74 ~]# mkdir -p /var/www/html/test.com/public_html/
[root@centos74 ~]# vi /var/www/html/test.com/public_html/index.php
<?php phpinfo(); ?>










답글 남기기