中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

CentOS7安裝LNMP+Mongodb環境

發布時間:2020-07-14 00:44:13 來源:網絡 閱讀:1293 作者:batiraul 欄目:數據庫

CentOS 7   MySQL 5.7.10   Mongo 3.2.1   Nginx 1.8.0   PHP 5.5.31  Redis 3.0.6


====================================== CentOS config
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動

yum install -y iptables-services
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 9312 -j ACCEPT

:wq! #保存退出
systemctl restart iptables.service
systemctl enable iptables.service

vi /etc/selinux/config  #關閉SELINUX
#SELINUX=enforcing #注釋掉
#SELINUXTYPE=targeted #注釋掉
SELINUX=disabled #增加

:wq! #保存退出
setenforce 0 #使配置立即生效

# 修改時間,如果安裝時改了時區則略過
date
timedatectl
timedatectl set-timezone Asia/Shanghai
date
hwclock --show
hwclock --set --date '2016-01-27 00:24:10'
hwclock --hctosys
clock -w
shutdown -r now

# 注意,以下每步wget的安裝包都存放到/usr/local/src;因為部分用到的安裝包需要翻出去下載,不能翻的可在網盤地址【http://pan.baidu.com/s/1boBJxd9】中下載。

============================================= cmake
yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
yum -y install imake mysql-devel
yum -y install net-tools
yum -y install wget

cd /usr/local/src
wget http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
tar -zxvf cmake-2.8.11.2.tar.gz
cd cmake-2.8.11.2
./configure
make
make install

============================================= mysql
cd /usr/local/src
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.10.tar.gz
groupadd mysql #添加mysql組
useradd -g mysql mysql -s /bin/false #創建用戶mysql并加入到mysql組,不允許mysql用戶直接登錄系統
mkdir -p /home/mysql/data #創建MySQL數據庫存放目錄
chown -R mysql:mysql /home/mysql/data
mkdir -p /usr/local/mysql
tar -zxvf mysql-5.7.10.tar.gz
cd mysql-5.7.10
# 配置,解決CMake Error,如果已經下載boost則執行以下操作,否則將以下cmake的-DDOWNLOAD_BOOST=0變為1
mkdir /usr/local/boost
cp /usr/local/src/boost_1_59_0.tar.gz /usr/local/boost/boost_1_59_0.tar.gz
cd /usr/local/boost
tar -zxvf boost_1_59_0.tar.gz
cd /usr/local/src/mysql-5.7.10
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=0 -DWITH_BOOST=/usr/local/boost
make
make install
cd /usr/local/mysql
# 執行以下初始化命令前保證 /home/mysql/data 下無任何文件和目錄!
bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/home/mysql/data
mkdir -p /home/mysql/data/undolog  # undo存放空間,必須安裝時設置innodb_undo_directory、innodb_undo_tablespaces,非必要用途
chown -R mysql:mysql /home/mysql/data/undolog
# 建立配置文件,如果需要主從復制或者集群,參見另篇博文的mysql部署
cp support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
net_buffer_length=4M
max_allowed_packet=300M
expire_logs_days=15

default_password_lifetime=0    #設為永不過期,默認360天后過期而安裝時無提示,也太坑了

#undo(ibdata) para set on
innodb_undo_log_truncate=ON
innodb_undo_directory=/home/mysql/data/undolog
innodb_undo_tablespaces=4
innodb_max_undo_log_size=10G
[client]
#default-character-set=utf8    #此項最好不添加
:wq! #保存退出

cp support-files/mysql.server /etc/rc.d/init.d/mysqld  #復制啟動腳本到init.d下,而且/etc/init.d與/etc/rc.d/init.d已經建立鏈接
chmod 755 /etc/init.d/mysqld
chkconfig mysqld on
vi /etc/rc.d/init.d/mysqld
basedir=/usr/local/mysql #MySQL程序安裝路徑
datadir=/home/mysql/data #MySQl數據庫存放目錄
:wq! #保存退出

systemctl start mysqld.service #啟動 service mysqld start
vi /etc/profile #把mysql服務加入系統環境變量:在最后添加下面這一行
export PATH=$PATH:/usr/local/mysql/bin
:wq! #保存退出
source /etc/profile

# 下面這兩行把myslq的庫文件鏈接到系統默認的位置,這樣你在編譯類似PHP等軟件時可以不用指定mysql的庫文件地址。
ln -s /usr/local/mysql/lib /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql

