: http://blog.csdn.net/yanzi1225627/article/details/49123659
, Y! d! X, ^( s7 ]1 l* w' ~
- c- [6 M5 E2 S% L5 B9 d' y& |9 p格嚗剖遣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 cmake; |/ W; L& ?/ o$ _
湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx
* H$ W3 B( _' D+ j1 { n 嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www
5 {# V4 _6 J) Y: l- g/usr/sbin/useradd M -s /sbin/nologin -g www www //-M 銝撱箇雿輻刻桅 nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具 chmod 755 /etc/init.d/nginx
" I6 f3 w; \+ k. E% c: }. V, q6 q, Z6 ]5 c8 m+ R$ L; ]4 i6 s
chkconfig --add nginx" f. B8 q: v6 ]$ g+ q. s& u7 L5 M
6 C9 Q1 D1 R* `' {7 B- Lchkconfig nginx on
1 U0 G; T3 C5 M' g: G 嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash
, _( w; T1 \! d6 I: a, f# `# nginx Startup script for the Nginx HTTP Server
3 H: Y: ~2 e3 w7 w! `# it is v.0.0.2 version.
# l: o }3 B5 Y, i; L# chkconfig: - 85 15
! |% \2 L' C8 Z; O" e# description: Nginx is a high-performance web and proxy server.
! x% ], L$ H) z% Z# It has a lot of features, but it's not for everyone.
( `# t( ]2 h; D# S# processname: nginx: ~) z3 C' c3 P, u2 ~5 B/ h+ n5 w
# pidfile: /var/run/nginx.pid3 m \8 \/ v6 V% @4 V, m
# config: /usr/local/nginx/conf/nginx.conf
6 J& i! E7 n7 T" D- a0 H* ~7 hnginxd=/www/nginx/sbin/nginx
[1 s5 Y2 I8 M6 x; l: fnginx_config=/www/nginx/conf/nginx.conf: m) R9 _( u2 E$ z2 D, p
nginx_pid=/www/nginx/logs/nginx.pid
C3 Z* D% h+ ERETVAL=0
0 U: j: X+ X7 h# ?prog="nginx"
# |. Z6 O; ~7 o |# Source function library.8 K( @6 b/ \8 k W% m
. /etc/rc.d/init.d/functions
* {& Y! E) x& y# Source networking configuration.
% ?- A- D6 J2 a- i1 f. /etc/sysconfig/network+ Y1 D* p5 l7 m; s# }$ o+ p
# Check that networking is up./ k, _( y6 O. H" E" N% w( }
[ ${NETWORKING} = "no" ] && exit 0
, V2 }- W) ~& n1 y# R6 K2 e[ -x $nginxd ] || exit 0& F: t! a, P4 _' S9 ]- x# G
# Start nginx daemons functions.8 b a2 F' o& S9 }" _
start() {
# J# j7 _# E* g3 \" ]if [ -e $nginx_pid ];then2 z2 o( o7 e) p+ P6 y8 w
echo "nginx already running...." R2 Q+ h( N0 p0 W% ^- q( S
exit 1) u9 ?: X3 m: |% Z2 V
fi6 r5 X5 e, k7 |3 K3 L+ s& {5 W
echo -n $"Starting $prog: "
+ M; @- c, V0 O/ Pdaemon $nginxd -c ${nginx_config}, t3 C- {9 e" i' z" [! Q
RETVAL=$?5 J0 X$ P* x( ?* y6 O
echo
# z8 a" d; H8 L4 K: Q7 R4 b# [[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
3 x9 p: Q, f& S. n( i- s/ lreturn $RETVAL
" b( W0 A1 w5 o! _}( n0 f( p+ }9 A1 G# w, Q
# Stop nginx daemons functions.
2 m/ k: L X% p, l V& k8 {5 M" ?: R4 lstop() {6 x# b) c: y! `) F0 h
echo -n $"Stopping $prog: "* p' k) n( a5 t9 r- X% o; l0 O8 n+ H
killproc $nginxd& s6 E$ R$ ~4 t% F( _! a( R% x/ q1 E
RETVAL=$?; n0 P* J( f3 _. z, @
echo
8 V# |1 O7 {3 o$ e/ m, g% p[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid9 N2 z" e, W$ @0 ]
}
( |# D) B1 }: \' ]+ z j! |1 sreload() {4 R8 O3 f8 w6 B: v- G- ?
echo -n $"Reloading $prog: "4 x b: O2 W% U: N3 v
#kill -HUP `cat ${nginx_pid}`2 p; T) p$ x C6 p# r3 f" r
killproc $nginxd -HUP
3 n4 U. ], f- ^9 O+ A/ QRETVAL=$?7 Z+ l% R% b! y8 H. p' A
echo
2 y$ H& p: F; \7 x" l9 ^} {. A* ^6 k0 k; e3 {8 T& _
# See how we were called.8 v3 K& X; Q: C. Q3 M- X' O
case "$1" in
3 M8 g4 @7 h; K9 hstart); q; @7 z8 V! K9 Q P1 R# a
start
$ u& w' `) _) a9 F;;2 {& u9 i# V w6 T* o: Q
stop)7 `4 k& p- a2 L" l( W9 `" O
stop
9 U: X" X9 \6 T. H( };;0 r) T2 j U8 F! i3 U' [0 z! h
reload)
$ C! K4 o1 ^/ _6 @# w4 i1 f0 [reload& j3 N9 E# X j( _* F8 v
;;
: w7 D+ {) _( Q+ N' v9 drestart)
3 t) I6 X7 r4 h$ L, u" m ystop5 u* A1 M9 L: Y7 C# ` q! J
start
' [ S/ Q4 K" O9 @7 f9 B;;
6 n( E) ]* S! O' B) hstatus)
: w2 c6 y0 }) p3 h! Z$ _/ B5 zstatus $prog, [9 v! w) D2 z, c& Y
RETVAL=$?" A+ W1 h( U4 Z3 e
;;) D. \8 A* A* [" Y
*)
4 c7 @0 D+ `1 U* D1 W- q0 ?echo $"Usage: $prog {start|stop|restart|reload|status|help}"
, f: G( U( ?8 m, y6 N- iexit 10 a; U* f F! [" |
esac
) Z2 h8 L. _2 h- `( sexit $RETVAL
( W9 [ {* D' H$ s
% ?7 X1 C0 c, w. F2 U 瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬
6 A7 K" B* T' d& V6 R2 Z2 c# Pchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗0 r, }2 H7 Z8 G- U
1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠 % H7 x0 F, ~! c" t. f0 W
location / {
! p$ f5 f3 X/ K! H& h+ x9 t root html;
: @" U7 V" k# ?7 q+ T index index.php index.html index.htm;
D$ Y8 w) h4 Q }; q" M+ s' [, A q' ^" k% ]1 c
靽格嫣蛹嚗
3 r; }9 i% t: p& k0 _- s& v# P5 [9 y. k- s6 H
location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
" b( q: d' |+ \! i1 P& _! clocation ~ \.php$ {( i+ p: {- {( j; w9 h. g4 P
root html;2 R: p/ m7 m# f* j
fastcgi_pass 127.0.0.1:9000;
" U5 ^/ v5 \4 h+ E7 b fastcgi_index index.php;! Q9 A7 F1 ^. T5 h g" A! [, d. s' k
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;5 ]" \6 i5 v/ {! j R+ w
include fastcgi_params;, a' l5 f9 ~3 K2 i
}
$ C' }) Y( E3 z9 @靽格嫣蛹嚗
' D+ i% z/ V9 I) y0 F2 Z
& K7 e" w4 r0 N6 k8 ?6 o0 }( 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閫蝻拙僎餈唳桀嚗扯嚗
7 h. l* M; G# { T7 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
8 L7 C8 ?6 ^: B1 L" |9 E1 v
0 U. F0 C: V" r2 Y#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
- `7 @& H: E6 i ` 扯 cat /etc/passwd 亦冽瑕銵$ L9 Z1 o) s }5 T& {" ?) U
cat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀# a6 y0 B' d& d# D& Y
3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql, b0 V- H: O( e# X% O# {8 W) E
4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql7 [: c# D |9 L
chkconfig mysql on
" F& i" A, J5 D4 _- j7 `service mysql start --臬決ySQL
|/ w2 |* F9 j0 M% D8 _. ? 5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH5 M& J- |; V. J- ?, ~2 p- `
export PATH% E3 B' a- X. {$ }$ |% L. F& x
靽摮source /etc/profile 扯嚗
4 E% L5 z8 x+ S# ]mysql -uroot mysql> SET PASSWORD = PASSWORD('root');" a9 ?! f2 @* s& p
4 ?3 m H/ ? W. i( B% F
霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗
! a4 _* S$ O& | A2 r' ?! tmysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗 8 m2 O) H- j; {
#./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嚗 5 [2 D* l9 q; {, [; M1 {* O
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.rpm
) B- {( g0 T8 W; l9 g U: P) K; R3 H f
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm8 W+ c' u" H7 C7 \; ?
Create /etc/yum.repos.d/php-fpm.repo file and add:
) y. a! u6 K) E5 ?) s- [nginx]
- N: s; Q) Z& _$ h - name=nginx repo
8 h `; H$ I- m9 N. t' ^/ @ - baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
0 E6 w, f4 J. ]0 L; `/ E( T% W% K - gpgcheck=0" n9 d8 i0 ~0 v' u
- enabled=1
銴鋆賭誨蝣
% K1 S& |; x! E- p* s! Oyum --enablerepo=remi,remi-test install php-fpm. ?( o. E8 ~& V# k- ]' E- a
4 K- X( X* ?0 ]8 w* N' M. d. N
7 q3 y& I4 H1 j8 U( ^鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn0 E, d% b5 @8 m, I. r
嚗yum remove subversion //貉蝸雿祉svn
! B% c) G* L3 D- R; W9 {$ V6 J% G% k$ X. g # yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn) \* L( ^ V2 s1 D6 n2 }& h, C2 ]" Z
餈# 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]
( u7 M) C; a: R, v# harry = harryssecret
3 b$ Y4 }! Q& f4 N8 ]9 A# sally = sallyssecret0 [0 u( O. A2 j* m( p; t: M
wangning=wangning, |1 B a# S6 V9 ^8 M" y
yanzi=yanzi
8 o; d8 T; l0 J7 S: z, I #vim authz //霈曄蔭 6 E. L$ O1 H; w5 K1 M
[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none4 m4 [& I* K: S/ G/ K' O; T
auth-access = write( [/ C4 v8 ]% O
### The password-db option controls the location of the password
' u& G* q* \5 F/ p### database file. Unless you specify a path starting with a /,# q2 g* ]3 m' P& @% ]! }0 R
### the file's location is relative to the directory containing- X w5 e- K& ~* {1 u
### this configuration file.
' _: \! C# d, f$ ]+ ?# q### If SASL is enabled (see below), this file will NOT be used.
# j" M% b8 P4 p8 C; \# R### Uncomment the line below to use the default password file.
7 T' t; ~. _4 n" Y/ y, V, wpassword-db = passwd
7 Z4 {8 k+ M9 \& ?6 o4 Y: x### The authz-db option controls the location of the authorization+ F8 l* v, a* H1 N& z
### rules for path-based access control. Unless you specify a path
/ ^( a5 e" x8 g: W; }### starting with a /, the file's location is relative to the the
& z" A7 u2 U b# g0 K( C### directory containing this file. If you don't specify an
$ `2 p, V3 @# c+ Y; g+ v) u! V### authz-db, no path-based access control is done.
+ N& \# ?4 Y+ H$ t### Uncomment the line below to use the default authorization file.& I! s4 p; R8 D! C
authz-db = authz
g: G* T/ |7 l5 u! X6 p+ w7 H: [0 V+ a### This option specifies the authentication realm of the repository.
& m X) q" O! |$ X) u6 A7 \ h, l### If two repositories have the same authentication realm, they should
! x, p3 R! o# b- m3 {' M### have the same password database, and vice versa. The default realm& k% w! j/ x6 ]" q; j$ y) I4 I& C: B
### is repository's uuid.4 o: p, |7 J- n3 l: o9 \
realm = My First Repository4 U' z, \* p1 O
瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn) C2 v, m! w! a H9 a: l
#killall svnserve //甇. ]. W5 |/ y3 |7 e, f1 f4 E' f
敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx
. k( s% h% I+ C0 q5 X% P: A 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/web5 Z: E2 C7 U6 \; N0 I- S) g6 [- w9 A
b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐 + Z; T: \0 i" E7 d0 p
export 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" :
- c1 W! I$ R( U% e' A. O3 p! q#system-config-securitylevel 豢DISABLE敺OK嚗敹璈
0 a8 x- j% h& F瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急
vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled + T. c* G" G( w' K% K; B1 }& i
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
: _( F2 Q0 v* D* j8 L! i |