歡迎您光臨本站 註冊首頁

lnmp 一鍵安裝腳本

←手機掃碼閱讀     火星人 @ 2014-03-25 , reply:0

nginx 如日中天,故分享一個我寫的安裝腳本,lnmp 是什麼,你懂的!


#!/usr/bin/env bash
# author = purple_grape
# name=lnmp_setup
# version: 0.7
# purpose: ready-to-use lnmp
# test under CentOS 6.2 only , use it at your own risk
# last update : 2012-02-12
# set -x

if [ "$(id -u)" != "0" ]; then
echo "This script is designed to run as root" 1>&2
exit 1
fi
#-------------------------------------------------------------------
# software version
#Linux = RHEL6
#Nginx = 1.0.12
#Mysql = 5.5.20
#PHP = 5.3.10

yum install -y wget curl rsync

rpm -ivh http://download.fedora.redhat.co ... ease-6-5.noarch.rpm
rpm -ivh http://centos.alt.ru/pub/reposit ... ease-6-1.noarch.rpm

# nginx official repo
# rpm -ivh http://nginx.org/packages/centos ... .el6.ngx.noarch.rpm

# remi repo
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

yum update -y

yum install -y nginx-stable \
mysql mysql-server \
php-fpm php-mysql php-cli php-eaccelerator php-gd php-imap php-xml php-xmlrpc php-mbstring php-mcrypt php-pdo php-soap php-tidy

#install some other packages
yum install dejavu-serif-fonts dejavu-sans-fonts dejavu-sans-mono-fonts -y

chkconfig nginx on
chkconfig mysqld on
chkconfig php-fpm on

# nginx via php enable
sed -i '/FastCGI/a\ location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;include fastcgi_params;}' /etc/nginx/nginx.conf

#echo "fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;" >> /etc/nginx/fastcgi_params

# set nginx worker processes
sed -i '/worker_processes/{s/10/2/g}' /etc/nginx/nginx.conf

# modify this to meet nginx verion 1.x
sed -i '/limit_conn/{s/^/#/g}' /etc/nginx/nginx.conf

# correct php-fpm setting
sed -i 's/apache/nginx/g' /etc/php-fpm.d/www.conf

#php timezone setting
sed -i '/;date.timezone/{s/;//g;s/=/= Asia\/Shanghai/g}' /etc/php.ini

# pathinfo
sed -i '/cgi.fix_pathinfo\=/{s/;//g;s/1/0/g}' /etc/php.ini

# set memory limit for php app
sed -i '/memory_limit/{s/128/64/g}' /etc/php.ini

# enable and set shared memory for eaccelerator
sed -i '/shm_size/{s/0/16/g}' /etc/php.d/eaccelerator.ini
sed -i '/shm_only/{s/0/1/g}' /etc/php.d/eaccelerator.ini

/etc/init.d/php-fpm start
/etc/init.d/mysqld start
/etc/init.d/nginx start

mkdir -p /var/www/html

# change the default document root
sed -i 's#\/usr\/share\/nginx\/html#\/var\/www\/html#g' /etc/nginx/nginx.conf

yum install -y centos-indexhtml
rsync -avz /usr/share/doc/HTML/ /var/www/html/

#create php test page
echo "" >/var/www/html/info.php

mysql_secure_installation

# the end

[火星人 ] lnmp 一鍵安裝腳本已經有518次圍觀

http://coctec.com/docs/linux/show-post-156743.html