mkdir /var/lib/mysql #創建目錄
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock #添加軟鏈接
mysql_secure_installation #(!坑人,不建議執行!)設置Mysql密碼,根據提示按Y 回車輸入2次密碼,不要使用默認生成密碼的方式,記不住

alter user 'root'@'localhost' identified by 'sa'; #或者按這個改默認密碼
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'sa' WITH GRANT OPTION; #允許root遠程登錄,改密碼為'sa'
flush privileges;

# 如果安裝后修改data存放,則需——
service mysqld stop
mkdir /home/mysql/data  #mysql用戶的目錄中建立數據目錄data
cd /data/mysql #原數據目錄
cp -R * /home/mysql/data
chown -R mysql:mysql /home/mysql/data
vi /etc/rc.d/init.d/mysqld
datadir=/home/mysql/data
:wq!
service mysqld start

============================================= nginx
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.8.31.4-beta.tar.gz
wget https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
wget http://nginx.org/download/nginx-1.8.0.tar.gz

tar -zxvf pcre-8.35.tar.gz
mkdir /usr/local/pcre
cd pcre-8.35
./configure --prefix=/usr/local/pcre
make
make install

tar -zxvf openssl-1.0.1h.tar.gz
mkdir /usr/local/openssl
cd openssl-1.0.1h
./config --prefix=/usr/local/openssl
make
make install
vi /etc/profile
export PATH=$PATH:/usr/local/openssl/bin
:wq!
source /etc/profile

tar -zxvf zlib-1.2.8.tar.gz
mkdir /usr/local/zlib
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib
make
make install

tar -zxvf v1.8.31.4-beta.tar.gz
cp 1.8.31.4.tar.gz ./ngx_pagespeed-1.8.31.4-beta
cd ngx_pagespeed-1.8.31.4-beta
tar -xzvf 1.8.31.4.tar.gz

