从win转centos7 node的环境部署篇
发布于 10 年前 作者 heixiaoshan 9161 次浏览 最后一次编辑是 8 年前

####centos7 安装最小版 安装完成使用root登陆 centos 7安装mate桌面

1.输入:yum install net-tools
2.安装desktop
rpm -ivh http://mirrors.hustunique.com/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
yum groups install "MATE Desktop"
yum groups install "X Window System"
systemctl set-default graphical.target
3.安装完成,重启
   reboot 
----------------------centos 7安装mate桌面 end---------------------------------------
增加一个SFTP上传的用户
#创建sftp组
groupadd sftp
#创建一个用户dsideal
useradd -g sftp -s /bin/false dsideal
#设置dsideal用户的密码
passwd dsideal
#创建一个sftp的上传目录
mkdir /usr/local/sftp
#修改用户dsideal所在的目录
usermod -d /usr/local/sftp dsideal
#配置sshd_config
vi /etc/ssh/sshd_config
#找到如下这行,并注释掉
#Subsystem      sftp    /usr/libexec/openssh/sftp-server
#添加如下几行
Subsystem sftp internal-sftp    #这行指定使用sftp服务使用系统自带的internal-sftp
Match User dsideal    #这行用来匹配用户
ChrootDirectory /usr/local/sftp    #用chroot将用户的根目录指定到/usr/local/sftp,这样用户就只能在/usr/local/sftp下活动
AllowTcpForwarding no
ForceCommand internal-sftp    #指定sftp命令
#保存退出(按ESC  输入 :wq  回车)
#设定Chroot目录权限
chown -R root:root /usr/local/sftp
chmod 755 /usr/local/sftp/
#建立SFTP用户登入后可写入的目录
mkdir /usr/local/sftp/dsideal
chown -R dsideal:sftp /usr/local/sftp/dsideal/
chmod 755 /usr/local/sftp/dsideal/
#重启sshd服务
service sshd restart

#关闭SElinux
vi /etc/sysconfig/selinux
#找到如下这行
SELINUX=enforcing
#修改为
SELINUX=disabled
#保存退出

#重启服务器
reboot
--------------------增加一个SFTP上传的用户 end------------------------------------------
安装 node.js
1、在根目录下新建一个目录 /down,用来保存下载的文件
# mkdir /down
cd /down
2、安装 node.js 相关软件
首先要安装 gcc gcc-g++ openssl-devel  
# yum install gcc gcc-g++ openssl-devel
#yum install -y bzip2*
yum install libtool automake autoconf gcc-c++ openssl-devel 
# yum install wget
 3、下载 python 2.7
#wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
解压安装
#tar zxvf Python-2.7.8.tgz
#cd Python-2.7.8
#./configure && make && make install

4、下载 node.js 解压 安装
# cd /down
# wget  http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz
# tar zxvf node-v0.10.29.tar.gz
# cd node-v0.10.29
# ./configure && make && make install
npm install -g node-gyp  

