리눅스 apm centos7에서 설치하는 스트립트


#!/bin/bash
 
#####################################################################################
#                                                                                   #
# * CentOS7                                                                         #
# * Apache 2.4.25 , MariaDB 10.1.20, PHP 7.1.0 setup shell script                   #
# * Created Date    : 2016/12/29                                                    #
# * Created by  : Joo Sung ( webmaster@nanoomi.org )                                #
#                                                                                   #
#####################################################################################

##########################################
#                                        #
#          의존성 라이브러리 설치             #
#                                        #
########################################## 
yum -y update
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y --enablerepo=remi update remi-release
yum-config-manager --enable remi | grep -P '\[remi|enabled ='
yum-config-manager --save --setopt=remi.exclude="php-* mysql-*" | grep -P '\[remi\]|exclude = php'

yum install php-cli php-fpm php-common php-pdo php-mysql php-mbstring php-opcache php-xml php-pecl-imagick php-gd php-fileinfo php-imap mcrypt php-mcrypt libmcrypt-devel 
yum -y install ORBit2 a2ps acpid alsa-lib aspell at atk audiofile audit-libs-python autoconf* autofs automake* avahi avahi-glib bc bind bind-chroot bind-libs bind-utils cairo ccid compat-libstdc++-33 conman cpp crash createrepo crypto-utils cryptsetup-luks cups-libs cvs cyrus-sasl-md5 cyrus-sasl-plain dbus-python device-mapper-multipath dhcp dhcp-devel dialog dmraid dos2unix dosfstools dump e2fsprogs-devel ed eject elfutils elfutils-libs enscript expat-devel expect expect-devel expectk fetchmail file finger flex fontconfig fontconfig-devel foomatic ftp gcc gcc-c++ gdb gdbm-devel gettext gfs2-utils glib2-devel glibc-devel glibc-headers gmp-devel gnutls gpm gtk2 hdparm hesiod hicolor-icon-theme imake iptraf iptstate ipvsadm irqbalance kernel-devel kernel-headers keyutils-libs-devel kpartx krb5-devel krb5-workstation ksh lftp libICE libSM libX11 libX11-devel libXau libXau-devel libXcursor libXdmcp libXdmcp-devel libXext libXfixes libXft libXi libXinerama libXpm libXpm-devel libXrandr libXrender libXt libXxf86vm
yum -y install libaio libaio-devel libart_lgpl libbonobo libcurl-devel libdaemon libevent libfontenc libgomp libhugetlbfs libhugetlbfs-devel libidn-devel libmng libnl libnl-devel libpcap libselinux-devel libselinux-python libsepol-devel libsmi libstdc++-devel libsysfs libtiff libtool libtool-ltdl libwvstreams libxml2 libxml2-devel libxml2-python libxslt libxslt-python lksctp-tools logwatch lrzsz lsof m2crypto mailcap mailx make nasm man man-pages man-pages-ko mc mcstrans mdadm memtest86+ mesa-libGL mesa-libGL-devel mgetty microcode_ctl mkbootdisk mlocate mrtg mt-st mtools mtr mutt nc ncurses-devel net-snmp-libs netpbm nfs-utils nmap nscd ntp ntsysv numactl oddjob openssh-clients openssl-devel pam-devel pam_krb5 pam_pkcs11 pango parted parted-devel patch pax pciutils pcsc-lite perl perl-Archive-Tar perl-Compress-Zlib perl-DBI perl-Digest-HMAC perl-Digest-SHA1 perl-HTML-Parser perl-HTML-Tagset perl-IO-Socket-INET6 perl-IO-Socket-SSL perl-IO-Zlib perl-Net-SSLeay perl-Newt perl-Socket6 perl-String-CRC32
yum -y install perl-libwww-perl pkgconfig pm-utils postgresql-libs prelink procmail psacct psutils pulseaudio-esound-compat pyOpenSSL pykickstart pyorbit pyparted python-pyblock quota rdate rdist rmt rpcbind rpm-build rsh rsync rusers rwho samba samba-client samba-common sendmail sendmail-cf setools setserial setuptool shared-mime-info sip sos spamassassin squashfs-tools strace stunnel symlinks sysfsutils syslinux sysstat system-config-date system-config-firewall talk tcl tcp_wrappers tcpdump tcsh telnet telnet-server time tk tmpwatch traceroute tree ttmkfdir unix2dos unixODBC unzip usbutils usermode vim-common vim-enhanced vsftpd wget words xinetd xorg-x11-proto-devel yp-tools ypbind ypserv zip zlib-devel GConf2 ImageMagick ImageMagick-perl avahi-libs bwidget crda cryptsetup-luks-libs cups deltarpm desktop-file-utils device-mapper-multipath-libs dmidecode dmraid-events docbook-dtds flac foomatic-db foomatic-db-filesystem foomatic-db-ppds ghostscript ghostscript-fonts gnome-doc-utils-stylesheets
yum -y install gnome-python2 gnome-python2-canvas gnome-user-docs gnome-vfs2 gpm-libs groff-perl gstreamer gstreamer-tools html2ps hunspell iw jasper-libs kpathsea libIDL libX11-common libXcomposite libXdamage libXdamage-devel libXext-devel libXfixes-devel libXfont libXres libXtst libXxf86vm-devel libasyncns libcanberra libcanberra-gtk2 libcom_err-devel libcroco libdrm-devel libedit libglade2 libgnomecanvas libgsf libnetfilter_conntrack libnfnetlink libnotify libogg libpaper librsvg2 libsamplerate libsndfile libtalloc libtasn1 libtdb libthai libtirpc libusb1 libvorbis libwmf-lite libxcb libxcb-devel lm_sensors-libs mesa-dri-drivers mozilla-filesystem mpfr netpbm-progs ntpdate openjpeg-libs pcsc-lite-libs perl-Compress-Raw-Zlib perl-Crypt-OpenSSL-Bignum perl-Crypt-OpenSSL-RSA perl-Crypt-OpenSSL-Random perl-Date-Manip perl-Digest-SHA perl-Encode-Detect perl-ExtUtils-MakeMaker perl-ExtUtils-ParseXS perl-IO-Compress-Base perl-IO-Compress-Zlib perl-Mail-DKIM perl-MailTools perl-Module-Pluggable 
yum -y install perl-Net-DNS perl-Net-LibIDN perl-NetAddr-IP perl-Package-Constants perl-Pod-Escapes perl-Pod-Simple perl-SNMP_Session perl-Test-Harness perl-Time-HiRes perl-TimeDate perl-YAML-Syck perl-devel perl-libs perl-version pixman poppler poppler-data poppler-utils portreserve psutils-perl pulseaudio pulseaudio-libs pycairo pygobject2 pygtk2 pygtk2-libglade python-decorator python-deltarpm python-slip python-slip-dbus rarian rarian-compat rtkit samba-winbind-clients setools-console setools-gui setools-libs setools-libs-tcl sgml-common sgpio sound-theme-freedesktop speex startup-notification system-config-date-docs system-config-firewall-tui tex-preview texinfo texinfo-tex texlive texlive-dvips texlive-latex texlive-texmf-dvips texlive-texmf-fonts texlive-texmf-latex tokyocabinet urlview urw-fonts usermode-gtk xcb-util xml-common xorg-x11-font-utils xulrunner xz xz-lzma-compat yelp lksctp-tools-devel libtool-ltdl-devel gmp gdbm zlib curl curl-devel openssl* 
yum -y install system-config-securitylevel readline-devel cmake lynx php-snmp gd-devel glibc-* net-tools nano bzip2-devel bison perl-URI
 

