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.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
rpm -ivh http://centos.alt.ru/pub/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm
# nginx official repo
# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.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
tomhonsom 于 2013-03-21 14:41:13发表:
多谢了,学习中。。。哈哈
velcbo 于 2012-02-13 08:58:46发表:
猛顶你