nginx 、mysql、php自动安装脚本

在安装之前,请将光盘放在光驱里面 ,如果是虚拟机的情况下,请将两个CD /DVD 、CD/DVD2都加载上光盘,然后将nginx的安装包用winscp工具传到Linux下的/usr/local/src.该脚本在安装时,经屡次调试,如果将sys Init 的脚本内容放在里面,总是会报错,于是我就没有加上。

脚本内容如下:

vi  /hoem/nginx_install.sh

service  iptables  stop
chkconfig iptables  off
setenforce 0

mv  /etc/yum.repos.d/rhel-debuginfo.repo     /etc/yum.repos.d/rhel-debuginfo.repo.bak

cat >/etc/yum.repos.d/rhel-debuginfo.repo <<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
EOF

mkdir -pv  /mnt/cdrom
mount  /dev/cdrom  /mnt/cdrom

yum list all

yum  groupinstall "Development Tools"  -y

yum  groupinstall "Development Libraries" -y


yum -y groupinstall "X Software Development"


yum -y install net-snmp

yum install gcc openssl-devel pcre-devel zlib-devel


groupadd -r nginx
useradd -r -g nginx nginx

cd /usr/local/src
tar  zxvf  nginx-1.4.2.tar.gz
cd  nginx-1.4.2
./configure \
  --prefix=/usr \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --http-log-path=/var/log/nginx/access.log \
  --pid-path=/var/run/nginx/nginx.pid  \
  --lock-path=/var/lock/nginx.lock \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_flv_module \
  --with-http_stub_status_module \
  --with-http_gzip_static_module \
  --http-client-body-temp-path=/var/tmp/nginx/client/ \
  --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
  --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
  --http-scgi-temp-path=/var/tmp/nginx/scgi \
  --with-pcre
  make && make install
 

mkdir  /var/tmp/nginx/client  -pv

nginx

此时安装完毕,查看nginx是否启动:

netstat  -an | more





######################################################################################################################################################################################



Mysql的安装,安装是我采用的通用二进制包。直接解压的那一种。将mysql安装包放在/usr/local/src中。

service  iptables  stop
chkconfig iptables  off
setenforce 0

mv  /etc/yum.repos.d/rhel-debuginfo.repo     /etc/yum.repos.d/rhel-debuginfo.repo.bak

cat >/etc/yum.repos.d/rhel-debuginfo.repo <<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
EOF

mkdir -pv  /mnt/cdrom
mount  /dev/cdrom  /mnt/cdrom

yum list all

yum  groupinstall "Development Tools"  -y

yum  groupinstall "Development Libraries" -y

yum -y groupinstall "X Software Development"

yum -y install net-snmp

yum install gcc openssl-devel pcre-devel zlib-devel

mkdir  /mydata/data  -pv
groupadd -r mysql
useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
chown -R mysql:mysql /mydata/data
cd /usr/local/src
tar zxvf mysql-5.5.39-linux2.6-i686.tar.gz -C /usr/local

cd /usr/local/
ln -sv mysql-5.5.39-linux2.6-i686      mysql

cd mysql
chown -R mysql:mysql  .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data
chown -R root  .

cd /usr/local/mysql

cp support-files/mysql.server  /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

cp support-files/my-large.cnf  /etc/my.cnf

echo "MANPATH  /usr/local/mysql/man" >> /etc/man.config

ln -sv /usr/local/mysql/include  /usr/include/mysql

echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf
ldconfig

echo "/usr/local/mysql/bin" >> /etc/profile.d/mysql.sh
source  /etc/profile

cp  /etc/my.cnf   /etc/my.cnf.bak

sed -i ‘s#thread_concurrency = 8#thread_concurrency = 2#g‘ /etc/my.cnf

 

提示安装完毕后,需要手动做两件事:

1。cd /etc/my.cnf

datadir = /mydata/data  ----加载[mysqld]中

thread_concurrency = 2  ----参数值改为CPU的个数*2。



######################################################################################################################################################################################

php的安装:首先将下面的包放在/usr/local/src

libmcrypt-2.5.8-4.el5.centos.i386.rpm       
libmcrypt-devel-2.5.8-4.el5.centos.i386.rpm 
mcrypt-2.6.8-1.el4.i386.rpm                 
mhash-0.9.9-1.el5.centos.i386.rpm           
mhash-devel-0.9.9-1.el5.centos.i386.rpm    
php-5.4.31.tar.gz
xcache-3.1.0.tar.gz


安装脚本:

service  iptables  stop
chkconfig iptables  off
setenforce 0

mv  /etc/yum.repos.d/rhel-debuginfo.repo     /etc/yum.repos.d/rhel-debuginfo.repo.bak

cat >/etc/yum.repos.d/rhel-debuginfo.repo <<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
EOF


cd /usr/local/src
yum -y groupinstall "X Software Development"
yum -y install net-snmp
tar xf php-5.4.31.tar.gz

#libmcrypt-2.5.8-4.el5.centos.i386.rpm
#libmcrypt-devel-2.5.8-4.el5.centos.i386.rpm
#mhash-0.9.9-1.el5.centos.i386.rpm
#mhash-devel-0.9.9-1.el5.centos.i386.rpm
#mcrypt-2.6.8-1.el5.i386.rpm

rpm  -ivh  *.rpm

cd  php-5.4.31
./configure --prefix=/usr/local/php  --with-openssl --enable-fpm --enable-sockets --enable-sysvshm  --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml  --with-mhash --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl

make
make test
make install

cp sapi/fpm/init.d.php-fpm  /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

sed -i ‘#pm.max_children = 5#pm.max_children = 150#‘ /usr/local/php/etc/php-fpm.conf

sed -i ‘#pm.start_servers = 2#pm.start_servers = 8#‘   /usr/local/php/etc/php-fpm.conf

sed -i ‘#pm.min_spare_servers = 1#pm.min_spare_servers = 5#‘ /usr/local/php/etc/php-fpm.conf

sed -i ‘#pm.max_spare_servers = 3#pm.max_spare_servers = 10#‘ /usr/local/php/etc/php-fpm.conf

echo "pid = /usr/local/php/var/run/php-fpm.pid"  >> /usr/local/php/etc/php-fpm.conf





本文出自 “常用文档” 博客,请务必保留此出处http://yujianglei.blog.51cto.com/7215578/1562861

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。