1.添加CentOS 6.5的epel和remi源。
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm |
2.安装基础工具及库文件
yum -y update yum -y install wget patch make cmake gcc gcc-c++ gcc-g77 perl flex bison file libtool libtool-libs \ autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel \ freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel \ libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 \ krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext \ gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils libcurl-devel \ libmcrypt-devel libedit libedit-devel readline readline-devel pcre pcre-devel |
3.安装mysql
//mysql_install.sh wget -c http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz tar -xzvf cmake-2.8.10.2.tar.gz cd cmake-2.8.10.2 ./bootstrap make && make install cd .. groupadd mysql ;useradd -r -g mysql mysql mkdir -p /usr/local/mysql ;mkdir -p /data/mysqldb wget -c http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.28.tar.gz tar zxvf mysql-5.6.28.tar.gz cd mysql-5.6.28 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1 rm -rf CMakeCache.txt make make install cd /usr/local/mysql chown -R mysql:mysql . cd /data/mysqldb chown -R mysql:mysql . cd /usr/local/mysql scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb \cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf sed -i 's;# basedir = .....;basedir = /usr/local/mysql/;g' /etc/my.cnf sed -i 's;# datadir = .....;datadir = /data/mysqldb;g' /etc/my.cnf sed -i 's;# port = .....;port = 3306;g' /etc/my.cnf sed -i 's;# server_id = .....;server_id = 1;g' /etc/my.cnf sed -i 's;# socket = .....;socket = /usr/local/mysql/mysql.sock;g' /etc/my.cnf cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile echo 'export PATH' >> /etc/profile source /etc/profile ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/include/mysql ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe service mysqld start chkconfig --level 35 mysqld on netstat -tulnp | grep 3306 ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock #测试Mysql mysql -u root -p #(密码为空) mysql> \q #修改Mysql密码为123456 mysqladmin -u root password '123456' mysql -u root -p123456 mysql> \q cd .. |
4.安装PHP
groupadd www && useradd -g www -s /sbin/nologin -M www wget -c http://mirrors.sohu.com/php/php-5.6.2.tar.gz tar zxvf php-5.6.2.tar.gz cd php-5.6.2 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-inline-optimization \ --disable-debug --disable-rpath --enable-shared --enable-fpm --with-fpm-user=www --with-fpm-group=www \ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring \ --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir \ --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets \ --with-curl --with-zlib --enable-zip --with-bz2 --with-readline make && make install /usr/local/php/bin/php --version cp php.ini-development /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm service php-fpm start service php-fpm status vim /etc/profile PATH=/usr/local/php/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH export PATH source /etc/profile php --version chkconfig --level 35 php-fpm on php -m |
5.安装Nginx
wget http://mirrors.sohu.com/nginx/nginx-1.8.0.tar.gz tar zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module \ --with-http_stub_status_module --with-http_realip_module make && make install cd .. wget -c http://soft.vpser.net/lnmp/ext/init.d.nginx cp init.d.nginx /etc/init.d/nginx chmod +x /etc/init.d/nginx chkconfig --level 345 nginx on /etc/init.d/nginx start cd /usr/local/nginx/conf/ vi nginx.conf # ... location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # ... |
5.安装redis-2.8
if [ -s redis-2.8.8 ]; then rm -rf redis-2.8.8/ fi wget -c http://download.redis.io/releases/redis-2.8.8.tar.gz tar zxf redis-2.8.8.tar.gz cd redis-2.8.8/ if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then make PREFIX=/usr/local/redis install else make CFLAGS="-march=i686" PREFIX=/usr/local/redis install fi mkdir -p /usr/local/redis/etc/ cp redis.conf /usr/local/redis/etc/ sed -i 's/daemonize no/daemonize yes/g' /usr/local/redis/etc/redis.conf cd ../ |
6.安装phpredis
function phpredis { if [ -s redis-2.2.5 ]; then rm -rf redis-2.2.5/ fi sed -i '/redis.so/d' /usr/local/php/etc/php.ini wget -c http://pecl.php.net/get/redis-2.2.5.tgz tar zxf redis-2.2.5.tgz cd redis-2.2.5/ /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install cd ../ sed -i '/the dl()/i\ extension = "redis.so"' /usr/local/php/etc/php.ini } |