##########################################
#                                        #
#           SELINUX disabled             #
#                                        #
##########################################

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

/usr/sbin/setenforce 0
  
 
#방화벽 설정
systemctl mask firewalld 
 
systemctl stop firewalld 
 
#iptables 기본으로 사용할수 있게 설정
systemctl enable iptables 
 
#iptables 서비스 시작
systemctl enable iptables 
 
systemctl start iptables 
 
 
 
 
##########################################
#                                        #
#          APR 설치                       #
#                                        #
##########################################
#apache 설치시 필요한 apr 파일 다운로드
cd /usr/local/src
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
 
#apr 파일 다운로드 체크
if [ -e apr-1.5.2.tar.gz ]; then
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apr 1.5.2 download success----------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
else
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apr 1.5.2 download fail-------------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
   exit
fi
 
#apr 압축풀기
tar zxvf apr-1.5.2.tar.gz
 
#apr 폴더로 접근
cd apr-1.5.2
 
#apr 컴파일
./configure --prefix=/usr/local/apr
 
#apr make make install
make
make install
 
#apr make install이 잘되있는지 확인
if [ "$?" -eq 0 ]; then
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apr 1.5.2 install success-----------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
else
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apr 1.5.2 install fail--------------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
   exit
fi
 
 
 
 
 
