您的位置:首页 > 运维架构 > Shell

shell centos 6.5 开发环境自动搭建

2015-04-18 11:10 495 查看
#!/bin/bash

### centos 6.5

yum -y update

work_path=`pwd`

echo $work_path

####### install nginx ##############

cat > /etc/yum.repos.d/nginx.repo <<_EOF

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/

gpgcheck=0

enabled=1

_EOF

yum -y install nginx

chkconfig nginx on

service nginx start

######## iptable config for nginx 80 ##########

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT

service iptables save

service iptables restart

############## install mysql ###########

yum -y install mysql mysql-server

chkconfig mysqld on

service mysqld start

mysqladmin -u root password 123456

################# install memcached ##################

yum install -y memcached

chkconfig memcached on

service memcached start

############## install mongodb #############

cat > /etc/yum.repos.d/10gen.repo <<_EOF

[10gen]

name=10gen Repository

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64

gpgcheck=0

_EOF

yum -y install mongo-10gen-server mongo-10gen

chkconfig mongod on

service mongod start

################ install redis ################

yum -y install redis

chkconfig redis on

service redis start

################### install php #########

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel
krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN pcre-devel libmcrypt libmcrypt-devel

wget http://cn2.php.net/distributions/php-5.5.23.tar.gz
tar -zxvf php-5.5.23.tar.gz

cd php-5.5.23

./configure --prefix=/usr/local/php --with-config-file-path=/etc/php --enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml
--enable-mbstring --disable-rpath --disable-debug --disable-fileinfo --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pcre-regex --with-iconv --with-zlib --with-mcrypt --with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl
--with-imap-ssl

make && make install

mkdir -p /etc/php

cp php.ini-development /etc/php/php.ini

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod 755 /etc/init.d/php-fpm

cat >> ~/.bashrc <<_EOF

export PATH=/usr/local/php/bin:\$PATH

export PATH=/usr/local/php/sbin:\$PATH

_EOF

source ~/.bashrc

cd $work_path

########### install php swoole extension ########

wget https://codeload.github.com/swoole/swoole-src/tar.gz/swoole-1.7.14-stable
tar -zxvf swoole-1.7.14-stable

cd swoole-src-swoole-1.7.14-stable/

/usr/local/php/bin/phpize

./configure --enable-async-mysql

make && make install

echo "extension=swoole.so" >> /etc/php/php.ini

cd $work_path

######## install php redis extension #########

yum -y install git

git clone https://github.com/owlient/phpredis.git
cd phpredis/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

echo "extension = redis.so" >> /etc/php/php.ini

cd $work_path

############ install php memcached extension ##########

wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz

cd libmemcached-1.0.18

./configure

make && make install

cd $work_path

wget http://pecl.php.net/get/memcached-2.2.0.tgz
tar -zxvf memcached-2.2.0.tgz

cd memcached-2.2.0

/usr/local/php/bin/phpize

./configure

make && make install

echo "extension = memcached.so" >> /etc/php/php.ini

cd $work_path

########## install php mongo extension ##########

wget http://pecl.php.net/get/mongo-1.5.8.tgz
tar -zxvf mongo-1.5.8.tgz

cd mongo-1.5.8

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

echo "extension=mongo.so" >> /etc/php/php.ini

cd $work_path

########### install php imagick extension ##########

yum -y install ImageMagick-devel

pecl install imagick

echo "extension=imagick.so" >> /etc/php/php.ini

############ php-fpm start ###########

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

/etc/init.d/php-fpm start

######## nginx domain config #########

cat > /etc/nginx/conf.d/service.conf <<_EOF

server {

listen 80;

server_name service.sinhonet.cn;

root /var/work/www/apkservice/websource;

index index.html index.htm index.php;

if (!-e \$request_filename){

rewrite ^/(.*) /index.php last;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;

include fastcgi_params;

}

}

_EOF

service nginx restart

###### now environment install success , Congratulations #################

######## next you can update your code and modify config file (myql/redis/memcached/mongo ...) #######################3

gd库问题:

1、编译时不编译gd

yum install libvpx libjpeg libpng zlib libXpm libXpm-devel FreeType t1lib libt1-devel -y

2、cd php-dir/ext/gd

./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir --with-freetype-dir

3、echo >> "extension=gd.so"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: