LNMP环境搭建
更新依赖包
yum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-serverspatch
安装mysql
/usr/sbin/groupaddmysql
/usr/sbin/useradd-gmysqlmysql
tarzxvfmysql-5.5.7-rc.tar.gz
cdmysql-5.5.7-rc
./configure--prefix=/usr/local/webserver/mysql/--enable-assembler--with-extra-charsets=complex--enable-thread-safe-client--with-big-tables--with-readline--with-ssl--with-embedded-server--enable-local-infile--with-plugins=partition,innobase,myisammrg
make&&makeinstall
chmod+w/usr/local/webserver/mysql
chown-Rmysql:mysql/usr/local/webserver/mysql
cd../
创建目录
mkdir-p/data0/mysql/3306/data/
mkdir-p/data0/mysql/3306/binlog/
mkdir-p/data0/mysql/3306/relaylog/
chown-Rmysql:mysql/data0/mysql/
以mysql用户帐号的身份建立数据表:
/usr/local/webserver/mysql/bin/mysql_install_db--basedir=/usr/local/webserver/mysql--datadir=/data0/mysql/3306/data--user=mysql
vi/data0/mysql/3306/my.cnf
输入
[client]
character-set-server=utf8
port=3306
socket=/tmp/mysql.sock
[mysqld]
character-set-server=utf8
replicate-ignore-db=mysql
replicate-ignore-db=test
replicate-ignore-db=information_schema
user=mysql
port=3306
socket=/tmp/mysql.sock
basedir=/usr/local/webserver/mysql
datadir=/data0/mysql/3306/data
log-error=/data0/mysql/3306/mysql_error.log
pid-file=/data0/mysql/3306/mysql.pid
open_files_limit=10240
back_log=600
max_connections=5000
max_connect_errors=6000
table_cache=614
external-locking=FALSE
max_allowed_packet=4M
sort_buffer_size=1M
join_buffer_size=1M
thread_cache_size=300
#thread_concurrency=8
query_cache_size=4M
query_cache_limit=1M
query_cache_min_res_unit=2k
default-storage-engine=MyISAM
thread_stack=192K
transaction_isolation=READ-COMMITTED
tmp_table_size=4M
max_heap_table_size=16M
long_query_time=3
log-slave-updates
log-bin=/data0/mysql/3306/binlog/binlog
binlog_cache_size=1M
binlog_format=MIXED
max_binlog_cache_size=2M
max_binlog_size=1G
relay-log-index=/data0/mysql/3306/relaylog/relaylog
relay-log-info-file=/data0/mysql/3306/relaylog/relaylog
relay-log=/data0/mysql/3306/relaylog/relaylog
expire_logs_days=30
key_buffer_size=8M
read_buffer_size=1M
read_rnd_buffer_size=2M
bulk_insert_buffer_size=4M
myisam_sort_buffer_size=16M
myisam_max_sort_file_size=1G
myisam_repair_threads=1
myisam_recover
interactive_timeout=120
wait_timeout=120
skip-name-resolve
#master-connect-retry=10
slave-skip-errors=1032,1062,126,1114,1146,1048,1396
#master-host=192.168.1.2
#master-user=username
#master-password=password
#master-port=3306
server-id=1
innodb_additional_mem_pool_size=8M
innodb_buffer_pool_size=64M
innodb_data_file_path=ibdata1:256M:autoextend
innodb_file_io_threads=4
innodb_thread_concurrency=8
innodb_flush_log_at_trx_commit=2
innodb_log_buffer_size=4M
innodb_log_file_size=32M
innodb_log_files_in_group=3
innodb_max_dirty_pages_pct=90
innodb_lock_wait_timeout=120
innodb_file_per_table=0
#log-slow-queries=/data0/mysql/3306/slow.log
#long_query_time=10
[mysqldump]
quick
max_allowed_packet=8M
===========================================================================
创建shell管理脚本
vi/data0/mysql/3306/mysql
输入
#!/bin/sh
mysql_port=3306
mysql_username="root"
mysql_password="123456"
function_start_mysql()
{
printf"StartingMySQL...\n"
/bin/sh/usr/local/webserver/mysql/bin/mysqld_safe--defaults-file=/data0/mysql/${mysql_port}/my.cnf2>&1>/dev/null&
}
function_stop_mysql()
{
printf"StopingMySQL...\n"
/usr/local/webserver/mysql/bin/mysqladmin-u${mysql_username}-p${mysql_password}-S/tmp/mysql.sockshutdown
}
function_restart_mysql()
{
printf"RestartingMySQL...\n"
function_stop_mysql
sleep5
function_start_mysql
}
function_kill_mysql()
{
kill-9$(ps-ef|grep'bin/mysqld_safe'|grep${mysql_port}|awk'{printf$2}')
kill-9$(ps-ef|grep'libexec/mysqld'|grep${mysql_port}|awk'{printf$2}')
}
if["$1"="start"];then
function_start_mysql
elif["$1"="stop"];then
function_stop_mysql
elif["$1"="restart"];then
function_restart_mysql
elif["$1"="kill"];then
function_kill_mysql
else
printf"Usage:/data0/mysql/${mysql_port}/mysql{start|stop|restart|kill}\n"
fi
============================================================================================================
chmod+x/data0/mysql/3306/mysql
启动mysql
/data0/mysql/3306/mysqlstart
登陆mysql
/usr/local/webserver/mysql/bin/mysql-uroot-p-S/tmp/mysql.sock
创建用户并赋予权限
GRANTALLPRIVILEGESON*.*TO'root'@'localhost'IDENTIFIEDBY'jianghaoisgood';
GRANTALLPRIVILEGESON*.*TO'root'@'127.0.0.1'IDENTIFIEDBY'123456';
GRANTALLPRIVILEGESON*.*TO'root'@'%'IDENTIFIEDBY'12345678';
======================================================================================
安装php
首先安装依赖库
tarzxvflibiconv-1.13.1.tar.gz
cdlibiconv-1.13.1/
./configure--prefix=/usr/local
make
makeinstall
cd../
tarzxvflibmcrypt-2.5.8.tar.gz
cdlibmcrypt-2.5.8/
./configure
make
makeinstall
/sbin/ldconfig
cdlibltdl/
./configure--enable-ltdl-install
make
makeinstall
cd../../
tarzxvfmhash-0.9.9.9.tar.gz
cdmhash-0.9.9.9/
./configure
make
makeinstall
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
tarzxvfmcrypt-2.6.8.tar.gz
cdmcrypt-2.6.8/
/sbin/ldconfig
./configure
make
makeinstall
cd../
tarzxvfphp-5.2.14.tar.gz
gzip-cdphp-5.2.14-fpm-0.5.14.diff.gz|patch-dphp-5.2.14-p1
cdphp-5.2.14/
./configure--prefix=/usr/local/webserver/php--with-config-file-path=/usr/local/webserver/php/etc--with-mysql=/usr/local/webserver/mysql--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config--with-iconv-dir=/usr/local--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-discard-path--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--enable-fastcgi--enable-fpm--enable-force-cgi-redirect--enable-mbstring--with-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-ldap--with-ldap-sasl--with-xmlrpc--enable-zip--enable-soap
makeZEND_EXTRA_LIBS='-liconv'
makeinstall
cpphp.ini-dist/usr/local/webserver/php/etc/php.ini
cd../
编译扩展模块
tarzxvfmemcache-2.2.5.tgz
cdmemcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config
make
makeinstall
cd../
tarjxvfeaccelerator-0.9.6.1.tar.bz2
cdeaccelerator-0.9.6.1/
/usr/local/webserver/php/bin/phpize
./configure--enable-eaccelerator=shared--with-php-config=/usr/local/webserver/php/bin/php-config
make
makeinstall
cd../
tarzxvfPDO_MYSQL-1.0.2.tgz
cdPDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config--with-pdo-mysql=/usr/local/webserver/mysql
make
makeinstall
cd../
tarzxvfImageMagick.tar.gz
cdImageMagick-6.5.1-2/
./configure
make
makeinstall
cd../
tarzxvfimagick-2.3.0.tgz
cdimagick-2.3.0/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config
make
makeinstall
cd../
修改php.ini文件
手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir="./"
修改为extension_dir="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
并在此行后增加以下几行,然后保存:
extension="memcache.so"
extension="pdo_mysql.so"
extension="imagick.so"
再查找output_buffering=Off
修改为output_buffering=On
再查找;cgi.fix_pathinfo=0去掉;
并且修改为cgi.fix_pathinfo=1打开pathinfo支持
自动修改:若嫌手工修改麻烦,可执行以下shell命令,自动完成对php.ini文件的修改:
sed-i's#extension_dir="./"#extension_dir="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension="memcache.so"\nextension="pdo_mysql.so"\nextension="imagick.so"\n#'/usr/local/webserver/php/etc/php.ini
sed-i's#output_buffering=Off#output_buffering=On#'/usr/local/webserver/php/etc/php.ini
sed-i"s#;always_populate_raw_post_data=On#always_populate_raw_post_data=On#g"/usr/local/webserver/php/etc/php.ini
sed-i"s#;cgi.fix_pathinfo=0#cgi.fix_pathinfo=1#g"/usr/local/webserver/php/etc/php.ini
配置eAccelerator加速PHP:
mkdir-p/usr/local/webserver/eaccelerator_cache
vi/usr/local/webserver/php/etc/php.ini
文件的最末尾,加上以下配置信息:
=================================================================================================================
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
===================================================================================================================
创建www用户和组
/usr/sbin/groupaddwww
/usr/sbin/useradd-gwwwwww
mkdir-p/data0/htdocs/mysql
chmod+w/data0/htdocs/mysql
chown-Rwww:www/data0/htdocs/mysql
mkdir-p/data0/htdocs/yca
chmod+w/data0/htdocs/yca
chown-Rwww:www/data0/htdocs/yca
配置fpm
rm-f/usr/local/webserver/php/etc/php-fpm.conf
vi/usr/local/webserver/php/etc/php-fpm.conf
输入
<?xmlversion="1.0"?>
<configuration>
Allrelativepathsinthisconfigarerelativetophp'sinstallprefix
<sectionname="global_options">
Pidfile
<valuename="pid_file">/usr/local/webserver/php/logs/php-fpm.pid</value>
Errorlogfile
<valuename="error_log">/usr/local/webserver/php/logs/php-fpm.log</value>
Loglevel
<valuename="log_level">notice</value>
WhenthisamountofphpprocessesexitedwithSIGSEGVorSIGBUS...
<valuename="emergency_restart_threshold">2</value>
...inalessthanthisintervaloftime,agracefulrestartwillbeinitiated.
Usefultoworkaroundaccidentalcurruptionsinaccelerator'ssharedmemory.
<valuename="emergency_restart_interval">1m</value>
Timelimitonwaitingchild'sreactiononsignalsfrommaster
<valuename="process_control_timeout">5s</value>
Setto'no'todebugfpm
<valuename="daemonize">yes</value>
</section>
<workers>
<sectionname="pool">
Nameofpool.Usedinlogsandstats.
<valuename="name">default</value>
Addresstoacceptfastcgirequestson.
Validsyntaxis'ip.ad.re.ss:port'orjust'port'or'/path/to/unix/socket'
<valuename="listen_address">127.0.0.1:9000</value>
<valuename="listen_options">
Setlisten(2)backlog
<valuename="backlog">-1</value>
Setpermissionsforunixsocket,ifoneused.
InLinuxread/writepermissionsmustbesetinordertoallowconnectionsfromwebserver.
ManyBSD-derrivedsystemsallowconnectionsregardlessofpermissions.
<valuename="owner"></value>
<valuename="group"></value>
<valuename="mode">0666</value>
</value>
Additionalphp.inidefines,specifictothispoolofworkers.
<valuename="php_defines">
<valuename="sendmail_path">/usr/sbin/sendmail-t-i</value>
<valuename="display_errors">1</value>
</value>
Unixuserofprocesses
<valuename="user">www</value>
Unixgroupofprocesses
<valuename="group">www</value>
Processmanagersettings
<valuename="pm">
Setsstyleofcontrolingworkerprocesscount.
Validvaluesare'static'and'apache-like'
<valuename="style">static</value>
Setsthelimitonthenumberofsimultaneousrequeststhatwillbeserved.
EquivalenttoApacheMaxClientsdirective.
EquivalenttoPHP_FCGI_CHILDRENenvironmentinoriginalphp.fcgi
Usedwithanypm_style.
<valuename="max_children">2</value>
Settingsgroupfor'apache-like'pmstyle
<valuename="apache_like">
Setsthenumberofserverprocessescreatedonstartup.
Usedonlywhen'apache-like'pm_styleisselected
<valuename="StartServers">20</value>
Setsthedesiredminimumnumberofidleserverprocesses.
Usedonlywhen'apache-like'pm_styleisselected
<valuename="MinSpareServers">5</value>
Setsthedesiredmaximumnumberofidleserverprocesses.
Usedonlywhen'apache-like'pm_styleisselected
<valuename="MaxSpareServers">35</value>
</value>
</value>
Thetimeout(inseconds)forservingasinglerequestafterwhichtheworkerprocesswillbeterminated
Shouldbeusedwhen'max_execution_time'inioptiondoesnotstopscriptexecutionforsomereason
'0s'means'off'
<valuename="request_terminate_timeout">0s</value>
Thetimeout(inseconds)forservingofsinglerequestafterwhichaphpbacktracewillbedumpedtoslow.logfile
'0s'means'off'
<valuename="request_slowlog_timeout">0s</value>
Thelogfileforslowrequests
<valuename="slowlog">logs/slow.log</value>
Setopenfiledescrlimit
<valuename="rlimit_files">65535</value>
Setmaxcoresizerlimit
<valuename="rlimit_core">0</value>
Chroottothisdirectoryatthestart,absolutepath
<valuename="chroot"></value>
Chdirtothisdirectoryatthestart,absolutepath
<valuename="chdir"></value>
Redirectworkers'stdoutandstderrintomainerrorlog.
Ifnotset,theywillberedirectedto/dev/null,accordingtoFastCGIspecs
<valuename="catch_workers_output">yes</value>
Howmuchrequestseachprocessshouldexecutebeforerespawn.
Usefultoworkaroundmemoryleaksin3rdpartylibraries.
Forendlessrequestprocessingpleasespecify0
EquivalenttoPHP_FCGI_MAX_REQUESTS
<valuename="max_requests">1024</value>
Commaseparatedlistofipv4addressesofFastCGIclientsthatallowedtoconnect.
EquivalenttoFCGI_WEB_SERVER_ADDRSenvironmentinoriginalphp.fcgi(5.2.2+)
MakessenseonlywithAF_INETlisteningsocket.
<valuename="allowed_clients">127.0.0.1</value>
PassenvironmentvariableslikeLD_LIBRARY_PATH
All$VARIABLEsaretakenfromcurrentenvironment
<valuename="environment">
<valuename="HOSTNAME">$HOSTNAME</value>
<valuename="PATH">/usr/local/bin:/usr/bin:/bin</value>
<valuename="TMP">/tmp</value>
<valuename="TMPDIR">/tmp</value>
<valuename="TEMP">/tmp</value>
<valuename="OSTYPE">$OSTYPE</value>
<valuename="MACHTYPE">$MACHTYPE</value>
<valuename="MALLOC_CHECK_">2</value>
</value>
</section>
</workers>
</configuration>
=======================================================
启动
ulimit-SHn65535
/usr/local/webserver/php/sbin/php-fpmstart
安装Nginx0.8.53
1、安装Nginx所需的pcre库:
tarzxvfpcre-8.10.tar.gz
cdpcre-8.10/
./configure
make&&makeinstall
cd../
2、安装Nginx
tarzxvfnginx-0.8.53.tar.gz
cdnginx-0.8.53/
./configure--user=www--group=www--prefix=/usr/local/webserver/nginx--with-http_stub_status_module--with-http_ssl_module
make&&makeinstall
cd../
3、创建Nginx日志目录
mkdir-p/data1/logs
chmod+w/data1/logs
chown-Rwww:www/data1/logs
4、创建Nginx配置文件
①、在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm-f/usr/local/webserver/nginx/conf/nginx.conf
vi/usr/local/webserver/nginx/conf/nginx.conf
输入
userwwwwww;
worker_processes2;
error_log/data1/logs/nginx_error.logcrit;
pid/usr/local/webserver/nginx/nginx.pid;
#Specifiesthevalueformaximumfiledescriptorsthatcanbeopenedbythisprocess.
worker_rlimit_nofile65535;
events
{
useepoll;
worker_connections65535;
}
http
{
includemime.types;
default_typeapplication/octet-stream;
#charsetgb2312;
server_names_hash_bucket_size128;
client_header_buffer_size32k;
large_client_header_buffers432k;
client_max_body_size8m;
sendfileon;
tcp_nopushon;
keepalive_timeout60;
tcp_nodelayon;
fastcgi_connect_timeout300;
fastcgi_send_timeout300;
fastcgi_read_timeout300;
fastcgi_buffer_size64k;
fastcgi_buffers464k;
fastcgi_busy_buffers_size128k;
fastcgi_temp_file_write_size128k;
gzipon;
gzip_min_length1k;
gzip_buffers416k;
gzip_http_version1.0;
gzip_comp_level2;
gzip_typestext/plainapplication/x-javascripttext/cssapplication/xml;
gzip_varyon;
#limit_zonecrawler$binary_remote_addr10m;
server
{
listen80;
server_namewww.54enga.com.cn;
indexindex.htmlindex.htmindex.php;
root/data0/htdocs/yca;
#limit_conncrawler20;
location~*.*\.php($|/){
includefcgi.conf;
}
location~.*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires30d;
}
location~.*\.(js|css)?$
{
expires1h;
}
log_formataccess'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent"$http_x_forwarded_for';
access_log/data1/logs/access.logaccess;
}
server
{
listen80;
server_namemysql.54enga.com;
indexindex.htmlindex.htmindex.php;
root/data0/htdocs/mysql;
location~*.*\.php($|/){
includefcgi.conf;
}
log_formatwwwlogs'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent"$http_x_forwarded_for';
access_log/data1/logs/wwwlogs.logwwwlogs;
}
}
=====================编辑cgi配置文件==============
vi/usr/local/webserver/nginx/conf/fcgi.conf
输入:
if($request_filename~*(.*)\.php){
set$php_url$1;
}
if(!-e$php_url.php){
return403;
}
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
set$path_info"";
set$real_script_name$fastcgi_script_name;
if($fastcgi_script_name~"^(.+?\.php)(/.+)$"){
set$real_script_name$1;
set$path_info$2;
}
fastcgi_paramSCRIPT_FILENAME$document_root$real_script_name;
fastcgi_paramSCRIPT_NAME$real_script_name;
fastcgi_paramPATH_INFO$path_info;
##以上是支持pathinfo的重点部分
fastcgi_paramGATEWAY_INTERFACECGI/1.1;
fastcgi_paramSERVER_SOFTWAREnginx;
fastcgi_paramQUERY_STRING$query_string;
fastcgi_paramREQUEST_METHOD$request_method;
fastcgi_paramCONTENT_TYPE$content_type;
fastcgi_paramCONTENT_LENGTH$content_length;
#fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
#fastcgi_paramSCRIPT_NAME$fastcgi_script_name;
fastcgi_paramREQUEST_URI$request_uri;
fastcgi_paramDOCUMENT_URI$document_uri;
fastcgi_paramDOCUMENT_ROOT$document_root;
fastcgi_paramSERVER_PROTOCOL$server_protocol;
fastcgi_paramREMOTE_ADDR$remote_addr;
fastcgi_paramREMOTE_PORT$remote_port;
fastcgi_paramSERVER_ADDR$server_addr;
fastcgi_paramSERVER_PORT$server_port;
fastcgi_paramSERVER_NAME$server_name;
启动nginx
ulimit-SHn65535
/usr/local/webserver/nginx/sbin/nginx
配置开机自启动
vi/etc/rc.local
输入
ulimit-SHn65535
/usr/local/webserver/php/sbin/php-fpmstart
/usr/local/webserver/nginx/sbin/nginx
/data0/mysql/3306/mysqlstart
/**********
*
*
**********/
svn配置
1.安装svn服务器端
yum-yinstallsubversion从镜像下载安装svn服务器端
cd/usr/local///进入目录,准备创建svn目录
mkdirsvn//创建一个svn目录
chmod-R777svn//修改目录权限为777
svnadmincreate/usr/local/svn/sunny//创建一个svn版本仓库sunny(sunny可以随便起名字)match
cdsvn/sunny/conf//进入sunny版本仓库下的配置文件目录
下面要修改这个目录下的三个配置文件
(1)visvnserve.conf//配置版本库信息和用户文件和用户密码文件的路径、版本库路径
[
把
#anon-access=read
#auth-access=write
#password-db=passwd
//这四行,前面的#号和空格去掉(注意去掉#要顶格写,不要留有多余空格),变成
anon-access=none//改成none
auth-access=write
password-db=passwd
realm=sunny//改成自己的版本库match
保存
(2)viauthz//文件,创建svn组和组用户的权限
[group]
sunny=gep,wce//创建一个sunny的组,并指定两个用户gep和wce
[/]//制定根目录下的权限
@sunny=rw//sunny组用户权限为读写
*=r//其他用户只有读权限
保存退出
(3)vipasswd//创建或修改用户密码
[users]
gep=123456//用户名为gep的用户的密码为123456
wce=123456//。。。
保存退出
启动svn:
svnserve-d-r/usr/local/svn///这里采用多版本库的方式启动如果是单版本库可以svnserve-d-r/usr/local/svn/sunny
添加一行
然后要设置自启动
vi/etc/rc.local打开自启动文件添加
/usr/bin/svnserve-d-r/usr/local/svn/
svn命令:
netstat-tnl|grep:3690查看svn是否启动
psaux|grep'svn'查找所有svn启动的进程
kill-92505杀死2505这个查找到的svn进程
svncheckoutsvn://172.19.5.2/sunny/data0/htdocs/blog//检出一份版本库文件到指定目录
svnup//更新文件
自动更新
在vi/usr/local/svn/sunny/hooks/post-commit中加入
#!/bin/sh
#设置一些变量
SVN=/usr/bin/svn
WEB=/home/testsvn#要更新的目录
exportLANG=en_US.UTF-8
$SVNupdate$WEB--usernamexxx--passwordxxx
其中SVN=右边改成svn命令位置一般默认为/usr/bin/svn
WEB=右边改成你实际的web目录
赋予可执行权限
chmod777/usr/local/svn/sunny/hooks/post-commit
=========================================================================
其他
#svncommit-m"注释"xxx.php//提交文件
svnci-m'aaa'test.php//提交文件
#svnaddfile//新建文件并添加到svn
svnadd*.php//(添加当前目录下所有的php文件)
svndeletetest.php//删除test.php
svnlogtest.php//查看test文件的log信息
svncleanup//清理当前目录
svnswitch--relocatesvn://192.168.1.253svn://172.19.10.250//重新定位SVN版本库地址
//SVN版本库起动方式,现在SVN下面有sunny、test两个版本库
1:单版本库起动svnserve-d-r/usr/local/svn/sunny
2:多版本库起动svnserve-d-r/usr/local/svn
区别在于起动svn时候的命令中的启动参数-r指定的目录。
限制不同的用户对不同的版本库操作权限,修改版本库中的conf目录下的authz文件
以配置sunny版本库为例
viauthz
[groups]
teacher=sunny,sunny1
[sunny:/]//指定版本库跟目录下的权限
@teacher=rw//teacher组用户权限为读写
*=r//其他用户只有读权限
保存退出
vipasswd设置组中用户的账号和密码
[users]
sunny=123456
sunny1=123456