##########################################
#                                        #
#         APR-util 설치                  #
#                                        #
##########################################
#apache 설치시 필요한 apr-util 파일 다운로드
cd /usr/local/src
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
 
#apr-util 파일 다운로드 체크
if [ -e apr-util-1.5.4.tar.gz ]; then
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apr-util 1.5.4 download success-----------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
else
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apr-util 1.5.4 download fail--------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
   exit
fi
 
#apr-util 압축풀기
tar zxvf apr-util-1.5.4.tar.gz
 
#apr-util 폴더로 접근
cd apr-util-1.5.4
 
#apr-util 컴파일
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
 
#apr-util make make install
make
make install
 
#apr-util make install이 잘되있는지 확인
if [ "$?" -eq 0 ]; then
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apr-util 1.5.4 install success------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
else
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apr-util 1.5.4 install fail---------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
   exit
fi
 

 
 
 
 
 
##########################################
#                                        #
#          apache 2.4.25 설치             #
#                                        #
##########################################
#apache 파일 다운로드
cd /usr/local/src
wget http://apache.tt.co.kr//httpd/httpd-2.4.25.tar.gz
 
#apache 파일 다운로드 체크
if [ -e httpd-2.4.25.tar.gz ]; then
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------httpd-2.4.25 download success-------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
else
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------httpd-2.4.25.tar.gz download fail---------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
   exit
fi
 
#apache 압축풀기
tar zxvf httpd-2.4.25.tar.gz
 
#apache 폴더 접근
cd httpd-2.4.25
 
#apache 컴파일
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-z --with-pcre --enable-mods-static='vhost_alias log_config logio mime mime_magic alias headers status http negotiation' --enable-mods-shared='file_cache disk_cache deflate expires usertrack unique_id actions userdir autoindex cgi cache mem_cache distcache auth_digest rewrite remoteip' --enable-rewrite --enable-deflate --enable-expires --enable-headers --enable-cache --enable-ssl --disable-imagemap --disable-include --disable-charset-lite --disable-reqtimeout --disable-cgid --disable-asis --enable-so --enable-authn-socache=no --enable-socache-shmcb --enable-socache-dbm=no --enable-ldap=no --enable-authnz-ldap=no --enable-cgid=no --enable-dav=no --enable-dav-fs=no --enable-isapi=no --enable-ext-filter=no --enable-authnz-ldap=no --enable-lbmethod-byrequests=no --enable-lbmethod-bytraffic=no --enable-lbmethod-bybusyness=no --enable-lbmethod-heartbeat=no --enable-dav-lock=no --enable-mpms-shared=all
 
#apache make make install
make
make install
 
#apache make install이 잘되있는지 확인
if [ "$?" -eq 0 ]; then
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apache 2.4.25  install success---------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
else
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------apache 2.4.25  install fail------------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
   exit
fi

 
 
 
##########################################
#                                        #
#         mariaDB 10.1.20 설치            #
#                                        #
##########################################
#php 다운로드 폴더 접근
cd /usr/local/src
 
#mariaDB 10.1.20
wget http://mirrors.accretive-networks.net/mariadb//mariadb-10.1.20/source/mariadb-10.1.20.tar.gz
 
#mariaDB 압축풀기
tar zxvf mariadb-10.1.20.tar.gz
 
#mariaDB 폴더 접근
cd mariadb-10.1.20
 
#libpcre.so.1 심볼릭 링크
ln -s /usr/local/lib/libpcre.so.1 /lib64
 
ln -s /usr/local/lib/libpcre.so.1 /lib
 
#mariaDB 컴파일
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mariadb/data -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATEDX_STORAGE_ENGINE=1 -DWITH_ARIA_STORAGE_ENGINE=1 -DWITH_XTRADB_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system
 
#mariaDB make make install
make
make install
 
 
#MariaDB 서버의 실행시킬 사용자를 생성 및 설정
/usr/sbin/groupadd -g 27 -o -r mysql
 