这里可能需要几分钟时间
------------------安装 node.js  end--------------------------------
安装MongoDB
1、下载MongoDB(64位)
http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.3.tgz
2、安装MongoDB(安装到/usr/local)(可以直接复制到/usr/local目录下)
tar zxvf mongodb-linux-x86_64-2.6.3.tgz
mv mongodb-linux-x86_64-2.6.3 mongodb
cd mongodb
mkdir data/db
mkdir logs
cd bin
vi mongodb.conf 
dbpath=/usr/local/mongodb/data/db
logpath=/usr/local/mongodb/logs/mongodb.log
port=27017 
fork=true 
nohttpinterface=true
#3、重新绑定mongodb的配置文件地址和访问IP
/usr/local/mongodb/bin/mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf
4、开机自动启动mongodb
vi /etc/rc.d/rc.local 
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
chmod +x /etc/rc.d/rc.local   # 一定要执行这句不然无法开机启动
5、重启一下系统测试下能不能自启
#进入mongodb的shell模式 
/usr/local/mongodb/bin/mongo --port 27017
#查看数据库列表
show dbs
#当前db版本
db.version();
--------------------------安装MongoDB   end----------------------------------------
centos直接yum安装nginx
rpm -ivh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.6.0-2.el7.ngx.x86_64.rpm
yum install -y nginx     #安装nginx,根据提示,输入Y安装即可成功安装
service nginx start    #启动
chkconfig nginx on    #设为开机启动
#仅安装完成,没有与node结合
----------------------centos直接yum安装nginx   end-----------------以下是配置rockmongo的准备 但是没有成功------------------------------------------
安装PHP
1、安装PHP
yum install php   #根据提示输入Y直到安装完成
yum install php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm 
chkconfig php-fpm on #设为开机启动
---------------------------------安装PHP end--------------------------
配置nginx支持php
cp /etc/nginx/nginx.conf  /etc/nginx/nginx.confbak    #备份原有配置文件
vi /etc/nginx/nginx.conf  #编辑
user  nginx  nginx;  #修改nginx运行账号为:nginx组的nginx用户
:wq!    #保存退出
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak   #备份原有配置文件
vi /etc/nginx/conf.d/default.conf   #编辑
index index.php index.html index.htm;   #增加index.php
 # pass the PHPscripts 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;
 }
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
------------------------------------------配置nginx支持php- end--------------------------------
配置php
vi /etc/php.ini   #编辑
date.timezone= PRC     #在946行 把前面的分号去掉,改为date.timezone = PRC
disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec
,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink
,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen
,disk_free_space,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
#在386行 列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off        #在432行 禁止显示php版本的信息
magic_quotes_gpc = On   #在745行 打开magic_quotes_gpc来防止SQL注入
open_basedir = .:/tmp/  #在380行,设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题,可注销此行,或者直接写上程序目录路径/var/www/html/www.osyunwei.com/:/tmp/
:wq! #保存退出
配置php-fpm
cp /etc/php-fpm.d/www.conf   /etc/php-fpm.d/www.confbak   #备份原有配置文件
vi /etc/php-fpm.d/www.conf   #编辑
user = nginx   #修改用户为nginx
group = nginx   #修改组为nginx
nginx  restart  #重启nginx
php-fpm  restart  #重启php-fpm
---------------------------------配置php end-----------------------------------------------
安装apache 配置 rockmongo(没成功)
安装命令:yum install -y unzip zip
安装Apache
#yum -y install httpd
#yum -y install httpd-manual mod_ssl mod_perl
更改端口
#vi /etc/httpd/conf/httpd.conf
Listen 80改为Listen 8899 
更改访问路径
#vi /etc/httpd/conf.d/welcome.conf
<Directory />  改为
<Directory />
    Options Indexes FollowSymLinks Includes
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>
DocumentRoot "/var/www/html" 改为
DocumentRoot "/down/rockmongo" #解压地址
 service httpd restart  # 重启服务
配置rockmongo
# unzip mongo-php-driver-master
# cd mongo-php-driver-master
# /usr/local/php_fcgi/bin/phpize
#  ./configure --with-php-config=/usr/local/php_fcgi/bin/php-config --enable-mongo
# make && make install
# mkdir /usr/local/php_fcgi/ext      //php下新建ext目录,用来存放php扩展
# cp /usr/local/php_fcgi/lib/php/extensions/no-debug-non-zts-20060613/mongo.so /usr/local/php_fcgi/ext/ 
修改php.ini,开启mongo.so,在php.ini中加入一行
#  vim /usr/local/apache/conf/php.ini        
 #可能在/usr/local/php_fcgi/lib/php.ini
加入:extension=/usr/local/php/ext/mongo.so
# service httpd restart
----------------------------安装apache 配置 rockmongo--end----------------------------------------
启动服务:
./mongod --config ./mongodb.conf  #mongodb
service httpd start #Apache
service nginx  start #nginx
开机启动
chkconfig php-fpm on  #php
chkconfig nginx   on  #nginx
chkconfig httpd  on # httpd