groupadd www
useradd -g www www -s /bin/false
tar -zxvf nginx-1.8.0.tar.gz
mkdir /usr/local/nginx
chown -R www:www /usr/local/nginx
cd nginx-1.8.0
./configure --prefix=/usr/local/nginx --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35 --add-module=/usr/local/src/ngx_pagespeed-1.8.31.4-beta
#注意:--with-openssl --with-zlib --with-pcre --add-module 指向的是源碼包解壓的路徑,而不是安裝的路徑,否則會報錯
make
make install
/usr/local/nginx/sbin/nginx
vi /etc/rc.d/init.d/nginx   
###################### 啟動腳本,添加以下內容
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
#configtest || return $?
stop
sleep 1
start
}
reload() {
#configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
:wq!

chmod 755 /etc/rc.d/init.d/nginx
chkconfig nginx on  #systemctl enable nginx , chkconfig --add nginx
vi /usr/local/nginx/conf/nginx.conf
worker_processes  1             #根據cpu內核數(more /proc/cpuinfo|grep "model name")調整worker進程數,1個內核對應1個worker進程
gzip  on;  #去掉注釋  
client_max_body_size 50M;    #增加該項解除上傳限制過小的問題
fastcgi_ignore_client_abort on; #放http段內,解決php fsockopen函數無效問題
client_header_buffer_size 16k;  #放http段內,解決php fsockopen函數無效問題
large_client_header_buffers 4 64k; #放http段內,解決php fsockopen函數無效問題
:wq!
/etc/rc.d/init.d/nginx restart

========================================== php
cd /usr/local/src
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz
wget https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
wget https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
wget http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz
wget ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.12.tar.gz
wget http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.3.tar.gz
wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
wget http://cn2.php.net/distributions/php-5.5.31.tar.gz
wget http://pecl.php.net/get/redis-2.2.4.tgz
wget http://pecl.php.net/get/mongo-1.6.12.tgz
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz    #memcached服務依賴
wget http://www.memcached.org/files/memcached-1.4.25.tar.gz
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz     #memcached擴展依賴
wget http://pecl.php.net/get/memcached-2.2.0.tgz

tar -zxvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
make install

tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install

tar xvf libvpx-v1.3.0.tar.bz2
mkdir /usr/local/libvpx
cd libvpx-v1.3.0
./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
make
make install

tar -zxvf tiff-4.0.3.tar.gz
mkdir /usr/local/tiff
cd tiff-4.0.3
./configure --prefix=/usr/local/tiff --enable-shared
make
make install

tar -zxvf libpng-1.6.12.tar.gz
mkdir /usr/local/libpng
cd libpng-1.6.12
./configure --prefix=/usr/local/libpng --enable-shared
make
make install

tar -zxvf freetype-2.5.3.tar.gz
mkdir /usr/local/freetype
cd freetype-2.5.3
./configure --prefix=/usr/local/freetype --enable-shared
make
make install

tar -zxvf jpegsrc.v9a.tar.gz
mkdir /usr/local/jpeg
cd jpeg-9a
./configure --prefix=/usr/local/jpeg --enable-shared
make
make install

tar -zxvf libgd-2.1.0.tar.gz
mkdir /usr/local/libgd
cd libgd-2.1.0
./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx
make
make install

tar -zxvf t1lib-5.1.2.tar.gz
mkdir /usr/local/t1lib
cd t1lib-5.1.2
./configure --prefix=/usr/local/t1lib --enable-shared
make without_doc  #如果想用make則需先裝latex:yum -y install tetex-latex
make install

\cp -frp /usr/lib64/libltdl.so*  /usr/lib/
\cp -frp /usr/lib64/libXpm.so* /usr/lib/
tar -zxvf php-5.5.31.tar.gz
cd php-5.5.31
export LD_LIBRARY_PATH=/usr/local/libgd/lib
./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-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype
make  #如果出undefined reference to libiconv_open ,使用make ZEND_EXTRA_LIBS='-liconv'
make install

cp php.ini-production /usr/local/php/etc/php.ini  #復制php配置文件到安裝目錄
rm -rf /etc/php.ini  #刪除系統自帶配置文件
ln -s /usr/local/php/etc/php.ini /etc/php.ini   #添加軟鏈接到 /etc目錄
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf  #拷貝模板文件為php-fpm配置文件
ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf  #添加軟連接到 /etc目錄
vi /usr/local/php/etc/php-fpm.conf
pid = run/php-fpm.pid #取消前面的分號
user = www #設置php-fpm運行賬號為www
group = www #設置php-fpm運行組為www
:wq! #保存退出

cp /usr/local/src/php-5.5.31/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm   #拷貝php-fpm到啟動目錄
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig php-fpm on
vi /usr/local/php/etc/php.ini
#編輯配置文件,列出PHP可以禁用的函數,如果某些程序需要用到這個函數,可以刪除,取消禁用。
找到:disable_functions =
修改為:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
找到:;date.timezone = 修改為:date.timezone = PRC #設置時區
找到:expose_php = On 修改為:expose_php = Off #禁止顯示php版本的信息
找到:short_open_tag = Off 修改為:short_open_tag = On #支持php短標簽
找到:opcache.enable=0 修改為:opcache.enable=1 #php支持opcode緩存
找到:opcache.enable_cli=1 修改為:opcache.enable_cli=0 #php支持opcode緩存
在[opcache]添加:zend_extension=opcache.so #開啟opcode緩存功能
:wq!

vi /usr/local/nginx/conf/nginx.conf    #配置nginx支持php, 做如下修改
user www www; #首行user去掉注釋,修改Nginx運行組為www www;必須與/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否則php運行出錯
index index.html index.htm index.php; #添加index.php
取消FastCGI server部分location的注釋,注意fastcgi_param行的參數,改為$document_root$fastcgi_script_name,或者使用絕對路徑
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
:wq!

vi /etc/php-fpm.conf       # 根據內存(grep MemTotal /proc/meminfo | cut -f2 -d:)調整并發請求處理數,每個php-fpm進程占用20m左右物理內存;單獨調高無用,需要對應調整spare_server的配置。
pm.max_children = 20
pm.start_servers = 8       # start_servers = min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.min_spare_servers = 4
pm.max_spare_servers = 12

#******* 安裝擴展php-openssl
cd /usr/local/src/php-5.5.31/ext/openssl/
mv config0.m4 config.m4
/usr/local/php/bin/phpize
./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config
make
make install
vi /usr/local/php/etc/php.ini
加入 extension="openssl.so"

#******* 安裝擴展php-redis
tar -zxvf redis-2.2.4.tgz
cd redis-2.2.4
/usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
 
如果出現:
Cannot find autoconf. Please check your autoconf installation and the  $PHP_AUTOCONF  environment variable is set correctly and then rerun this script.
用下面的方法解決:
# wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
# tar -zvxf m4-1.4.9.tar.gz
# cd m4-1.4.9/
# ./configure && make && make install
# cd ../
# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
# tar -zvxf autoconf-2.62.tar.gz
# cd autoconf-2.62/
# ./configure && make && make install
 
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
vi /usr/local/php/etc/php.ini
加入 extension="redis.so"

# 所有此般編譯后的so都應出現在該路徑/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/

#******* 安裝擴展mongodb database driver
tar -zxvf mongo-1.6.12.tgz
cd mongo-1.6.12
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
vi /usr/local/php/etc/php.ini
加入 extension="mongo.so"

#******* 安裝memcache服務與memcached擴展
tar -zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/usr/local/libevent
make
make install
tar -zxvf memcached-1.4.25.tar.gz
mv memcached-1.4.25 memcached-svr-1.4.25
cd memcached-svr-1.4.25
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make
make install
vi /etc/init.d/memcached
###################### 啟動腳本,添加以下內容
#! /bin/bash  
#  
# memcached     start/stop the memcached daemon  
#  
# chkconfig: 35 80 70  
# description: memcached is a memory cache server.  
#

prog="memcached"  
exec=/usr/local/memcached/bin/memcached
lockfile=/var/lock/subsys/memcached  
 
# source function library.  
. /etc/rc.d/init.d/functions  
 
start() {  
    if [ $UID -ne 0 ]; then  
        echo "User has insufficient privilege."  
        exit 4  
    fi  
    [ -x $exec ] || exit 5  
    echo -n $"starting $prog: "  
    daemon $exec -u root -d -P /var/run/memcached.pid  
    retval=$?  
    echo  
    [ $retval -eq 0 ] && touch $lockfile  
}  
 
stop() {  
    if [ $UID -ne 0 ]; then  
        echo "User has insufficient privilege."  
        exit 4  
    fi  
    echo -n $"Stopping $prog: "  
        if [ -n "`pidfileofproc $exec`" ]; then  
                killproc $exec  
 
        else  
                failure $"stopping $prog"  
        fi  
    retval=$?  
    echo  
    [ $retval -eq 0 ] && rm -f $lockfile  
}  
 
restart() {  
    stop  
    start  
}  
 
rh_status() {  
    # run checks to determine if the service is running or use generic status  
    status $prog  
}  
 
rh_status_q() {  
    rh_status >/dev/null 2>&1  
}  
 
case "$1" in  
    "start")  
        rh_status_q && exit 0  
        $1  
        ;;  
    "stop")  
        rh_status_q || exit 0  
        $1  
        ;;  
    "restart")  
        rh_status_q || exit 7  
        $1  
        ;;  
    "status")  
        rh_status  
        ;;  
    *)  
        echo $"Usage: $0 {start|stop|status|restart}"  
        exit 2  
        ;;  
