CentOS 7.x Apache + MariaDB + PHP 설치 쉘스크립트



리눅스 VPS 개설 후 매번 LAMP 설치가 귀찮아서 한번 만들어보았습니다.


#!/bin/sh


if [ `rpm -qa | grep httpd | wc -l` = 0 ] ; then

yum -y install httpd mariadb mariadb-server php php-common php-devel php-fpm php-gd php-mbstring php-mysql

fi


if [ `cat /etc/my.cnf | grep "set names utf8" | wc -l` = 0 ] ; then

echo "[mysqld]" >> /etc/my.cnf

echo "init_connect='set names utf8'" >> /etc/my.cnf

echo "character-set-server=utf8" >> /etc/my.cnf

echo "max_connections=1000" >> /etc/my.cnf

echo "log_slow_queries = On" >> /etc/my.cnf

echo "long_query_time = 5" >> /etc/my.cnf

echo "join_buffer_size = 16MB" >> /etc/my.cnf

echo "key_buffer_size = 8MB" >> /etc/my.cnf

echo "read_rnd_buffer_size = 32MB" >> /etc/my.cnf

echo "sort_buffer_size = 32MB" >> /etc/my.cnf

echo "query_cache_limit = 256KB" >> /etc/my.cnf

echo "query_cache_min_res_unit = 4096" >> /etc/my.cnf

echo "query_cache_size = 16MB" >> /etc/my.cnf

echo "thread_cache_size = 8" >> /etc/my.cnf

echo "table_open_cache = 16384" >> /etc/my.cnf

echo "max_heap_table_size = 256MB" >> /etc/my.cnf

echo "tmp_table_size = 256MB" >> /etc/my.cnf

echo "[Service]" >> /etc/systemd/system/multi-user.target.wants/mariadb.service

echo "LimitNOFILE=32768" >> /etc/systemd/system/multi-user.target.wants/mariadb.service

fi


if [ `cat /etc/php.ini | grep "short_open_tag = On" | wc -l` = 0 ] ; then

sed -i 's/^short_open_tag\ =\ Off/short_open_tag\ =\ On/g' /etc/php.ini

sed -i 's/^allow_url_fopen\ =\ On/allow_url_fopen\ =\ Off/g' /etc/php.ini

sed -i 's/^post_max_size\ =\ 8M/post_max_size\ =\ 32M/g' /etc/php.ini

sed -i 's/^upload_max_filesize\ =\ 2M/upload_max_filesize\ =\ 5M/g' /etc/php.ini

sed -i 's/^;date.timezone\ =/date.timezone\ =\ Asia\/Seoul/g' /etc/php.ini

sed -i 's/^session.gc_maxlifetime\ =\ 1440/session.gc_maxlifetime\ =\ 43200/g' /etc/php.ini

fi

if [ `cat /etc/httpd/conf.d/php.conf | grep "^AddType application/x-httpd-php" | wc -l` = 0 ] ; then

sed -i 's/^AddType\ text\/html\ .php/AddType\ text\/html\ .php\nAddType\ application\/x-httpd-php\ .htm\ .html\ .php\ .php3\ .php4\ .inc/g' /etc/httpd/conf.d/php.conf

fi


systemctl enable httpd.service

systemctl enable mariadb.service

systemctl start httpd.service

systemctl start mariadb.service

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

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

firewall-cmd --reload

mysql_secure_installation


my.cnf 튜닝은 환경에 따라 다르게 설정되어야 합니다.


그리고 php.ini 환경 설정도 개인 마다 다를 수 있으니 참고하시면 됩니다.


CentOS-7.x-LAMP-install.sh.txt


'LINUX' 카테고리의 다른 글

NGINX Service Unavailable  (0) 2017.07.05
MariaDB open_files_limit 값 변경하기  (0) 2017.07.05
리눅스 아파치 로그 IP 정렬방법  (0) 2017.07.03
아파치 BLEXBot 차단하기  (0) 2017.06.26
NGINX phpMyAdmin 연결  (0) 2017.06.26
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,