: http://blog.csdn.net/yanzi1225627/article/details/49123659
4 C! T) P( W0 w% s3 @
. s m4 l1 d9 E. b( q$ ~+ b格嚗剖遣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 J& `) G: g) p0 p. @# F
湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx9 J% v7 E6 _% D( s) J
嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www3 V1 i' ]; f2 D% @
/usr/sbin/useradd M -s /sbin/nologin -g www www //-M 銝撱箇雿輻刻桅 nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具 chmod 755 /etc/init.d/nginx
1 U- A+ b' R) k y( w
$ }$ f* m6 ^/ M% n3 ?7 O/ `chkconfig --add nginx# ^" J+ _; [; q
7 `. s2 [( I3 t$ j' wchkconfig nginx on9 |9 j ]- \& U( l6 ?/ E' P
嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash; p$ u+ s* n) O) W
# nginx Startup script for the Nginx HTTP Server
, I2 r+ J6 Q6 d2 }6 y# it is v.0.0.2 version.
- |, O% m$ v: c+ A; G, g# chkconfig: - 85 15, @7 n& N/ t3 h4 w5 {) V
# description: Nginx is a high-performance web and proxy server.
$ f5 ?& u) Y$ S( H6 {# It has a lot of features, but it's not for everyone.
9 X: E6 H! c- o" R0 [# processname: nginx) G2 [" |7 u- v+ H4 `* Q
# pidfile: /var/run/nginx.pid3 z% J7 G" ~, p5 ^. g5 C
# config: /usr/local/nginx/conf/nginx.conf
3 o* c3 t% I' u* T ^: [! e# xnginxd=/www/nginx/sbin/nginx
) o7 B0 u) e! a" ~nginx_config=/www/nginx/conf/nginx.conf
3 Z! ^& M7 S2 a9 U: Q+ h9 Xnginx_pid=/www/nginx/logs/nginx.pid c/ [& X, n/ X" S5 Q3 E7 z5 i
RETVAL=0
% X; z" q* s' w7 mprog="nginx"
6 ~8 \5 } c* M- j: m# Source function library.
$ r+ R# T! M1 M# t. R. /etc/rc.d/init.d/functions
/ `; _ t! s9 H* ~: S7 S0 C( C: `& R/ }" V# Source networking configuration.& K9 U# M, T4 J7 q
. /etc/sysconfig/network
! C. O! a: ^$ R" q5 p8 ` g# Check that networking is up.) I8 |6 r1 x% G! ]9 w$ v+ c8 w% x
[ ${NETWORKING} = "no" ] && exit 08 z8 S/ k4 q3 t( I& q4 q7 M8 K
[ -x $nginxd ] || exit 07 X. R! E7 ]3 a2 C5 O4 F* ~4 t
# Start nginx daemons functions.+ ^" P {) [9 M0 \9 S& W( I0 x
start() {
0 |6 I" F7 d6 Sif [ -e $nginx_pid ];then
, U/ u6 ~- @$ E5 j+ C3 hecho "nginx already running...."
$ b$ @7 u3 m$ i1 Q0 K6 ]8 {exit 1
# ?- D* C7 b, Q* j- N$ S0 v" ]( sfi
/ i1 q, J" g! {0 Xecho -n $"Starting $prog: "* O6 z y) s/ Z4 c
daemon $nginxd -c ${nginx_config}$ K( _% h. M" N8 }2 u
RETVAL=$?
; _2 ^3 L* M0 [/ I7 X" n' k- aecho
i3 q! q- {: L0 E- B[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx2 H& o) f! s- g; K
return $RETVAL
4 x6 g8 [; z' y! O% p}
# q. \4 \6 @/ {0 g# Stop nginx daemons functions.% P4 e2 D. a3 Z, U* ^$ y" k' H
stop() {
/ h# Y# ]6 n9 p" t8 ?% }echo -n $"Stopping $prog: "" i% Z, v6 F4 ^( v. R8 m
killproc $nginxd
/ }$ U+ ?# Z& @- H5 ]( nRETVAL=$?( F4 ]/ t: H% Q" x; E
echo
) w% R& P1 I' l% @- M: C" u[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid! ~/ Y% t$ { z, ]% m4 U. O* V$ z( P
}
3 K. w' u$ j: K6 Oreload() {
# U- |2 D: h$ X/ _$ ?1 Decho -n $"Reloading $prog: "
) b5 q2 w6 y$ i% k* d7 P8 E#kill -HUP `cat ${nginx_pid}`+ T" z6 Z: K1 j0 L' K# @; X3 i
killproc $nginxd -HUP
9 _3 F- v2 f3 N7 g. e( F& oRETVAL=$?
- E- m) F: E( |+ [echo( {9 q* U, u. g; _/ q
}
; M0 F. Z% ?5 i+ s6 q4 @2 |3 V# See how we were called.( X: m% s" b( ?9 N$ O. ~
case "$1" in7 O' \5 Y$ ^" y6 e4 y
start)
' j. P' d6 o7 l" {" J jstart
& n/ u! p Q* E4 x" v;;
- }' k8 C9 f2 D& t' q$ Fstop)
3 A: K# a/ D$ C5 ]stop! b. L1 e, B/ Q0 b) s
;;
" \1 z6 O9 C+ h5 ?% Qreload)% v& T" L; V8 ~) E e$ J% ^
reload
4 O: d/ R( [5 i, y& l3 s;;: y4 g& R# W+ J2 K @ a' g& I( Y
restart)
/ O Z' t, H' `; G' j8 \$ o' Hstop
' O; M8 d; ]. M: B4 Z' qstart
2 z4 J6 R4 Y8 Z" x;;6 e4 B& ~" t2 W7 A( y
status)
. o2 q8 y& T: q0 k. f2 R% n* pstatus $prog
% y" X. \4 w8 @1 h+ Y3 ]0 q( A g, LRETVAL=$?
6 C9 K B+ O7 l( Q7 m) @+ `;;
5 U2 W% V6 m+ Q$ j, R0 ]*)
c, ?! j& e, l- Oecho $"Usage: $prog {start|stop|restart|reload|status|help}"
: I, h% p8 R {) U/ j9 r% O3 Eexit 1& \! A$ k: _# G2 b9 U6 M4 T* p
esac
5 X8 R+ x; u; J: U8 @0 g/ Mexit $RETVAL
! t3 m* \) j% R# O" s! _; Z" a; q4 [8 {& l P4 v( g: Q1 T
瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬
6 } G6 `; C9 bchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗% w% f, V0 N3 [2 T, O* E2 L
1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠
( a0 Q! n: L! c' z/ h! w location / {4 `' L g: h6 c5 v D6 @3 L( f- q8 T
root html;
1 ~) R- Q$ v9 G) J index index.php index.html index.htm;
' B9 [& B: R: i! s4 x }4 ]* g% P4 L) }4 S
靽格嫣蛹嚗! k8 C% X1 I2 {) X1 ?
" L8 ]1 t5 a0 J: e3 _3 u) F
location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
( l" Z' P3 x- c A$ \location ~ \.php$ {4 H! l6 H! R: V1 m! O; D/ a! n
root html;* c4 q6 q; P$ K9 D: l
fastcgi_pass 127.0.0.1:9000;8 ~ l4 y7 D) l# S# p, _; S9 q9 v
fastcgi_index index.php;
5 T1 \% N1 [3 [& V- K! w7 } fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
& e0 [8 i% M& m+ \ include fastcgi_params;
1 c4 l! l! I. I& @( H, s }. L- Y$ g& S6 y, T
靽格嫣蛹嚗, \. Y$ m5 o) m3 V& t- X8 Z0 ?$ c, e! z" V* N
- S8 n7 |1 {, R( s3 i9 i9 O% z3 |* f. ` 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閫蝻拙僎餈唳桀嚗扯嚗
1 J# j; j" r) y( f/ d5 _5 ~8 t#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql
3 q; I5 L7 ?3 \5 k, R6 m6 }5 u* I0 S+ u& |. y: P' |5 {
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏4 w1 Y3 |8 y) ^4 E
扯 cat /etc/passwd 亦冽瑕銵) Z& f8 n7 A( v9 L- m+ |! g E4 Z) q
cat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
9 L6 a; g& {* j* K# k2 Y 3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql% ? b, L6 F: x" I8 p2 a- r: o6 |# }
4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql" T! ~3 P- O$ x) H, S4 r
chkconfig mysql on' C+ v% W8 l$ M) b! e' {
service mysql start --臬決ySQL
; b# K+ M! r" L 5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH
+ S5 U1 t5 p `) Q- b; uexport PATH
# L$ `) V* ?2 s 靽摮source /etc/profile 扯嚗 - W. O' j: S- M5 ^, H
mysql -uroot mysql> SET PASSWORD = PASSWORD('root');; {+ E! t8 R! r F4 T' [
2 b3 ^3 Q1 ^: I3 C' x. H4 ^霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗 3 j: C. k/ e$ Y m$ O/ L
mysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗
' b0 z4 A" K2 F& M8 r5 y* k#./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嚗 0 h6 v! m5 R# M: m t* h* J
PATH=/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.rpm9 C9 l. h a9 g) @
% p: F' w: y$ b" V+ E% ?
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
! L6 l: g7 u* ~# hCreate /etc/yum.repos.d/php-fpm.repo file and add:9 A% p$ b: R% g- v% L
- [nginx]
' R }3 z' r/ [6 e+ f - name=nginx repo. y( l* c5 M$ k1 N. S
- baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
- T1 K" ?8 \$ ]5 c! G( X l - gpgcheck=0
/ p! \, v8 `! f+ e# K4 } - enabled=1
銴鋆賭誨蝣 7 X: [( `1 Q. R6 d1 T, n# i
yum --enablerepo=remi,remi-test install php-fpm
) [; Y/ R Z. p: |
3 ^4 V3 V+ D& T |3 P) [
1 z& U0 E6 i: C) d( O' h1 K$ \& n鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn* z" _8 ]% Q% C! F9 J
嚗yum remove subversion //貉蝸雿祉svn
! @. @: I" [ @8 s2 [' d; l7 J # yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn: T* W2 _1 r0 R9 S& g9 ~& O; O6 Q
餈# 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]7 c- L7 s/ b P/ h: F% X7 ~+ ?
# harry = harryssecret7 `9 C: W$ Z, O9 G8 a
# sally = sallyssecret5 |6 A! B5 H7 k6 p- j
wangning=wangning
9 x4 E9 _7 O0 n+ [+ _+ e U0 N+ myanzi=yanzi
: }) Q* m3 J2 t9 U$ w #vim authz //霈曄蔭 6 Q; n- X4 J2 R2 D# X* Y
[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none: i- A8 S7 r4 q1 k0 c
auth-access = write, W3 i5 P1 e$ `+ |; n) u5 X
### The password-db option controls the location of the password
2 n; ^+ R6 h0 R4 ` e; D### database file. Unless you specify a path starting with a /,& j; |4 e6 t8 o3 }; S
### the file's location is relative to the directory containing! ]) b, F- p' \' `" X
### this configuration file.6 F$ Q; s7 h( N; ?4 O8 ~
### If SASL is enabled (see below), this file will NOT be used.
' {2 {( n3 X/ ~2 z+ e1 I0 K### Uncomment the line below to use the default password file.! A$ b. {1 J% P# X J% N" X2 ~
password-db = passwd
; ?( ?+ h- t- V9 @### The authz-db option controls the location of the authorization1 Z/ H+ r$ O7 M4 k
### rules for path-based access control. Unless you specify a path
) [/ _0 p3 w1 s5 @5 J% T### starting with a /, the file's location is relative to the the% u) J9 ]) Y# ^/ v" V* a
### directory containing this file. If you don't specify an2 _; ?" Y; D+ E% J9 m% Q
### authz-db, no path-based access control is done.- ?4 W. A2 D0 w" }
### Uncomment the line below to use the default authorization file." x# ]# g. h1 W+ L$ C: `
authz-db = authz
9 H8 {! }5 F$ ^### This option specifies the authentication realm of the repository.) a- x) n( _$ x, {; A" m7 n. i
### If two repositories have the same authentication realm, they should& }0 u2 b" ~7 x
### have the same password database, and vice versa. The default realm) ]- N" \- I Y* Y; v9 j8 Y
### is repository's uuid." ]! ~; R7 Z4 j* \% x0 f. f( S
realm = My First Repository" g9 W) S' C( S& z' s1 Z) r3 @
瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn
: B% Q W8 r& c9 f/ { #killall svnserve //甇& v/ B/ a# I9 A# M6 o, y
敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx
0 u2 s/ W, J) p( X6 _, B 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
) z- Z# p1 q. H; V b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐
3 R4 X# v; y8 `6 w, x' H" B+ Zexport 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" :9 y8 F) s7 n7 V1 g4 b9 N
#system-config-securitylevel 豢DISABLE敺OK嚗敹璈
8 A( \: C) p/ B' I, v# ?" {' R: E瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急
vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled 0 J1 ?" }* v1 L3 y0 @
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
* F& u, L) ^2 }( I# t3 e4 j6 T* c |