esac  
exit $?
:wq!

chmod 755 /etc/init.d/memcached
chkconfig memcached on

tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached --with-memcached=/usr/local/memcached/bin/memcached
make
make install
tar -zxvf memcached-2.2.0.tgz
mv memcached-2.2.0 memcached-so-2.2.0
cd memcached-so-2.2.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl
make
make install
vi /usr/local/php/etc/php.ini
加入 extension="memcached.so"

/etc/init.d/nginx restart #重啟nginx
service php-fpm start #啟動php-fpm

#******* 測試nginx+php
cd /usr/local/nginx/html/  #進入nginx默認網站根目錄
rm -rf /usr/local/nginx/html/*  #刪除默認測試頁
vi index.php
<?php
phpinfo();
?>
:wq!

chown -R www.www /usr/local/nginx/html/
chmod 700 /usr/local/nginx/html/ -R

# 在瀏覽器中打開服務器IP地址,會看到php的界面

============================================== MongoDB
cd /usr/local/src
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.1.tgz
tar -zxvf mongodb-linux-x86_64-rhel70-3.2.1.tgz
mv /usr/local/src/mongodb-linux-x86_64-rhel70-3.2.1 /usr/local/mongodb  #運行目錄

groupadd mongodb
useradd -g mongodb mongodb -s /bin/false
mkdir -p /home/mongodb/db  #數據目錄
mkdir -p /home/mongodb/log  #日志目錄
chown -R mongodb:mongodb /usr/local/mongodb
chown -R mongodb:mongodb /home/mongodb

vi /usr/local/mongodb/mongodb.conf
port=27017
pidfilepath=/usr/local/mongodb/mongo.pid
fork=true
directoryperdb=true
dbpath=/home/mongodb/db
logpath=/home/mongodb/log/mongodb.log
logappend=true
shardsvr=true
#auth=true  #開啟認證
#bind_ip=192.168.1.18   # Listen to local interface only. Comment out to listen on all interfaces.
:wq!

vi /etc/rc.d/init.d/mongod   
############################# 啟動腳本,添加以下內容
#!/bin/sh
# chkconfig: - 64 36
# description:mongodb 3.2.1
case $1 in
start)
/usr/local/mongodb/bin/mongod  --maxConns 20000  --config /usr/local/mongodb/mongodb.conf
;;
stop)
/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()"
;;
status)
/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin --eval "db.stats()"
;;
esac
:wq!

chmod 755 /etc/rc.d/init.d/mongod
chkconfig mongod on
service  mongod  start

vi /etc/profile  #添加環境變量,在最后一行添加下面的代碼
export PATH=$PATH:/usr/local/mongodb/bin
:wq!

source /etc/profile  #使配置立即生效

#啟動MongoDB方式 1
/usr/local/mongodb/bin/mongod --port 27017 --fork --dbpath=/home/mongodb/db/ --logpath=/home/mongodb/log/mongodb.log --logappend
netstat -lanp | grep "27017"  #查看MongoDB是否啟動
cd /usr/local/mongodb/bin/
./mongo  #進入MongoDB數據庫控制臺
use admin  #進入admin數據庫
db.shutdownServer()  #關閉MongoDB數據庫
exit #退出
#啟動MongoDB方式 2
mongo  #進入MongoDB控制臺
show dbs #查看默認數據庫
use admin  #切換到admin數據庫
exit #退出MongoDB控制臺
#啟動MongoDB方式 3
cd /usr/local/mongodb/bin/
./mongod --config /usr/local/mongodb/mongodb.conf  #啟動MongoDB
./mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()"  #關閉MongoDB

#建立索引
>mongo db.table01.ensureIndex({"myid":1});

============================================== sphinx
cd /usr/local/src
wget http://sphinxsearch.com/files/sphinx-2.2.8-release.tar.gz
tar -zxvf sphinx-2.2.8-release.tar.gz
mv /usr/local/src/sphinx-2.2.8-release /usr/local/sphinx
cd /usr/local/sphinx
./configure --prefix=/usr/local/sphinx  –-with-mysql
# 出現下面的就可以進行下一步:
configuration done
-------------------
You can now run 'make install' to ...

make && make install    #安裝結束,到/usr/local 目錄看是否有剛才指定的Sphinx目錄,有安裝成功

# 在make時如果出現undefined reference to libiconv的錯誤:
/usr/local/sphinx/src/sphinx.cpp:20060:undefined reference to `libiconv_open'
/usr/local/sphinx/src/sphinx.cpp:20078: undefined reference to `libiconv'
/usr/local/sphinx/src/sphinx.cpp:20084: undefined reference to `libiconv_close'
collect2: ld returned 1exit status
make[2]:***[indexer]Error1
make[2]:Leaving directory `/home/sphinx/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/sphinx/src'
make: *** [all-recursive] Error 1

解決辦法:打開configure文件,找到“#define USE_LIBICONV 1”,將注釋去掉,并將1改成0。
執行:
#make clean
#make && make install

# 創建索引文件和存放目錄
mkdir /home/sphinx
mkdir /home/sphinx/indexdelta   #創建增量索引存放目錄
useradd sphxrun  #不使用root運行
chown sphxrun:sphxrun -R /home/sphinx
chown sphxrun:sphxrun -R /usr/local/sphinx/var
vi /usr/local/sphinx/etc/sphinx.conf   #修改對應索引的數據存放目錄
:wq!

vi /etc/rc.d/init.d/sphinx
#################### 啟動腳本,添加以下內容,【!!!注意!!!啟動賬戶為新建的用戶“sphxrun”】
#!/bin/sh  
# sphinx: Startup script for Sphinx search  
#  
# chkconfig: 345 86 14  
# description:  This is a daemon for high performance full text \  
#               search of MySQL and PostgreSQL databases. \  
#               See http://www.sphinxsearch.com/ for more info.  
#  
# processname: searchd  
# pidfile: $sphinxlocation/var/log/searchd.pid  
   
# Source function library.  
. /etc/rc.d/init.d/functions  
   
processname=searchd  
servicename=sphinx  
sphinxlocation=/usr/local/sphinx  
pidfile=$sphinxlocation/var/log/searchd.pid  
searchd=$sphinxlocation/bin/searchd
indexer=$sphinxlocation/bin/indexer
cfgfile=$sphinxlocation/etc/sphinx.conf
   
RETVAL=0  
   
PATH=$PATH:$sphinxlocation/bin  
   
start() {
    su - sphxrun -c "$searchd -c $cfgfile > /dev/null 2>&1"
    ret=$?  
    if [ $ret -eq 0 ]; then  
        action $"Starting Sphinx: " /bin/true  
    else  
        action $"Starting Sphinx: " /bin/false  
    fi  
    return $ret
}
stop() {  
    echo -n $"Stopping Sphinx daemon: "  
   
    su - sphxrun -c "$searchd --config $cfgfile --stop"
    #killproc -p $pidfile $servicename -TERM  
    RETVAL=$?  
    echo  
    if [ $RETVAL -eq 0 ]; then  
        rm -f /var/lock/subsys/$servicename  
        rm -f $pidfile  
    fi  
}
indexer(){  
    su - sphxrun -c "$indexer --config $cfgfile --all --rotate > /dev/null 2>&1"
    ret=$?  
    if [ $ret -eq 0 ]; then  
        action $"sphinx making index: " /bin/true  
    else  
        action $"sphinx making index: " /bin/false  
    fi  
    return $ret  
}  
   
# See how we were called.  
case "$1" in  
    start)  
        start
        ;;  
    stop)  
        stop  
        ;;  
    status)  
        status $processname  
        RETVAL=$?  
        ;;  
    restart)  
        stop  
        sleep 3  
        start
        sleep 3
        ;;  
    indexer)
        indexer
        ;;  
    condrestart)  
        if [ -f /var/lock/subsys/$servicename ]; then  
            stop  
            sleep 3  
            start
            sleep 3
        fi  
        ;;  
    *)  
        echo $"Usage: $0 {start|stop|status|restart|indexer|condrestart}"  
        ;;  
esac  
exit $RETVAL
:wq!

chmod 755 /etc/rc.d/init.d/sphinx
chkconfig sphinx on

# 如果sphinx文件太大,刪除對應存放目錄文件
cd /home/sphinx/
rm * -fr
mkdir indexdelta

#如果提示searchd.pid錯誤,則執行下兩步
vi /usr/local/sphinx/var/log/searchd.pid
寫入11770

============================================== jvm
yum search java #找到合適的版本,然后執行install
yum install -y java-1.8.0-openjdk-devel
java -version
vi    /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0  
export JRE_HOME=${JAVA_HOME}/jre  
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile

============================================== redis server
cd /usr/local/src
wget http://download.redis.io/releases/redis-3.0.6.tar.gz
tar -zxvf redis-3.0.6.tar.gz
cd redis-3.0.6
make MALLOC=libc  #如果不加參數,linux下會報錯,沒試過,反正是加上了參數編譯的
make test
make install   #將可執行文件拷貝到/usr/local/bin目錄
mkdir /home/redis   #數據data和日志log目錄
./utils/install_server.sh   #問答式的配置如下,執行腳本使得Redis隨系統啟動
###################################################
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /home/redis/log/redis_6379.log
Data dir       : /home/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
###################################################
chkconfig --list   #檢查是否開機啟動
# 測試
redis-cli
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
src/redis-server &   #啟動redis (后臺開啟服務器)
src/redis-cli shutdown   #關閉redis

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

泰顺县| 大邑县| 兴山县| 邛崃市| 光山县| 珲春市| 昆山市| 乐都县| 云霄县| 尉犁县| 徐州市| 商城县| 芦山县| 米泉市| 顺平县| 友谊县| 吉水县| 三亚市| 弥勒县| 江达县| 佛坪县| 山东| 额敏县| 柏乡县| 石台县| 高淳县| 平原县| 芮城县| 林芝县| 新野县| 台北市| 江永县| 太仆寺旗| 报价| 老河口市| 长泰县| 广西| 平和县| 台江县| 蒙城县| 巨野县|