/usr/sbin/useradd -M -g mysql -o -r -d /usr/local/mariadb/data -s /bin/false -c "MariaDB Server" -u 27 mysql
 
#사용자를 mysql로 한것은 mariaDB는 MySQL과의 호환성으로 인하여 mysql로 하였습니다.
#소유권변경
mkdir -p /usr/local/mariadb/InnoDB/redoLogs
 
mkdir -p /usr/local/mariadb/InnoDB/undoLogs
 
chown -R mysql /usr/local/mariadb/data
 
chgrp -R mysql /usr/local/mariadb
 
mkdir /usr/local/mariadb/logs /usr/local/mariadb/tmp
 
chown mysql.mysql /usr/local/mariadb/tmp
 
chown mysql.mysql /usr/local/mariadb/logs
 
chown -R mysql:mysql /usr/local/mariadb/data
 
#자동 실행 등록
cp /usr/local/mariadb/support-files/mysql.server /etc/rc.d/init.d/mysqld
 
chmod 755 /etc/rc.d/init.d/mysqld
 
chkconfig --add mysqld
 
chkconfig --list | grep mysqld
 
#시스템 테이블 생성
cd /usr/local/mariadb
 
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/data
 
#라이브러리를 추가
echo "/usr/local/mariadb/lib" > /etc/ld.so.conf.d/mysql.conf
 
#64bit 라면 라이브러리를 위해서 심볼릭 링크
cd /usr/local/mariadb
 
ln -s lib lib64
 
cd /usr/local/mariadb/support-files
 
cp my-huge.cnf /etc/my.cnf
 
chmod 755 /etc/init.d/mysqld
 
/etc/init.d/mysqld start
 
 
 
 
##########################################
#                                        #
#          php 7.1.0 설치                #
#                                        #
##########################################
#php 다운로드 폴더 접근
cd /usr/local/src
 
#php 7.1.0 다운로드
wget http://de1.php.net/get/php-7.1.0.tar.gz/from/this/mirror
 
#php 7.1.0 파일 다운로드 체크
if [ -e mirror ]; then
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------php-7.1.0 download success---------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
else
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------php-7.1.0 download fail------------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
   exit
fi
 
#php 7.1.0 압축해제
tar zxvf mirror
 
#php 7.1.0 폴더 접근
cd php-7.1.0
 
#php 7.1.0 컴파일
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-libdir=lib --with-config-file-path=/usr/local/lib --with-curl --enable-calendar --enable-shmop --enable-sockets --with-gd --with-png --with-zlib --with-jpeg --with-freetype --with-iconv --enable-bcmath --enable-exif --with-bz2 --enable-mbstring  --with-mcrypt --with-mysql-sock=/tmp/mysql.sock --with-mysqli=/usr/local/mariadb/bin/mysql_config --with-openssl --with-pdo-mysql=/usr/local/mariadb --enable-opcache --with-mhash --enable-pcntl --enable-mbregex --enable-zip --with-pcre-regex --with-libxml-dir=/usr --with-kerberos --disable-debug --enable-soap --with-gdbm --enable-ftp --enable-inline-optimization --enable-sigchild --enable-maintainer-zts
 
#php 7.1.0 make make install
make
make install
 
#php 7.1.0  make install이 잘되있는지 확인
if [ "$?" -eq 0 ]; then
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------php7.1.0  install  success---------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
else
   echo '                                                                '
   echo '----------------------------------------------------------------'
   echo '----------------php7.1.0  install  fail------------------------'
   echo '----------------------------------------------------------------'
   echo '                                                                '
   exit
fi 
 
 
##########################################
#                                        #
#               apache 등록               #
#                                        #
##########################################
#init.d 에 파일 복사하기
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
 
#/etc/init.d/httpd 서비스 등록을위해 파일내용 변경하기
sed -i 's,\(#!/bin/sh.*\),\1\n# chkconfig: 2345 90 90\n# description: init file for Apache server daemon\n# processname: /usr/local/apache/bin/apachectl\n# config: /usr/local/apache/conf/httpd.conf\n# pidfile: /usr/local/apache/logs/httpd.pid,g;' /etc/init.d/httpd
 
