标签存档: 配置

samba安装与配置

由于公司的代码统一独立服务器管理,为了方便开发,在开发机上配置samba映射一个目录,来进行SVN的提交和更新。

samba安装

$ wget http://www.samba.org/samba/ftp/stable/samba-3.6.0.tar.gz
$ ls
$ rm samba-3.6.0.tar.gz
$ rz
$ tar -zxvf samba-3.6.0.tar.gz
$ cd samba-3.6.0/
$ ls
$ find . -name configure
$ ./source3/configure
$ cd source3/
$ mkdir /usr/local/samba
$ ./configure --prefix=/usr/local/samba/
$ make
$ make install
$ make clean
$ cd /usr/local/samba
$ ls
$ mkdir etc
$ cp /home/super/samba-3.6.0/examples/smb.conf.default  ./etc/smb.conf

//启动samba服务

$ /usr/local/samba/sbin/smbd -D
$ /usr/local/samba/sbin/nmbd -D
$ /usr/local/samba/sbin/winbindd -D

//查看samba网络情况

$ netstat -tlnp | grep smb

samba配置

# 添加系统用户
$ useradd superzc
$ passwd superzc
# 创建samba用户
$ /usr/local/samba/bin/smbpasswd -a superzc #必须是系统已存在的用户

$ vim /usr/local/samba/lib/smb.conf
#增加
[superzc]
comment = superzc
path = /var/www/html/superzc
directory mask = 0700
valid users = superzc
read only = No
create mask = 0755

连接
Windows -> 映射网络驱动器 -> \\10.1.163.42\superzc -> 输入用户名和密码 -> 成功访问

NOSQL mongodb 安装及简介

简介
NOSQL:指的是非关系型的数据库。随着互联网web2.0网站的兴起,传统的关系数据库在应付web2.0网站,特别是超大规模和高并发的SNS类型的web2.0纯动态网站已经显得力不从心,暴露了很多难以克服的问题,而非关系型的数据库则由于其本身的特点得到了非常迅速的发展。
MongoDB:是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。

安装
服务端:

$ cd /home/super
$ wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.5.tgz
$ tar -zxvf mongodb-linux-i686-1.6.5.tgz
$ mv mongodb-linux-i686-1.6.5 /usr/local/mongodb
$ cd /usr/local/mongodb
$ mkdir /data
$ mkdir /data/mongodb
$ ./mongod --fork --dbpath /data/mongodb --logpath /data/mongod.log --maxConns 1000 --directoryperdb --auth --quiet --logappend &
$ netstat -ln #查看******

显示如下图所示:

测试:

$ ./mongo
>help
db.help()                    help on db methods
db.mycoll.help()             help on collection methods
rs.help()                    help on replica set methods
help connect                 connecting to a db help
help admin                   administrative help
help misc                    misc things to know

show dbs                     show database names
show collections             show collections in current database
show users                   show users in current database
show profile                 show most recent system.profile entries with time >= 1ms
use                 set current database
db.foo.find()                list objects in collection foo
db.foo.find( { a : 1 } )     list objects in foo where a == 1
it                           result of the last line evaluated; use to further iterate
> use test #选择数据库,test可以是从未建立过的数据库
switched to db test
> a={name:'test'}
{"name":"test"}
> b={url:'http://www.test.com'}
{ "url" : "http://www.test.com" }
> db.data.save(a) #将数据保存到data表中,data表可以是从未建立过的数据表
> db.data.save(b)
> db.data.find()  #数据查询
{ "_id" : ObjectId("4d7f7c1076568212fe4efbad"), "name" : "test" }
{ "_id" : ObjectId("4d7f7c1876568212fe4efbae"), "url" : "http://www.test.com" }
> show collections #显示test库下所有的表
data
system.indexes
> db.data.find().limit(1) #只显示一条记录
{ "_id" : ObjectId("4d7f7c1076568212fe4efbad"), "name" : "test" }
#增加认证,添加管理员
> use admin
> db.addUser("admin","123456");
#以后登录mongodb必须认证
> use admin
> db.auth("admin","123456")
> db.shutdownServer()

安装rockmongo://MongoDB可视化管理工具

$ mkdir /var/www/html/rockmongo
$ cd /var/www/html/rockmongo
$ wget http://rock-php.googlecode.com/files/rockmongo-v1.0.12.1.zip
$ unzip rockmongo-v1.0.12.1.zip
#修改管理员名和密码
$ vim config.php

mongo-php-driver: //参照:http://www.php.net/manual/en/mongo.installation.php#mongo.installation.nix

$ cd /home/super
$ wget --no-check-certificate https://github.com/mongodb/mongo-php-driver/tarball/master
$ tar -zxvf mongodb-mongo-php-driver-1.1.4-4-g0c16c89.tar.gz
$ cd mongodb-mongo-php-driver-0c16c89/
$ phpize
$ ./configure
$ make && make install

memcached配置

