: http://blog.csdn.net/yanzi1225627/article/details/49123659
. s" G6 C G4 G7 s
% q5 p' D2 Q, \- v+ e: q4 n格嚗剖遣LNMP嚗Linux 嚗 Nginx 嚗 MySQL 嚗 PHP 嚗SVN嚗嚗嗡葉svn舐冽乩誨瞞tp嚗嫣噶撘銝剛霂甇乩誨 詨喟桀嚗頧臭辣賢鋆/www/桀銝嚗肓ww桀銝啣遣web隞嗅允雿銝箇蝡寡楝敺嚗www桀銝啣遣wwwsvn雿銝漳vn隞摨啣/www/software冽交駐ginx嚗mysql嚗php摰鋆皞nginx餈銵蝏韐行暈ww:www 銝嚗摰鋆憭yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel cmake5 v& S! q: w# J) ~0 B0 E
湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx
$ ^% ]8 _& P/ K' O 嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www. c+ J; c2 O4 O/ {! U" h, P+ T
/usr/sbin/useradd M -s /sbin/nologin -g www www //-M 銝撱箇雿輻刻桅 nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具 chmod 755 /etc/init.d/nginx
$ ]: u# f, L. f0 c, }# ~% `) C8 h1 y
K" p7 H. U2 @% vchkconfig --add nginx! m' |4 }; _! @2 D
) v: [1 ~4 V! q) L' o" s2 ]; R
chkconfig nginx on
; V( E% |) d5 W* y 嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash1 `* _* P& Z2 ~5 r8 W0 x0 I7 b5 z* X
# nginx Startup script for the Nginx HTTP Server
% x' f$ ^+ H# I2 E- E# it is v.0.0.2 version.
3 g" i9 m# ~* D0 [# chkconfig: - 85 15' t8 @3 I, t5 p/ B0 Y
# description: Nginx is a high-performance web and proxy server.( `* }# F, J# V3 ^
# It has a lot of features, but it's not for everyone.1 a( G/ L/ a' Q, }5 M5 R6 B3 w
# processname: nginx7 e; ] |/ _& u1 `
# pidfile: /var/run/nginx.pid
6 g, e9 ?- G3 Q, `" D. ~7 o7 L7 @# config: /usr/local/nginx/conf/nginx.conf( ?, x+ D' x) n' Q" P) S
nginxd=/www/nginx/sbin/nginx
8 [4 F: o. }3 \' unginx_config=/www/nginx/conf/nginx.conf; r2 Q5 h4 y$ `- C
nginx_pid=/www/nginx/logs/nginx.pid' v7 v4 z- k0 P, C0 |4 Q
RETVAL=0
6 v1 q, X9 Y% x: s$ W ]/ wprog="nginx"
4 [9 N1 w; @0 w6 D3 A9 E! l3 Q- ]# Source function library.
% k* G9 `, O& U2 Z. /etc/rc.d/init.d/functions
A: r3 h7 D; ^. t! }, u# Source networking configuration.
( ~5 g+ m% m! L. _, S" J' e. /etc/sysconfig/network
; c' u! k" V9 b! a5 K7 w9 i( p# Check that networking is up.
, f7 D% W: q) Q: M) U+ {0 `9 A' V[ ${NETWORKING} = "no" ] && exit 0
' K( f5 n( T2 D' N4 [' J3 \[ -x $nginxd ] || exit 03 i/ j" }) s. Q- U
# Start nginx daemons functions./ m' O [ r* d' N7 M5 W8 |
start() {
3 E I# I2 `. e O+ }if [ -e $nginx_pid ];then
0 L V! k9 G% n9 a* Q Fecho "nginx already running...."
) p- ~& d" b2 _5 k- L$ Gexit 1. I( P' d' e: d5 K0 t3 O9 O
fi* b7 U# X6 C9 U
echo -n $"Starting $prog: "; r# C' V8 [9 o
daemon $nginxd -c ${nginx_config}
8 l7 M! F/ j. k5 c! K8 F) G% S" qRETVAL=$?
$ } n: b: y5 H1 W$ @echo
2 R) I& i; n, N4 t3 f% z( k3 r1 Z[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx9 O. s- C5 z& |) E+ y2 V% l
return $RETVAL$ [$ }& Z T ~% c/ F
}& F' \6 U' l- E/ t
# Stop nginx daemons functions.4 \- d# d; j2 W$ {
stop() {
. F; N3 \- t1 T' O; G9 C) m pecho -n $"Stopping $prog: "
! t/ N% l! i+ d. q/ Jkillproc $nginxd) X! y' [4 f5 b4 f* d, q$ Z% U) c; _
RETVAL=$?
4 y* F1 [4 `9 ]& Kecho
- ~; ^7 [" g# v, _[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
5 L! n$ g x. i0 q# J}
. G4 u3 D% M) N- n freload() {
4 n1 e/ n0 G# I8 G& r0 Kecho -n $"Reloading $prog: "5 b" I. U: {) z# {" ~+ B
#kill -HUP `cat ${nginx_pid}`. J0 |" u7 |: w$ ~$ o
killproc $nginxd -HUP
- u0 U7 \, m6 GRETVAL=$?
) F. h1 ]+ W! B2 c8 n& Iecho; F( X6 [; f9 {) n+ k" ~- h
}5 D8 v, X' H# F+ D2 j2 i
# See how we were called.
7 ~( _; C- N) p2 A+ O: c9 Icase "$1" in
! z ]" D) ?! A9 e' O/ D( ]& sstart)
# \; w6 q9 u. V; [6 Kstart
9 |7 T* i1 r% ~, I# L. t;;
. @$ `' j* \1 pstop)0 Q: }1 V- D) k# Y! o0 h2 D
stop
- X5 ]4 U& ~1 j: X;;
4 @. I/ R$ K; i% v. I( @3 kreload)
) A( |8 l j8 `4 f& U8 ^8 lreload
4 P1 T) z# S5 i: g u;;, x; G! L( |3 I* D
restart) j, c3 A& E- s6 V
stop
* V) w6 P# v$ Ustart9 q# U8 s4 e( ?1 c/ N
;;7 d9 S7 |0 r) k7 V" ?
status)" t$ d5 u$ s: b
status $prog# Y- l- J* D5 D% c" h1 ^: Y
RETVAL=$?; N3 ^, Z. x- _8 L& g. b' ^7 q; f
;;
! ?! ^; @1 a: C6 ]0 N*)& i: w9 O% m. D2 J$ Y
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
% e- v! c) j3 |- l- f* Y' iexit 18 D$ }! I4 X4 P& U. U+ n0 ~7 u
esac
- x4 }0 y4 E V* yexit $RETVAL
- P% Y* i" E$ Q4 O; K5 V) o5 Y8 @7 N
瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬
n7 J6 G1 k7 @( N% |chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗/ }" |* ~" N' J
1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠 9 S3 p: M! N* p8 i( o1 y
location / {
3 u+ m& @, D' b: U- P root html;
1 b# x. A/ d; J# w7 w5 E( E$ U index index.php index.html index.htm;! m# _* E) X$ U8 ?
}
( A8 P! o) F9 y e- N6 R* ~4 i$ i靽格嫣蛹嚗
0 |* T. @3 r% q. B0 w @! H
8 v) Q( {. f2 ], l* C location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
) j- i+ T, V) O- q5 W# {location ~ \.php$ {
! \ U! O5 ^4 ] g root html;" j( u7 D6 K/ C( `9 Q5 X
fastcgi_pass 127.0.0.1:9000;
: V/ U% C! K& S$ b/ r) q' S) {! k fastcgi_index index.php;+ p9 M5 v% C& ?3 }4 L9 W
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ I6 o6 V: }3 H( f include fastcgi_params;
5 \" M$ A5 f ~ }0 ?/ w5 M, X4 d( R
靽格嫣蛹嚗( x2 D U w/ D- F
2 S) A( _; d( b1 ~3 Z1 v
location ~ \.php$ { root /www/web; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #include fastcgi_params; include fastcgi.conf; } 嗅撠得k鈭蝚砌銝芷桅頝php游嚗敺摰鋆摰瘥php氬 銝嚗摰鋆MySQL閫蝻拙僎餈唳桀嚗扯嚗
: t* Q! H# V' Y/ q: x#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql
' o% @$ @5 g9 C) C4 B3 j. A% R
5 T6 K* k' q* V& X9 n$ A. @#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
2 ]0 g, V+ D( o: m 扯 cat /etc/passwd 亦冽瑕銵
* |) x7 t T# }cat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀1 F! z% n" w1 {# c3 n! G [
3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
6 T3 r! d. ]8 l 4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql
! E" f0 O, M. a' F/ l+ Uchkconfig mysql on, N# Z, l. z8 z( ^/ r O
service mysql start --臬決ySQL
|9 Z7 j8 L$ @9 Q8 { 5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH/ r3 c+ ?- Q- o V/ k
export PATH
. G- O \" k1 I5 F 靽摮source /etc/profile 扯嚗 ! e4 I0 W' _2 T9 N
mysql -uroot mysql> SET PASSWORD = PASSWORD('root');
+ e* N9 o T# E2 l$ y- [: Q
9 T5 W/ m+ a: O1 c9 P/ l霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗 $ W" ~+ z1 A6 a6 D) e
mysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗 7 r( U3 H1 ?6 M+ B
#./configure --prefix=/www/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-openssl --with-libxml-dir --with-zlib --enable-mbstring --with-mysql=/www/mysql --with-mysqli=/www/mysql/bin/mysql_config --enable-mysqlnd --with-pdo-mysql=/www/mysql --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --with-curl 嗅make make install亦閬隞乩鈭嚗 1嚗游nginx嚗臬私hp 餈軏d /www/php/etc/ 桀銝嚗瑁php-fpm.conf.default 銝歉hp-fpm.conf扯/www/php/sbin/php-fpm start 臬私hp嚗fpm 2嚗蝵峰hp.ini 撠摰鋆皞/www/software/php-5.6.14/php.ini-production 瑁郡hp摰鋆桀lib隞嗅允銝 3嚗憒閬摰鋆curl拙霂嚗銝Yconfigure撌脩撣虫嚗嚗餈唳ext/curl桀銝嚗靽霂菔銝撌脩摰鋆鈭curlcurl-devel,嗅嚗 a嚗/www/php/bin/phpize 隞乩嚗銝箔嫣噶臭誑餈銝芰桀/etc/profile嚗
1 D6 D3 ?) v: u5 wPATH=/www/php/bin:/www/mysql/bin: $PATH export PATH b,./configure --with-curl --with-php-config=/www/php/bin/php-config銋make make install嚗curl.so隡 /www/php/lib/php/extensions/no-debug-non-zts-20131226桀銝嚗嗅蝻颲php.ini曉送xtension_dirextension靽格孵喳胯 雿輻 yum 瘥頛嫣噶: 隞乩舫撠 centOS 6.x/x86_64: yum install php php-mysql php-fpm php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel 隞乩舫撠 centOS 5.x/i386: rpm -ivh http://mirror.yandex.ru/epel/5/i386/epel-release-5-4.noarch.rpm
( [) y* x9 v) Q) O! M9 T
5 ]7 s4 D u" v; v$ W5 F: Lrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm" ~) P+ v: t6 n, E3 R$ j
Create /etc/yum.repos.d/php-fpm.repo file and add:
1 K9 B( z. \) S; \; x* ?- [nginx]
' h5 T( ?' z" L$ w) O, Z6 a - name=nginx repo5 I2 Q2 d7 T1 D
- baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
8 l& k2 ?8 f% L: [7 B4 |% b - gpgcheck=0
/ y& P7 b! J7 g' f2 {7 T |. B - enabled=1
銴鋆賭誨蝣 $ [, ^5 h' a/ ]& J
yum --enablerepo=remi,remi-test install php-fpm
* W& N( [& |4 M3 } C! ~6 o
8 Z' {' Y5 L3 ?7 c- W4 z2 ]5 P: ~$ h W0 L% y: c
鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn
9 d2 R3 w; n1 ^6 P 嚗yum remove subversion //貉蝸雿祉svn5 e- v |! d5 `3 c9 d% ]& n
# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn
% P0 P/ j5 L9 n4 C: F6 ]- D 餈# svnserve --version撉霂臬血鋆乩亙停臬撱箔摨撟嗡web桀甇乓 1嚗mkdir -p /www/wwwsvn 甇斗隞嗅允撠望盎vn隞摨. svnadmin create /www/wwwsvn 撱箔摨嚗扯銝餈啣賭誘嚗臭誑圈Xconf, db,format,hooks, locks, README.txt蝑隞塚霂湔銝銝杵VN摨撌脩撱箇嚗ps嚗甇文臭誑餈svnserve -d -r /www/svndata 撱箇svn砍桀嚗嗅svnadmin究vndata桀銝啣遣隞摨嚗 2嚗蝵桃冽瑕撖 肓wwsvn銝餈軏onf隞嗅允嚗X銝銝芣隞塚authz passwd svnserve.conf閬蝻颲 嚗vim passwd //霈曄蔭冽瑕撖 [users]. N1 ^6 Y& ]( S( `% x5 ]
# harry = harryssecret3 e6 K9 y& y& a6 Z+ w. r+ u$ |
# sally = sallyssecret, @6 K, }; S8 x
wangning=wangning9 Q" @+ n& V' a# e
yanzi=yanzi7 o9 w- v( J0 w. p& ]* H+ H4 s
#vim authz //霈曄蔭
; B9 t) s' v, l! O[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none8 |) S/ F. v. }" c7 I: ^
auth-access = write( ]# s7 a0 S' l6 `5 g2 V
### The password-db option controls the location of the password- N# |/ [! [3 L9 T
### database file. Unless you specify a path starting with a /,$ H0 W6 Q5 g: `% ^" h" o n; j: U
### the file's location is relative to the directory containing
& _* d+ ^- B, W### this configuration file.
+ L& C8 ?3 C t4 i& R' `### If SASL is enabled (see below), this file will NOT be used.+ O9 X1 N9 l* e, P. H+ V# j
### Uncomment the line below to use the default password file.1 q O# I2 j+ ]: ]
password-db = passwd! k6 S& q* _7 U* ~0 l) V) w# c9 D- [
### The authz-db option controls the location of the authorization* m( b% a) [, a
### rules for path-based access control. Unless you specify a path8 v1 U% d: e7 ?% P3 N
### starting with a /, the file's location is relative to the the
^% w5 S* E2 n5 R### directory containing this file. If you don't specify an+ P( y. p8 U4 f3 B$ g- P/ Y2 f8 V
### authz-db, no path-based access control is done.
A; P/ A# I+ \9 d### Uncomment the line below to use the default authorization file.! x8 t: |( O: X5 R8 n$ i
authz-db = authz
4 F1 e- b1 X y! K0 F( A### This option specifies the authentication realm of the repository.) Z# ?* x4 f6 x% F( a3 h9 N$ n
### If two repositories have the same authentication realm, they should' `) z/ }( Z* c( q4 e
### have the same password database, and vice versa. The default realm& m$ X7 p( [4 P; j, j- e
### is repository's uuid.
: h- f6 u8 d# I1 w2 i! Zrealm = My First Repository
/ \' Q& P. n. j& x6 p 瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn n! K0 b- X) l) T5 X
#killall svnserve //甇
+ X6 g+ H7 a7 t5 k, ^) x, H 敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx% Q8 g$ N' l: ~7 e; {
4,蝵峰ost嚗commit 蝏餈銝餈圈蝵桀嚗svn隞摨啣/www/wwwsvn, 雿眨eb寧桀/www/web,銝方銝臭銝芰桀嚗瘜svn push銝亙停唬具 a嚗擐究erver蝏蝡舫嚗嚗svn co svn://192.1.15.222 /www/web 霈啣撠/www/web桀靽格嫣蛹www:www chown -R www:www /www/web
9 `* X U. A2 L: p b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐
& H) @+ ^" l3 ?& x( Nexport LANG=zh_CN.UTF-8 svn up --username yanzi --password yanzi /www/web/ chown -R www:www /www/web/ 嗅撠曹ok鈭嚗典┬vn commitweb桀銋撖孵隞嗅改 ps:1嚗svn upY摮撖臭霈曄svn冽瑯 2嚗銝├p撠望真pdate嚗git亦閫嚗撠望舀銝芯摨A嚗嗅啣遣鈭銝朋餉頦服嚗瘥甈,鈭斤嗅嚗霈咕銋pull銝銝餈乓究vn真pdate 3 , 鋆摰nginx php-fpm 撠 SElinux 摰冽輻,血蝬脤箇 "Access denied" :$ B5 k+ D8 l( f% E& @3 Y
#system-config-securitylevel 豢DISABLE敺OK嚗敹璈 , r; P+ R4 h! t( C2 y' G6 f
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急 vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled
2 |1 f! _3 j& t3 n( `4 _1 gvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
) \6 q* r ^4 e4 I1 |/ N4 E; m |