服务器应用安装文档
App 服务器应用安装文档
- 安装依赖包
yum install gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-server readline-devel pcre-devel openssl-devel gcc gcc-c++ gcc-g77 gd -y
- openresty 安装
wget http://openresty.org/download/openresty-1.11.2.2.tar.gz
wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
groupadd www
useradd –g www www –s /bin/false
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install
tar zxf openresty-1.11.2.2.tar.gz
cd openresty-1.11.2.2
./configure --with-luajit
gmake && gmake install
vim /usr/local/openresty/nginx/conf/nginx.conf
/usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf
- php 安装
yum install –y libjpeg-devel curl-devel bzip2-devel libxml2-devel libpng-devel freetype-devel
./configure --prefix=/usr/local/php --with-libxml-dir=/usr/include/libxml2 --with-config-file-path=/usr/local/php/etc/ --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --enable-gd-native-ttf --with-zlib --with-mcrypt --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --with-xmlrpc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mbstring --with-zlib-dir --with-bz2 --with-curl --enable-exif --enable-ftp --with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 --with-freetype-dir=/usr/lib64 --with-iconv --enable-xml --enable-bcmath --enable-sysvsem --enable-inline-optimization --enable-mbregex --with-openssl --enable-pcntl --with-gettext --enable-session
make && make install
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
/usr/local/php/sbin/php-fpm
3.1 php-msgpack扩展
wget http://pecl.php.net/get/msgpack-0.5.6.tgz
tar zxf msgpack-0.5.6.tgz
cd msgpack-0.5.6
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vim /usr/local/php/etc/php.ini
安装完成需要重启php
3.2 php-redis 扩展
wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
tar zxf 2.2.4.tar.gz
cd phpredis-2.2.4/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vim /usr/local/php/etc/php.ini
重启php
- autoconf 安装
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
yum install libtool exp at-devel mysql-devel
cd autoconf-2.69
./configure --prefix=/usr
make && make install
/usr/bin/autoconf –V
- coressek 安装
wget http://www.coreseek.cn/uploads/csft/4.0/coreseek-4.1-beta.tar.gz
yum install mysql-devel libxml2-devel expat-devel gcc gcc-c++
tar zxf coreseek-4.1-beta.tar.gz
cd coreseek-4.1-beta/mmseg-3.2.14/
./bootstrap
./configure --prefix=/usr/local/mmseg3
make && make install
cd ../csft-4.1
sh buildconf.sh
./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 ../testpack/
cat var/test/test.xml
/usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc/ var/test/test.xml
/usr/local/coreseek/bin/indexer -c etc/csft.conf --all
/usr/local/coreseek/bin/search -c etc/csft.conf 网络
ln -s /usr/local/coreseek/bin/* /usr/bin/
- ssdb 安装
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
yum install -y gcc gcc-c++ gcc-g77
unzip master
cd ssdb-master
make && make install
设置随系统启动
cp /ssdb-master/tools/ssdb.sh /etc/init.d/ssdb
vim /etc/init.d/ssdb
configs="/usr/local/ssdb/ssdb.conf"
chkconfig —-add ssdb
chkconfig ssdb on
ln -sv /usr/local/ssdb/* /usr/bin/
/etc/init.d/ssdb start
老版本手动启动
/usr/local/ssdb/ssdb-server -d /usr/local/ssdb/ssdb.conf 参数 -d 为后台启动
- redis 安装
wget http://download.redis.io/releases/redis-2.8.7.tar.gz
wget http://download.redis.io/releases/redis-2.8.4.tar.gz
wget http://redis.googlecode.com/files/redis-2.6.13.tar.gz
wget http://download.redis.io/releases/redis-2.8.13.tar.gz
tar zxf redis-3.0.3.tar.gz
cd redis-3.0.3
make && make install
mkdir -p /usr/local/redis/{bin,etc,log,var}
mv src/mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server redis-trib.rb /usr/local/redis/bin/
cp redis.conf /usr/local/redis/etc/
修改配置文件项 daemonize为yes以使redis后台启动
启动redis,需加上配置文件地址 否则报错
vim /usr/local/redis/etc/redis.conf
启动 redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
- mysql 安装
#下载mysql源码包及编译工具cmake
wget https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
wget http://www.cmake.org/files/v3.3/cmake-3.3.0.tar.gz
tar zxf cmake-3.3.0.tar.gz
cd cmake-3.3.0
#编译安装cmake
./configure && make && make install
#添加组及用户
groupadd mysql
useradd –g mysql mysql –s /bin/false
#创建mysql数据目录并给mysql赋权
mkdir –p /data/mysql/{data,tmp}
chown –R mysql.mysql /data/mysql
tar zxf mysql-5.6.26.tar.gz
cd mysql-5.6.26/
#编译mysql
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
#安装mysql
make && make install
#赋权
chown -R mysql.mysql /usr/local/mysql
#初始化db
cd /usr/local/mysql/scripts/
./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/data
#把mysql启动脚本移动到服务启动与管理目录
cd ../support-files/
cp mysql.server /etc/rc.d/init.d/mysqld
#修改mysqld 启动指定的安装目录及数据目录
vim /etc/rc.d/init.d/mysqld
修改
basedir=/usr/local/mysql/
datadir=/data/mysql/data/
#开机自启
chkconfig --add mysqld
chkconfig --level 345 mysqld on
#启动服务
service mysqld start
若报错 ERROR! The server quit without updating PID file
则修改配置文件/etc/my.cnf
给root添加密码
update mysql.user set password=PASSWORD('密码') WHERE user='root';
删除匿名用户
delete from mysql.user where user='';
添加用户
GRANT USAGE ON *.* TO 'appwriter'@'localhost' IDENTIFIED BY 'appwr@zxcv' WITH GRANT OPTION;
赋权远程访问
GRANT ALL PRIVILEGES ON *.* TO 'appwriter'@'%' IDENTIFIED BY 'appwr@zxcv' WITH GRANT OPTION;
最大权限
grant all privileges on *.* to appwriter@localhost identified by 'appwr@zxcv';
给用户添加操作某个库的权限
grant select,update on *.* to appwriter@localhost identified by 'appwr@zxcv';
flush privileges;
查看用户
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
- Python-2.7、scrapy 安装
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
tar zxf Python-2.7.10.tgz
cd Python-2.7.10
./configure --prefix=/usr/local/python2.7
make && make install
ln –s /usr/local/python2.7/bin/python /usr/bin/
python –V
yum install libxml* libxslt-devel libffi-devel openssl*
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz
tar zxf setuptools-2.1.tar.gz
cd setuptools-2.1
python setup.py build
python setup.py install
wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-1.5.tar.gz
tar zxf pip-1.5.tar.gz
cd pip-1.5
python setup.py install
ln -s /usr/local/python2.7/bin/pip /usr/bin/
wget https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.15.1.tar.gz
tar zxf pyOpenSSL-0.15.1.tar.gz
cd pyOpenSSL-0.15.1
python setup.py install
pip install scrapy
./scrapy version
- python-mysql 安装
wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip
unzip mysql-connector-python-2.0.4.zip
cd mysql-connector-python-2.0.4
python setup.py install
- python-redis 安装
wget https://pypi.python.org/packages/source/r/redis/redis-2.8.0.tar.gz
tar -zvxf redis-2.8.0.tar.gz
mv redis-2.8.0 python-redis-2.8.0
cd python-redis-2.8.0
python setup.py install
- mongodb 安装
64位http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.5.tgz
tar zxf mongodb-linux-x86_64-2.4.5.tgz
groupadd mongo
useradd -g mongo mongo -s /bin/nologin
mkdir -p /usr/local/mongodb/{db,logs}
cp -r mongodb-linux-x86_64-2.4.5/bin /usr/local/mongodb/
chown -R mongo:mongo /usr/local/mongodb
vim /etc/mongod.conf 添加以下内容
================================mongod.conf开始=========================
# mongo.conf
#where to log
logpath=/usr/local/mongodb/logs/mongod.log
logappend=true
# fork and run in background
fork = true
#port = 27017
dbpath=/usr/local/mongodb/db/
# location of pidfile
pidfilepath = /var/run/mongodb/mongod.pid
# Disables write-ahead journaling
# nojournal = true
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog = 0
# Ignore query hints
#nohints = true
# Disable the HTTP interface (Defaults to localhost:27018).
#nohttpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Accout token for Mongo monitoring server.
#mms-token = <token>
# Server name for Mongo monitoring server.
#mms-name = <server-name>
# Ping interval for Mongo monitoring server.
#mms-interval = <seconds>
# Replication Options
# in replicated mongo databases, specify here whether this is a slave or master
#slave = true
#source = master.example.com
# Slave only: specify a single database to replicate
#only = master.example.com
# or
#master = true
#source = slave.example.com
=========================mongod.conf结束==========================================
vim /etc/init.d/mongod 添加mongo自启动
================================== 开始 ====================================
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /etc/mongod.conf
# pidfile: /var/run/mongo/mongod.pid
/etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
# NOTE: if you change any OPTIONS here, you get what you pay for:
# this script assumes all options are in the config file.
CONFIGFILE="/etc/mongod.conf"
OPTIONS=" -f $CONFIGFILE"
SYSCONFIG="/etc/sysconfig/mongod"
# FIXME: 1.9.x has a --shutdown flag that parses the config file and
# shuts down the correct running pid, but that's unavailable in 1.8
# for now. This can go away when this script stops supporting 1.8.
DBPATH=`awk -F= '/^dbpath=/{print $2}' "$CONFIGFILE"`
PIDFILE=`awk -F= '/^dbpath\s=\s/{print $2}' "$CONFIGFILE"`
mongod=${MONGOD-/usr/local/mongodb/bin/mongod}
MONGO_USER=mongo
MONGO_GROUP=mongo
if [ -f "$SYSCONFIG" ]; then
. "$SYSCONFIG"
fi
# Handle NUMA access to CPUs (SERVER-3574)
# This verifies the existence of numactl as well as testing that the command works
NUMACTL_ARGS="--interleave=all"
if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
then
NUMACTL="numactl $NUMACTL_ARGS"
else
NUMACTL=""
fi
start()
{
echo -n $"Starting mongod: "
daemon --user "$MONGO_USER" $NUMACTL $mongod $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
}
stop()
{
echo -n $"Stopping mongod: "
killproc -p "$PIDFILE" -d 300 /usr/bin/mongod
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod
}
restart () {
stop
start
}
ulimit -n 12000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/mongod ] && restart || :
;;
status)
status $mongod
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
==================================== 结束 =========================================
chmod +x /etc/init.d/mongod
chkconfig --add mongod
chkconfig --level 345 mongod on
ln -s /usr/local/mongodb/bin/* /usr/bin/