1.memcache-client //memcached客户端

$ cd /home/super
$ 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/bin/phpize #使用phpize建立php扩展
$ ./configure --prefix=/usr/local/memcached --with-php-config=/usr/local/bin/php-config
$ make && make install
#记录下一个很长的路径:/usr/local/lib/php/extensions/no-debug-zts-20090626/

$ vim /usr/local/php/lib/php.ini #配置php.ini
>extension_dir = "/usr/local/lib/php/extensions/no-debug-zts-20090626/"
>extension=memcached.so
$ /usr/local/apache2/bin/apachectl restart

2.memcached //memcache服务端

#安装 libevent
$ cd /home/super
$ wget http://monkey.org/~provos/libevent-1.3b.tar.gz
$ tart -zxvf libevent-1.3b.tar.gz
$ cd libevent-1.3b
$ ./configure
$ make && make install
#安装 memcached
$ cd /home/super
$ wget http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
$ tar -zxvf memcached-1.2.1.tar.gz
$ cd memcached-1.2.1
$ ./configure
$ make && make install
#测试libevent是否安装成功:
$ ls -al /usr/lib | grep libevent
#启动(安装后位置:/usr/local/bin/memcached)
#$ memcached -d -m 128 -l 0.0.0.0 -p 11211 -u root //0.0.0.0对任何客户端都开放memcache
#memcached的基本设置
#启动Memcache的服务器端:
$ /usr/local/bin/memcached -d -m 10 -u root -l 0.0.0.0 -p 12000 -c 256 -P /tmp/memcached.pid
#-d选项是启动一个守护进程,
#-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
#-u是运行Memcache的用户,我这里是root,
#-l是******的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200,
#-p是设置Memcache******的端口,我这里设置了12000,最好是1024以上的端口,
#-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
#-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,
#如果要结束Memcache进程,执行:
#kill cat /tmp/memcached.pid
#也可以启动多个守护进程,不过端口不能重复。

成功截图:
写一个phpinfo();的php文件,成功啦~

$ cd /var/www/html
$ vim memcache.php
>$memcache = new Memcache();
>$memcache->connect('127.0.0.1', 12000);
>$memcache->set('key', 'This is a memcache key!', 0, 60);
>$res = $memcache->get('key');
>echo $res;

3.memcached统计监控

$ telnet 127.0.0.1 12000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
STAT pid 1467
STAT uptime 59525
STAT time 1368585692
STAT version 1.4.15
STAT libevent 2.0.21-stable
STAT pointer_size 64
STAT rusage_user 0.196012
STAT rusage_system 0.232014
STAT curr_connections 5
STAT total_connections 51
STAT connection_structures 6
STAT reserved_fds 20
STAT cmd_get 42
STAT cmd_set 20
STAT cmd_flush 6
STAT cmd_touch 0
STAT get_hits 29
STAT get_misses 13
STAT delete_misses 0
STAT delete_hits 5
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 3520
STAT bytes_written 3893
STAT limit_maxbytes 268435456
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT bytes 470
STAT curr_items 2
STAT total_items 20
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evictions 0
STAT reclaimed 3
END

遇到问题:
如果遇到 memcached:error while loading shared libraries:libevent-1.3b.so.1:cannot open shared object file:No such file or directory.
使用 LD_DEBUG=libs /usr/local/bin/memcached -v 查看其启动的时候,加载lib情况;具体的不列出;
执行:ln -s /usr/local/lib/libevent-1.3b.so.1 /lib/libevent-1.3b.so.1问题可以解决;

lamp | linux+apache+mysql+php配置

linux+apache+mysql+php配置:
1.apache

$ cd /home
$ mkdir super
$ wget http://labs.renren.com/apache-mirror/httpd/httpd-2.2.17.tar.gz
$ tar -zxvf httpd-2.2.17.tar.gz
$ cd httpd-2.2.17
$ ./configure --prefix=/usr/local/apache2 --enable-vhost-alias --enable-deflate --enable-rewrite --with-mpm=worker --enable-ssl
# --prefix=/usr/local/apache 设置安装位置
# --enable-so 让apache核心装载DSO
# --enable-rewrite 启用重写功能
$ make && make install //编译并且安装
$ /usr/local/apache2/bin/apachectl start //启动apache服务
$ vim /usr/local/apache2/conf/httpd.conf
# prefork和worker模式的配置

ServerLimit         2048
StartServers         100
MinSpareServers      50
MaxSpareServers      150
MaxClients          1000  # 设定的是 Apache可以同时处理的请求
MaxRequestsPerChild 10000

ServerLimit 30
ThreadLimit 64
StartServers 20
MaxClients 1024
MinSpareThreads 75
MaxSpareThreads 250
ThreadsPerChild 64
MaxRequestsPerChild 10000

$ /usr/local/apache2/bin/apachectl restart //重启apache服务

注:在编译安装apache之前需要安装apr、apr-util、zlib

