PHP-FPM+mysql+Nginx+Memcached安装简记

#####安装脚本##### #####启动命令##### #/etc/init.d/mysqld start #/usr/local/memcached/bin/memcached -d -c 10240 -m 1024 -u root #php-fpm #nginx -c /usr/local/nginx/conf/nginx.conf #初始环境 yum update yum list yum install gcc yum install cmake yum install gcc-c++ MySQL: wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.28-linux2.6-x86_64.tar.gz #解压缩 tar -xzf mysql-5.5.28-linux2.6-x86_64.tar.gz #拷贝到想要安装的位置 cp -R mysql-5.5.28-linux2.6-x86_64 /usr/local/mysql #添加用户组和用户 /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql #分配权限 chmod +w /usr/local/mysql chmod +w /usr/local/mysql/data chown -R mysql:mysql /usr/local/mysql chown -R mysql:mysql /usr/local/mysql/data cd /usr/local/mysql sh scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data #复制文件到相关目录 cp support-files/my-medium.cnf /etc/my.cnf cp support-files/mysql.server /etc/init.d/mysqld chmod 700 /etc/rc.d/init.d/mysqld chkconfig –add mysqld #启动mysql /etc/init.d/mysqld start (service mysqld start) #修改root密码 /usr/local/mysql/bin/mysqladmin -u root password ‘password’ #创建命令行 ln -s /usr/local/mysql/bin/mysql /bin/mysql #给PHP make时使用 ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /lib64/libmysqlclient.so.18 PHP yum install libxml2-devel yum install curl-devel yum install libjpeg-devel yum install libpng-devel yum install freetype-devel yum install openldap* yum install bison* yum install net-snmp yum install net-snmp-devel yum install libtidy yum install libtidy-devel yum install libxslt-devel #拷贝ldap64bit 到usr/lib cp -frp /usr/lib64/libldap* /usr/lib/ #mcrypt wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz tar zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure && make && make install #找不到mysql_config cp /usr/local/mysql/bin/mysql_config /usr/bin/ #PHP:re2c wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz tar -zxvf re2c-0.13.5.tar.gz cd re2c-0.13.5 ./configure && make && make install #PHP:libiconv wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar zxvf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure –prefix=/usr/local/libiconv make && make install #添加so文件到用户lib目录 ln -s /usr/local/libiconv/lib/libiconv.so /usr/lib64/ ln -s /usr/local/libiconv/lib/libiconv.so.2 /usr/lib64/ cd .. wget http://cn2.php.net/distributions/php-5.4.9.tar.gz tar zxvf php-5.4.9.tar.gz cd php-5.4.9 #防止出现找不到phar.phar文件的情况 cp ext/phar/phar.php ext/phar/phar.phar #编译 ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-pdo-mysql=/usr/local/mysql/ –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-pdo-sqlite –enable-pdo –with-gettext –with-tidy –with-snmp –with-libxml-dir –with-xsl –enable-xml –disable-rpath –disable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fpm –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap –without-pear –disable-debug –disable-ipv6 –enable-fpm make ZEND_EXTRA_LIBS=’-liconv’ make install cp php.ini-production /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf /usr/sbin/groupadd www /usr/sbin/useradd -g www www #修改php-fpm.conf pm.max_children = 64 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 1024 user = www group = www #检查语法 /usr/local/php/sbin/php-fpm -t #创建命令行 ln -s /usr/local/php/sbin/php-fpm /bin/php-fpm #启动php-fpm php-fpm NGINX wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz tar zxvf pcre-8.32.tar.gz cd pcre-8.32 ./configure && make && make install cd .. wget http://nginx.org/download/nginx-1.3.9.tar.gz tar zxvf nginx-1.3.9.tar.gz cd nginx-1.3.9 ./configure –user=www –group=www –prefix=/usr/local/nginx/ –with-http_stub_status_module –with-http_ssl_module –with-http_sub_module –with-md5=/usr/lib –with-sha1=/usr/lib –with-http_gzip_static_module make && make install #创建命令行 ln -s /usr/local/nginx/sbin/nginx /bin/nginx #启动 nginx -c /usr/local/nginx/conf/nginx.conf memcached wget https://github.com/downloads/libevent/libevent/libevent-2.0.16-stable.tar.gz tar zxvf libevent-2.0.16-stable.tar.gz cd libevent-2.0.16-stable ./configure –prefix=/usr/local/libevent make && make install wget https://memcached.googlecode.com/files/memcached-1.4.15.tar.gz tar zxvf memcached-1.4.15.tar.gz cd memcached-1.4.15 ./configure –prefix=/usr/local/memcached –with-libevent=/usr/local/libevent/ make && make install #启动 /usr/local/memcached/bin/memcached -d -c 10240 -m 1024 -u root wget http://download.tangent.org/libmemcached-1.0.14.tar.gz tar zxvf libmemcached-1.0.14.tar.gz cd libmemcached-1.0.14 ./configure –prefix=/usr/local/libmemcached/ –with-libmemcached-dir=/usr/local/libmemcached/ make && make install wget http://pecl.php.net/get/memcached-2.1.0.tgz tar zxvf memcached-2.1.0.tgz cd memcached-2.1.0 /usr/local/php/bin/phpize ./configure –with-php-config=/usr/local/php/bin/php-config make && make install #编辑php.ini [memcached] extension=’memcached.so’ APC–NO wget http://pecl.php.net/get/APC tar zxvf APC /usr/local/php/bin/phpize cd cd APC-3.1.13 ./configure –with-php-config=/usr/local/php/bin/php-config make && make install #编辑php.ini [apc] extension=’apc.so’