: http://blog.csdn.net/yanzi1225627/article/details/49123659* Z7 B0 \6 \0 H* j5 I0 F* b
" Y) _- ^( I9 X" R1 H; E
格嚗剖遣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 cmake9 y0 B+ j3 c5 O
湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx7 d- n( l' l. e* F" Z& ]
嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www
5 m& a; ^" L2 V8 j2 g; K* h/usr/sbin/useradd M -s /sbin/nologin -g www www //-M 銝撱箇雿輻刻桅 nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具 chmod 755 /etc/init.d/nginx x" B, p7 \( P3 ]6 v: |
) M9 W; e4 w; x! Echkconfig --add nginx: K0 w- b5 x" f/ N1 k6 M
% g {4 `4 M8 P- o- G/ ]
chkconfig nginx on
1 w# Q) ^7 w6 z+ d$ x 嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash& O) o; @. Y3 @* H! E/ a4 P
# nginx Startup script for the Nginx HTTP Server, g; ^1 V: Q9 \; O! |& S* N
# it is v.0.0.2 version.3 i+ _1 r5 ~+ d( l4 C" c
# chkconfig: - 85 15& D, O: T) J6 T, `8 D3 g @
# description: Nginx is a high-performance web and proxy server.% o1 ]7 D. U; W% [& B- J$ M
# It has a lot of features, but it's not for everyone.8 k2 A* D B1 J5 L2 O1 \
# processname: nginx
5 [& d ]+ Y6 N1 Y+ Y# pidfile: /var/run/nginx.pid' H* i% D; _, Q# K! C( K) J5 \
# config: /usr/local/nginx/conf/nginx.conf& X! n- m% c1 f; X9 ~; [
nginxd=/www/nginx/sbin/nginx) M! ~0 h' N; i) U! S
nginx_config=/www/nginx/conf/nginx.conf
% [6 {5 c# A" g3 m0 X3 m" s: bnginx_pid=/www/nginx/logs/nginx.pid
: h* Z$ Y0 M$ a4 ^1 YRETVAL=0
2 c5 j9 ]4 P0 l8 Xprog="nginx"1 Q( o! C$ @/ L' a" T) ?' z
# Source function library.
" H' Q6 u3 }4 s7 b7 t# k0 e. /etc/rc.d/init.d/functions% {+ y% r! \5 E$ u4 p' X# F
# Source networking configuration.
8 q/ R; C) t% J3 {0 z: c. /etc/sysconfig/network
. g0 p3 d) @; ?# Check that networking is up.
7 ^& U4 @$ k4 t' u, `' I[ ${NETWORKING} = "no" ] && exit 0! R" y/ e" U8 ^5 \( a) `. R0 J
[ -x $nginxd ] || exit 06 B1 c& @+ R! q7 F, e& ]/ k
# Start nginx daemons functions.
- E# S$ ]/ b$ w7 u* b0 i3 D+ `" Q& |" e# ?start() { A, ]6 }# Q" ~, M7 r
if [ -e $nginx_pid ];then
+ U g0 t9 |: }; Zecho "nginx already running...." J, t5 Q5 F* H) z7 ^
exit 1
, P/ |; b1 i/ ]3 z8 a' q7 B5 `* {" e/ ofi
% t* ]/ Q- z# X ~' s: }echo -n $"Starting $prog: "6 w' N' O& v& K& ]7 g# O/ |
daemon $nginxd -c ${nginx_config}
7 R2 |8 I/ V; S( }5 f/ u- W, _1 HRETVAL=$? k6 N; p0 s6 v
echo2 ^! N) C) ? W: M% Y0 S0 P
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx0 a9 W; X$ ?: T. t% _. s
return $RETVAL" Q. Q5 Z G7 [/ I- j
}
5 v2 H- s3 X8 ]! p- k. q# Stop nginx daemons functions.9 I% b4 L o! U0 ?5 N+ j. H. G
stop() {& [6 T. ]+ G/ Q' Q0 b- b6 e* t3 P
echo -n $"Stopping $prog: "8 M5 J+ F4 E6 U9 M1 F _
killproc $nginxd
# y+ x3 O0 o& e0 A' b/ d# ARETVAL=$?
0 `- N0 O; Q0 h# gecho. J/ t) h' E# r$ m. ?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid4 ^9 p! b* X$ {5 r* o' X
}# y' x% u5 q, T1 ^1 f' k" t2 }9 J% b, u
reload() {- W3 s9 n2 o, c* T& R `
echo -n $"Reloading $prog: "
4 h L8 e4 e5 b7 i#kill -HUP `cat ${nginx_pid}`
5 u. ~5 g v; Y0 L: ^8 n$ Y, [- kkillproc $nginxd -HUP
6 v- R- J2 l; n+ l' }$ KRETVAL=$?
- _- r* q# z; y2 F. z# Yecho
N! _& a+ L* {/ X" L# y}7 ~0 x0 [; A% T) f% O
# See how we were called., P! i" t! k3 k' |
case "$1" in
; B0 V9 h0 W8 }0 K. L; Wstart)+ }+ M( F: Q. `, M$ v/ [8 W
start
~3 t8 N9 H F2 z- A;;
, }& K0 b4 [& S9 d: x- ?stop)
& x: v! @8 j. e9 ]stop
0 B* P8 q6 v+ u' s# |, x# C;;
% J. A/ U" h! ]) z( z# N1 Sreload)
$ u" F8 `4 U9 @0 g1 breload
5 U2 p: `8 J3 ]5 w;;
8 y/ d1 S+ S3 l l4 i2 Arestart)0 ] e9 Y! V+ i' l" c( ~" k
stop! e- X: v, e* n7 o. ]% L
start- o+ M' G$ y* z+ i) O3 E0 M4 M
;;
( j8 y5 j0 U9 |5 |. U. }% qstatus)6 k( Z5 D1 o+ {/ @, a
status $prog$ \6 n/ }+ g8 C+ U9 [
RETVAL=$?+ x2 O, {% j/ W% {/ g, y0 M3 [
;;
9 p) R& x4 k% w4 r, l; p( P*)
: H! c8 t/ D) K7 w9 Fecho $"Usage: $prog {start|stop|restart|reload|status|help}"
) g+ D2 {+ S% n9 {# G0 h4 Kexit 1
: Z' a, }: q7 b3 m5 q4 `2 Mesac4 f$ B& p8 x' g, a7 V, p
exit $RETVAL6 P% ~/ }9 V, z6 X: G8 s5 H
; A: `5 U; o* q4 F( K7 R7 Q3 n 瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬
8 _4 j- H1 D3 _, rchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗4 F# J4 M( O+ {; ]& E- i9 ~* I# \0 l
1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠
1 k+ V8 p# n" X! k( y location / {& g1 T6 B" |- K& z1 ~% e4 v+ N
root html;
$ G+ n! `( c, U0 d9 u/ V: j+ D index index.php index.html index.htm;# T" G# Z$ k1 n* W0 T
}. ~/ C2 Q4 k" _$ n5 [. A$ c6 k
靽格嫣蛹嚗$ D# O7 s$ U& c" I$ j" g
" N W X" ?# m' w4 g4 U
location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
9 T+ T0 i Q3 s( P1 p c/ Alocation ~ \.php$ {( j4 @" G' x9 L
root html;) ^* S6 e8 ^6 }; |% Q
fastcgi_pass 127.0.0.1:9000;
5 @5 S/ a2 A0 u8 \ fastcgi_index index.php;2 O/ W4 x( f/ K- H
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;0 r8 B- J: Y% u& U6 ?
include fastcgi_params;
5 W7 | @9 t- ], k8 O- z) k2 \ }/ c: `! K9 _8 o$ R
靽格嫣蛹嚗$ f- ]5 z: X4 ~3 q& \8 ^
Q9 P! o" T; W" |6 \ T 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閫蝻拙僎餈唳桀嚗扯嚗
* i! u8 V# s4 y( u#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql7 B! r3 G) G" K
2 Z P! }4 Q5 d7 q' \% L
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏 W/ _& c0 x" j$ i6 Q) b
扯 cat /etc/passwd 亦冽瑕銵
* n* c, S1 y# t5 S1 p; Jcat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
5 i. ?& v; I$ ]* j1 a8 j3 o1 v# R 3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql1 L2 n# e6 [+ G5 U" ~
4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql
9 l7 Y. o `1 d$ y7 @chkconfig mysql on$ g7 y: [, \9 L9 ^9 n
service mysql start --臬決ySQL
% l, H$ Y9 U- C7 g T 5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH
' X. V; }: a7 ], e' {export PATH O1 `9 l) n" `9 ?7 E) w1 Y
靽摮source /etc/profile 扯嚗
7 q8 w. s0 U9 k, N( Kmysql -uroot mysql> SET PASSWORD = PASSWORD('root');4 _+ o, b2 C- j
W" k7 s4 ]' v6 p
霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗 & i* H g# |& ^/ }, H% I4 _' p
mysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗 ( g( F# n4 @2 [; E- L7 o2 y
#./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嚗 3 M/ g9 Y) [- c0 L5 X# e$ ^9 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.rpm
4 ]; k. ^9 G+ f' U8 B7 k( y
4 H! ^# d' h/ m1 Jrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm# k9 j9 d0 I4 a" G C: i3 @+ g$ m
Create /etc/yum.repos.d/php-fpm.repo file and add:$ j$ J, W+ B! P
- [nginx]
: z- Q" u) U: q/ l - name=nginx repo
8 a* ]/ O7 T( S/ O - baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
; W. \/ R# z) @5 |% h9 A, j - gpgcheck=0. e/ f/ `- W q6 |
- enabled=1
銴鋆賭誨蝣
5 y* R, r/ `! S; H# Zyum --enablerepo=remi,remi-test install php-fpm* H7 B6 g: u6 l6 Y8 w
9 W0 y6 \: o. P' _8 w, M
6 l4 L7 J$ t A" V" a. \* x
鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn7 d# A1 w4 g2 d8 ], U) i$ i5 [+ f9 f
嚗yum remove subversion //貉蝸雿祉svn4 A0 r) e- y. q% @4 G# E2 y3 U$ A: d' x
# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn
* o, ?) `# n: p t5 y4 r 餈# 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]6 \3 E. f: X8 s, M
# harry = harryssecret m7 E" _6 B2 l/ a8 e; d
# sally = sallyssecret; W, [" h5 g- `- k( @6 _
wangning=wangning, _7 e+ P2 h% k0 Q! o/ |
yanzi=yanzi
5 N/ M: `' n9 E4 A' u2 [$ n #vim authz //霈曄蔭 1 z& X& \, v4 u9 R" R
[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none0 Y% ?& v, V1 N8 l. T, D0 T
auth-access = write9 v: ?( J! E) L( y* K, I
### The password-db option controls the location of the password
4 ~ c; C6 Q! ~; |- K5 r" n### database file. Unless you specify a path starting with a /,
, \. o' A0 g2 l9 Q4 z' ~### the file's location is relative to the directory containing
7 z0 v1 s- w s9 Y3 d: q# u### this configuration file.1 U& U$ B* I" M
### If SASL is enabled (see below), this file will NOT be used." a& x F6 e1 e) t* d
### Uncomment the line below to use the default password file.. a- ?6 k# E# s) x- G
password-db = passwd4 H `6 ]3 o2 A) z' h
### The authz-db option controls the location of the authorization. l& l) [9 g2 b' g5 N* y S, Q
### rules for path-based access control. Unless you specify a path# f2 `6 A8 P6 X2 y7 E0 R. T, g
### starting with a /, the file's location is relative to the the
N# z7 @3 q# K. l### directory containing this file. If you don't specify an
5 B' p3 Q* g2 h% H* _7 D5 @) U### authz-db, no path-based access control is done.7 ~9 Q3 \7 l8 W# D& b) Q' A
### Uncomment the line below to use the default authorization file.7 l1 H5 @: {7 B* r% L7 W8 v- d. @3 i
authz-db = authz
( |/ F( W7 `$ R. T### This option specifies the authentication realm of the repository.% V n9 f. M5 H( ?% V' [
### If two repositories have the same authentication realm, they should
- H9 }9 E l2 d" n+ X, ~4 ^: Y### have the same password database, and vice versa. The default realm
0 e' {, g, [3 L& k2 F/ F5 i4 @! j0 {### is repository's uuid.
7 v' w( ]% r* d7 _+ Grealm = My First Repository
4 `6 ^) |$ |+ `- H 瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn
5 ]9 O; Q2 Y* V6 @2 e #killall svnserve //甇- O9 s; T/ y5 x( X! ?
敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx
. ^/ R- F8 C8 S$ y 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/web9 L& f9 k3 F G/ n6 k2 D% H. _
b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐 - S# P# ]/ J8 G1 M7 E% n+ e, \
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" :
% G. A& q! P0 g#system-config-securitylevel 豢DISABLE敺OK嚗敹璈 c( x4 z) s& J" l8 Y/ O% v6 T9 N8 w( N
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急 vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled & s! c. i" [7 {) H+ {) [
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
" s/ G+ h3 P+ i# Y) y |