#httpd 서비스 등록
chkconfig --add httpd
chkconfig --list | grep httpd
 
#80포트 열기
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
service iptables save
service iptables restart
 
#httpd.conf 셋팅
sed -i 's,\(IfModule mime_module.*\),\1\nAddType application/x-httpd-php .htm .html .php .ph php3 .php4 .phtml .inc,g;' /usr/local/apache/conf/httpd.conf
 
sed -i 's,\(IfModule mime_module.*\),\1\nAddType application/x-httpd-php-source .phps,g;' /usr/local/apache/conf/httpd.conf
 
sed -i 's/#ServerName/ServerName/' /usr/local/apache/conf/httpd.conf
 
sed -i 's/www.example.com:80/localhost:80/' /usr/local/apache/conf/httpd.conf

sed -i 's/DirectoryIndex index.html/DirectoryIndex index.html index.htm index.php index.php3 index.cgi index.jsp/' /usr/local/apache/conf/httpd.conf

sed -i 's/AllowOverride none/AllowOverride All/' /usr/local/apache/conf/httpd.conf

sed -i 's/#AddHandler cgi-script .cgi/AddHandler cgi-script .cgi/' /usr/local/apache/conf/httpd.conf

cp /usr/local/src/php-7.1.0/php.ini-production /usr/local/lib/php.ini
 
sed -i 's/;opcache.enable_cli=0/opcache.enable_cli=1/' /usr/local/lib/php.ini

sed -i 's/;opcache.memory_consumption=64/opcache.memory_consumption=128/' /usr/local/lib/php.ini

sed -i 's/;opcache.interned_strings_buffer=4/opcache.interned_strings_buffer=8/' /usr/local/lib/php.ini

sed -i 's/;opcache.max_accelerated_files=2000/opcache.max_accelerated_files=4000/' /usr/local/lib/php.ini

sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=60/' /usr/local/lib/php.ini

sed -i 's/;opcache.fast_shutdown=0/opcache.fast_shutdown=1/' /usr/local/lib/php.ini
 
sed -i '1780a\zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20131226/opcache.so' /usr/local/lib/php.ini
 
#httpd start
service httpd start

##########################################
#                                        #
#            profile 파일추가              #
#                                        #
##########################################
 
sed -i 's/PATH=$PATH:$HOME/bin/PATH=$PATH:$HOME/bin:/usr/local/mariadb/bin:/usr/local/apache/bin:/usr/local/php/bin/' /root/.bash_profile

source /root/.bash_profile


##########################################
#                                        #
#        root 폴더에 중요파일 심볼릭링크       #
#                                        #
##########################################

mkdir /root/conf

cd /root/conf

ln -s /usr/local/lib/php.ini /root/conf/php.ini
ln -s /usr/local/apache/conf/httpd.conf /root/conf/httpd.conf
ln -s /usr/local/apache/conf/extra/httpd-vhosts.conf /root/conf/httpd-vhosts.conf
ln -s /etc/my.cnf /root/conf/my.cnf
ln -s /etc/sysconfig/iptables /root/conf/iptables


##########################################
#                                        #
#            install 파일삭제              #
#                                        #
##########################################
#src 폴더에 파일 삭제하기
cd /usr/local/src
 
rm -rf httpd-2.4.25.tar.gz

rm -rf mariadb-10.1.20.tar.gz

rm -rf mirror
 
#httpd restart
service httpd restart

reboot
이 글이 마음에 드셨나요?
지인과 공유해보세요.



Profile

Mr.키아

삶이란 꿈과 희망을 가지고 살아가야한다는 것이다.
대한민국 20대 청년으로 열심히 살아가고있으며
키큰아이, 키큰아이닷컴 등 현재 몇몇 서비스를 운영하고 있습니다.



엮인글 0

https://project.kikni.com/tip/5874/6b6/trackback

댓글 0

"apm centos7에서 설치하는 스트립트"의 첫댓글을 달아주세요!

댓글 달기

댓글을 쓸 수 있는 권한이 없습니다.

팁공유

간단한 일상 팁부터 지식이 필요한 테크니컬 자료를 수집 하는 공간입니다.


커뮤니티



제휴


당신의 인터넷은 감청당하고 있습니다.

광고



kikni
서버에 요청 중입니다. 잠시만 기다려 주십시오...