---------------------------------yum 安装 mongodb--------------------
1、准备工作

运行yum命令查看MongoDB的包信息 [root[@localhost](/user/localhost)~]# yum info mongo-10gen

(提示没有相关匹配的信息,) 说明你的centos系统中的yum源不包含MongoDB的相关资源,所以要在使用yum命令安装MongoDB前需要增加yum源,也就是在 /etc/yum.repos.d/目录中增加 *.repo yum源配置文件

2、vi /etc/yum.repos.d/10gen.repo,输入下面的语句:


[10gen] 

name=10gen Repository 

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 

gpgcheck=0 

做好yum源的配置后,如果配置正确执行下面的命令便可以查询MongoDB相关的信息: 

查看mongoDB的服务器包的信息

[root[@localhost](/user/localhost) geffzhang]# yum info mongo-10gen-server
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
Installed Packages
Name        : mongo-10gen-server
Arch        : x86_64
Version     : 2.0.6
Release     : mongodb_1
Size        : 13 M
Repo        : installed
From repo   : 10gen
Summary     : mongo server, sharding server, and support scripts
URL         : http://www.mongodb.org
License     : AGPL 3.0
Description : Mongo (from "huMONGOus") is a schema-free document-oriented
            : database.
            : 
            : This package provides the mongo server software, mongo sharding
            : server softwware, default configuration files, and init.d scripts.
查看客户端安装情况 
[root[@localhost](/user/localhost) geffzhang]#  

* base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
Installed Packages
Name        : mongo-10gen
Arch        : x86_64
Version     : 2.0.6
Release     : mongodb_1
Size        : 69 M
Repo        : installed
From repo   : 10gen
Summary     : mongo client shell and tools
URL         : http://www.mongodb.org
License     : AGPL 3.0
Description : Mongo (from "huMONGOus") is a schema-free document-oriented
            : database. It features dynamic profileable queries, full indexing,
            : replication and fail-over support, efficient storage of large
            : binary data objects, and auto-sharding.
            : 
            : This package provides the mongo shell, import/export tools, and
            : other client utilities.

3、安装MongoDB的服务器端和客户端工具  
[root[@localhost](/user/localhost) geffzhang]#  yum install mongo-10gen-server

[root[@localhost](/user/localhost) geffzhang]#  yum install mongo-10gen

4、启动Mongodb

service mongod start

以后有更新了,停掉mongodb,执行yum update mongo-10gen mongo-10gen-server 即可。

5、服务器配置: /etc/mongod.conf

# mongo.conf   
  
#where to log   
logpath=/var/log/mongo/mongod.log   
  
logappend=true #以追加方式写入日志   
  
# fork and run in background   
fork = true  
  
#port = 27017 #端口   
  
dbpath=/var/lib/mongo #数据库文件保存位置   
directoryperdb=true
# Enables periodic logging of CPU utilization and I/O wait   
#启用定期记录CPU利用率和 I/O 等待   
#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 启用数据库配额管理,默认每个db可以有8个文件,可以用quotaFiles参数设置   
#quota = true  
# 设置oplog记录等级   
# Set oplogging level where n is   
#   0=off (default)   
#   1=W   
#   2=R   
#   3=both   
#   7=W+some reads   
#oplog = 0  
  
# Diagnostic/debugging option 动态调试项   
#nocursors = true  
  
# Ignore query hints 忽略查询提示   
#nohints = true  
# 禁用http界面,默认为localhost:28017  
# 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  
# 为新数据库指定.ns文件的大小,单位:MB   
# Specify .ns file size for new databases.   
# nssize = <size>   
  
# Accout token for Mongo monitoring server.   
#mms-token = <token>   
# mongo监控服务器的名称   
# Server name for Mongo monitoring server.   
#mms-name = <server-name>   
# mongo监控服务器的ping 间隔   
# 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  

###请各位大神给予优化意见。如果能够提供node 结合nginx 的教程链接就更好了。万分感谢。

回到顶部