WEB服务器 (190) 安装文档
目录
导入 GPG keys
<source lang="bash"> rpm --import /etc/pki/rpm-gpg/RPM* </source>
更新所需程序包
<source lang="bash"> yum -y install gcc gcc-c++ autoconf automake zlib libtool zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libc-cilent libc-client-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel </source>
下载安装包
<source lang="bash"> mkdir /data cd /data/ wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz wget http://nginx.org/download/nginx-1.0.15.tar.gz wget http://cn.php.net/get/php-5.4.0.tar.gz/from/this/mirror wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz wget http://pecl.php.net/get/imagick-2.3.0.tgz wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2 wget http://pecl.php.net/get/memcache-3.0.5.tgz wget http://pecl.php.net/get/memcached-2.0.1.tgz wget http://www.imagemagick.org/download/ImageMagick.tar.gz wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.23.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
tar vzxf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local make && make install cd .. tar vjxf libmcrypt-2.5.8.tar.bz2 cd libmcrypt-2.5.8 ./configure make && make install ldconfig cd libltdl/ ./configure --enable-ltdl-install make && make install cd ../../ tar vzxf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9 ./configure make && make install cd .. ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4 ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 ln -s /usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config tar vzxf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8 ldconfig ./configure make && make install cd .. </source>
安装 MySQL,建立数据库并把MySQL加入启动项
安装 MySQL <source lang="bash"> tar vzxf cmake-2.8.4.tar.gz cd cmake-2.8.4 ./configure make && make install cd ..
tar vzxf mysql-5.5.23.tar.gz cd mysql-5.5.23 cmake -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_PROFILING=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data make make install chown -R mysql:mysql /usr/local/mysql/ ln -s /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16 cd support-files/ cp my-medium.cnf /etc/my.cnf cp mysql.server /etc/init.d/mysqld cd ../../ </source> 建立数据库 <source lang="bash"> /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/var/mysql/data --user=mysql </source> 把MySQL加入启动项 <source lang="bash"> vim /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/var/mysql/data
chmod a+x /etc/init.d/mysqld chkconfig --level 345 mysqld on </source> 启动MySQL <source lang="bash"> service mysqld start </source>
安装 PHP
安装 PHP5.4.0 <syntaxhighlight lang="bash"> groupadd www useradd -g www www tar vxzf php-5.4.0.tar.gz cd php-5.4.0
- old###
./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mbstring --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-sockets --enable-zip --with-config-file-path=/usr/local/php/etc --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-imap --with-kerberos --with-imap-ssl --with-mhash --with-mcrypt --with-curl --with-openssl --with-gettext --with-iconv-dir --with-libxml-dir --enable-inline-optimization --enable-mbstring --enable-xml --enable-ftp --enable-gd-native-ttf --enable-pcntl
- new###
./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mbstring --with-mysqli=/usr/bin/mysql_config --with-mysql --with-pdo-mysql --enable-sockets --enable-zip --with-config-file-path=/usr/local/php/etc --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-imap --with-kerberos --with-imap-ssl --with-mhash --with-mcrypt --with-curl --with-openssl --with-gettext --with-iconv-dir --with-libxml-dir --enable-inline-optimization --enable-mbstring --enable-xml --enable-ftp --enable-gd-native-ttf --enable-pcntl -with-zlib --enable-exif --with-tidy --enable-soap --enable-mbregex --enable-bcmath --enable-shmop --enable-inline-optimization make ZEND_EXTRA_LIBS='-liconv' make install cp php.ini-production /usr/local/php/etc/php.ini ln -s /usr/local/php/bin/php /usr/bin/php ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm cd .. </syntaxhighlight> 修改 PHP 配置文件 <syntaxhighlight lang="bash"> vim /usr/local/php/etc/php.ini date.timezone = Asia/Shanghai short_open_tag = On cgi.fix_pathinfo = 0 upload_max_filesize = 10M </syntaxhighlight>
修改 php-fpm 设置 <syntaxhighlight lang="bash"> cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf vim /usr/local/php/etc/php-fpm.conf pm.max_children = 20 pm.start_servers = 10 pm.min_spare_servers = 5 pm.max_spare_servers = 35 </syntaxhighlight> 安装 PHP 扩展 <syntaxhighlight lang="bash"> tar vzxf memcache-3.0.5.tgz cd memcache-3.0.5 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install cd ../ </syntaxhighlight> <syntaxhighlight lang="bash"> vim /usr/local/php/etc/php.ini extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525" extension = "memcache.so" </syntaxhighlight>
安装 nginx
<source lang="bash"> tar vzxf pcre-8.30.tar.gz cd pcre-8.30 ./configure make && make install cd .. tar vzxf nginx-1.0.15.tar.gz cd nginx-1.0.15 ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module make make install ln -s /usr/local/lib/libpcre.so.1 /lib64/libpcre.so.1 </source>
启动 php-fpm
<source lang="bash"> /usr/local/php/sbin/php-fpm /usr/local/php/sbin/php-fpm -t kill -SIGINT `cat /usr/local/php/var/run/php-fpm.pid` 终止 kill -SIGUSR2 `cat /usr/local/php/var/run/php-fpm.pid` 重启 kill -SIGUSR1 `cat /usr/local/php/var/run/php-fpm.pid` 日志 </source>
安装 GIT
<source lang="bash"> cd /data/ wget http://git-core.googlecode.com/files/git-1.7.10.tar.gz tar vzxf git-1.7.10.tar.gz cd git-1.7.10 ./configure --prefix=/usr/local make install ln -s /usr/local/lib/libiconv.so.2 /lib64/ ln -s /usr/local/lib/libcharset.so.1 /lib64/ </source>
安装 Sphinx
<source lang="bash"> wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz tar vzxf coreseek-3.2.14.tar.gz cd coreseek-3.2.14 cd mmseg-3.2.14/ ./bootstrap ./configure --prefix=/usr/local/mmseg3 make && make install cd ..
cd csft-3.2.14 autoreconf ./buildconf.sh export LIBS="-liconv" ./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql make && make install cd /usr/local/mmseg3/etc /usr/local/mmseg3/bin/mmseg -u unigram.txt </source>
安装 libevent
<source lang="bash"> wget https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz tar vzxf libevent-2.0.18-stable.tar.gz cd libevent-2.0.18-stable ./configure make && make install cd .. ln -s /usr/local/lib/libevent-2.0.so.5 /lib64/ </source>
安装 memcached并启动
安装memcached <source lang="bash"> wget http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz tar vzxf memcached-1.4.13.tar.gz cd memcached-1.4.13 ./configure make && make install cd .. </source> 启动 memcache <source lang="bash"> /usr/local/bin/memcached -m 10m -p 11211 -d -u root -P /var/run/memcached.pid -c 256 </source>