配置文件httpd.conf在php模块下面加一句:AddType application/x-httpd-php .php //执行php文件格式

遇到问题:

$ vim /etc/resolv.conf
> nameserver 8.8.8.8

2.mysql

$ cd /home/super
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.35.tar.gz
$ tar -zxvf mysql-mysql-5.5.35.tar.gz
$ cd mysql-5.5.35.tar.gz
$ groupadd mysql
$ useradd -g mysql mysql
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/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=/tmp/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
$ make && make install
$ chown mysql.mysql /usr/local/mysql/ -R
#把你编译目录的一个脚本COPY过去
$ cp support-files/mysql.server /etc/init.d/mysqld
#增加一项新的服务
$ chkconfig --add mysqld
#启动mysql
$ /etc/rc.d/init.d/mysqld start

成功启动!!!

3.php

$ cd /home/super
$ wget  http://cn.php.net/get/php-5.2.9.tar.gz/from/cn2.php.net/mirror
$ tar -zxvf php-5.2.9.tar.gz
$ cd php-5.2.9
$ ./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-zlib-dir --with-zlib --enable-ftp --enable-mbstring --enable-sockets --enable-soap --enable-fpm --with-curl --with-libxml-dir=/usr/local/libxml2 --with-openssl --with-mcrypt
#如果是64位系统:增加 --libdir=/usr/lib64
#配置php、生成可编译文件
$ make && make install
$ cd /home/super/php-5.2.9
$ cp php.ini-development /usr/local/php/lib/php.ini
$ cd /usr/local/php/lib
$ vim php.ini
> register_globals = On
$ vi /usr/local/apache/conf/httpd.conf
#查找
#在此范围添加
> AddType application/x-httpd-php .php
> AddType application/x-httpd-php-source .phps
$ /usr/local/apache2/bin/apachectl restart #重启apache服务
$ cd /usr/local/apache2/htdocs
$ vim phpinfo.php
> <?php
> phpinfo();
> ?>;
#访问phpinfo.php尝试正常哈哈!
$ cd /usr/local/apache2/lib
$ vim http.conf
#更改php执行目录,将#DocumentRoot "/usr/local/apache2/htdocs"改为
> DocumentRoot "/var/www/html/"
#增加扩展虚拟主机配置
> Include conf/extra/httpd-vhosts*.conf
$ cd extra
$ vim http-vhosts-pma.conf
#添加扩展pma配置文件
DocumentRoot   "/var/www/html/phpMyAdmin"
ServerName pma.zhouchao.com
ServerAlias pma.chaoji.com
ServerAdmin zhouchao@qeeka.com
DirectoryIndex index.php index.html index.htm index.shtml
#       LogLevel debug
HostNameLookups off

Options Includes FollowSymLinks
AllowOverride all
Allow from all
#                        AuthName "Auth Name :"
#                        AuthType Basic
#                        AuthUserFile /etc/phphtaccess.pwd
#                        require valid-user
Order allow,deny

CustomLog "logs/access_pma.log" combined

遇到问题:
php编译报错:/usr/local/ssl/lib/libcrypto.a: could not read symbols: Bad value
解决方案:
重新编译openssl:./config no-shared -fPIC

4.mcrypt //加密算法扩展库

$ wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
$ tar -zxvf libmcrypt-2.5.8.tar.gz
$ cd libmcrypt-2.5.8
$ ./configure
$ make && make install

遇到问题:
进去phpMyAdmin时,缺少:mcrypt
然后再重新编译PHP,加上编译参数:–with-mcrypt
测试下是否编译成功:
$ /usr/local/php/bin/php -m | grep mcrypt
mcrypt
别忘了重新启动apache!!!!

5.phpmyadmin

$ cd /home/super
$ wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.9.2/phpMyAdmin-3.3.9.2-all-languages.tar.gz?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php&ts=1298912166&use_mirror=ncu
$ tar -zxvf phpMyAdmin-3.3.9.2-all-languages.tar.gz
$ mkdir -p /var/www/html
$ mv phpMyAdmin-3.3.9.2-all-languages /var/www/html/phpMyAdmin
$ cd !$
$ cp -a config.sample.inc.php config.inc.php
#找到 /libraries/config.default.php文件(config.default.php复制到phpmyadmin目录下,然后更名为 config.inc.php)

遇到问题:
(1)配置好apache虚拟主机后若出现Wrong permissions on configuration file, should not be world writable! 则需要修改权限 chmod 755 config.* ;chmod 755 libraries/config.default.php
(2)若出现:配置文件现在需要绝密的短语密码(blowfish_secret) 要改配置文件里的:$cfg['blowfish_secret'] = ‘ ‘; 单引号里面随便写个数
(3)pma无法登陆,要在mysql中root用户授权(默认密码为空)#GRANT ALL PRIVILEGES ON *.* TO root@’localhost’ IDENTIFIED BY ’123456′;

第 1 页,共 1 页1