: http://blog.csdn.net/yanzi1225627/article/details/491236595 g9 A& t$ i# U3 {* b+ `
7 [3 J1 [ k% J: i) }: }格嚗剖遣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
+ x( @: u) q. _4 {4 J 湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx
- B/ D, ?* k* q0 z; ^9 E& o t* ` 嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www
& [8 l0 C+ l2 U6 E# H$ K0 h/usr/sbin/useradd M -s /sbin/nologin -g www www //-M 銝撱箇雿輻刻桅 nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具 chmod 755 /etc/init.d/nginx8 k- w4 _8 F% \
4 w2 i6 m2 V( n( k+ uchkconfig --add nginx
+ p0 v9 Q; E% I+ B2 E) L! ~9 t; F2 k9 N1 D- O. v' s
chkconfig nginx on
U, e% a7 e- U/ w4 c3 c! y0 w 嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash
- v' `7 ~% T4 p) f$ L# nginx Startup script for the Nginx HTTP Server
& n# o; g/ O; N) Y) y# it is v.0.0.2 version./ d2 P* ^: D) Z. \ N; y
# chkconfig: - 85 15
* O: }' Z- o, k5 C3 c* l. K6 I2 g# description: Nginx is a high-performance web and proxy server.* F2 Q+ ?" ]/ E
# It has a lot of features, but it's not for everyone.
: v* x7 v' p8 I3 r/ H* O# processname: nginx
. S, _) i& W H' \$ u9 \5 h# pidfile: /var/run/nginx.pid8 G; |- o5 M& K- F/ I6 E
# config: /usr/local/nginx/conf/nginx.conf
; Z" _% ?; B9 V" G1 |nginxd=/www/nginx/sbin/nginx7 k) _" p- Z J! ]! s+ z% g2 w0 S
nginx_config=/www/nginx/conf/nginx.conf: W3 q6 [+ Y4 G0 X8 p# U
nginx_pid=/www/nginx/logs/nginx.pid
$ G; p4 r0 a7 B( G5 [! `RETVAL=0
& {7 P, r3 X$ w9 O! l8 aprog="nginx"8 A8 E/ y, ^9 Z# S5 c# N
# Source function library.8 i0 L9 N2 Q. }3 U8 t M6 l" N
. /etc/rc.d/init.d/functions2 i5 ?$ W) p. p4 p
# Source networking configuration.2 W1 W- R+ |3 b N( w7 Z0 A. s! b
. /etc/sysconfig/network
- o j9 _! W, N1 ]6 B" _- {# Check that networking is up.% _7 T" Q( g' C1 s0 x/ z
[ ${NETWORKING} = "no" ] && exit 0
" f0 p0 m1 P4 X, P) G[ -x $nginxd ] || exit 0
0 j& x" Q. q" W4 r5 Q0 P# Start nginx daemons functions.% o! O3 J1 F) u
start() {
) f1 A$ b6 n1 Z9 h6 G7 |if [ -e $nginx_pid ];then
9 y* d$ p& @1 M% `0 Cecho "nginx already running...."" V) H, Y0 d, @& e. Q9 H
exit 1& U4 x, R/ z. d0 ]8 o4 n, r. T& q- Q
fi
* P1 W, @) Q/ Y/ N# E0 m1 ?) kecho -n $"Starting $prog: "
- q9 H4 S+ n3 n5 J& p) f; W) D: [" `daemon $nginxd -c ${nginx_config}
7 \3 Y! X6 S/ i p' s) a8 \RETVAL=$?3 g1 ]# J" G! ~; H+ w) j4 D
echo
6 e% O! \1 V0 S/ Y# F[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
5 @' i- n' }+ a! g0 ereturn $RETVAL
. p- ^) {( g5 K+ k& z5 k}) G( m" V; a( q7 s7 I' T
# Stop nginx daemons functions.
7 Q3 f' c6 v8 Q6 dstop() {
- K4 o$ W& C; g) v yecho -n $"Stopping $prog: "
% k+ v$ r: Y8 |. kkillproc $nginxd8 D* R9 f$ p7 n# f% ^ s4 L+ v
RETVAL=$?; e3 M9 W' J: v( ^; T
echo3 z3 Q+ Z; n0 U) Z6 e, E/ k) c- Q
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
H3 \ U" M, q}
# f* R7 O% O/ Q9 |/ w1 Z# Freload() {4 @5 Y% ~ V3 f. l+ d
echo -n $"Reloading $prog: "
& p2 [/ |% U3 G2 h/ f" Y+ Q3 e#kill -HUP `cat ${nginx_pid}`2 b; Q2 N, _& ^# R, m
killproc $nginxd -HUP
$ l& D4 w( u$ R1 E3 D$ h0 r2 k3 d% NRETVAL=$?
' z& }) c7 E: A: Y* s/ P- Y& }echo
! x- H/ P; l- Q2 S, _# Q! _}
: N; `6 `" @0 G& H8 D) D# See how we were called.2 G4 Z* k0 y; ]2 ^
case "$1" in
, w9 O, o' z& z$ ], z& G) K3 ^start)
* r4 {8 K) V' v9 E B. ?0 H2 Qstart
1 c+ S' R3 T; n4 _" d;;
: w% b+ h5 U! y5 I; h4 X9 ] `& kstop)' U* |& L/ U7 i6 f
stop
6 { x: l% ^; }$ M [$ s' Z, U;;; H' ` [3 H! p$ t. u
reload)
- O5 {* A2 t1 I5 E+ K) nreload
1 S* X, C7 V. d B$ {1 d; `/ ];;
5 D L) S4 n. E! \; U. u' urestart)
; D, w1 r9 _7 D) [) rstop: {* Q2 |" l' H* b4 o
start& n/ H% L9 u: Z0 E: q, y5 S
;;. \" o0 V& x1 f) [
status)
. R) M- |. X+ h4 U ~0 kstatus $prog
. Y T$ f# E* `. C7 t6 ~RETVAL=$?
; j; m M' n- ^ L% r8 S c;;/ }2 \# g5 }" I5 l; a- `$ R! L
*)2 O2 E& ^2 F7 ^* h# Y
echo $"Usage: $prog {start|stop|restart|reload|status|help}"& b2 q/ J) ?, V$ X p! I; c! D
exit 1( ] @) y6 E2 f/ R+ |
esac
, Q* B! G v: s0 J' W- ?exit $RETVAL
& L0 w; `( F. ]7 u1 Z; h `6 |% J/ F4 W9 |$ R2 E3 Q* B, W$ T
瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬
6 G# n/ H8 l/ A5 ?6 i7 I& P; Gchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
0 P2 q/ z; |* v. A7 i; @0 P% O1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠
' \' I$ r) l" R+ A location / {
, z9 {" ?( ?! t2 h% \ root html;9 B: f. q$ l' G6 f7 P
index index.php index.html index.htm;
3 K% l: y# E6 \4 t s' y }
8 ^& d o) r+ n. y1 o靽格嫣蛹嚗5 o1 P2 E# j" ?* { S) i
2 W) ~) M5 c# P: @ N x8 t4 V location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠 # e1 T& s8 C! F! F5 m# y9 A0 y
location ~ \.php$ {
0 L/ p0 \0 H) |. Z root html;
9 J* r' G. P* Y+ D! J fastcgi_pass 127.0.0.1:9000;
3 D# S0 y# m# o* G2 D fastcgi_index index.php;1 S7 S4 T7 W% y# e7 H) ]2 @
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; x% H. E" q% W
include fastcgi_params;
9 m' I/ K* o' J& e# I5 F% j6 H, X }
1 E2 X" L" p( c K靽格嫣蛹嚗- w( I5 ^; v! d. K3 e+ J6 C$ }
) T. m; ^9 G: ?' W
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閫蝻拙僎餈唳桀嚗扯嚗 . m8 x# X. R7 F2 X4 }
#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql
' D+ r: g9 o4 ^9 c8 R0 z
1 D7 v2 J2 j; d( x c" D#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
, U" f {; V4 }7 d6 h2 ]% h/ l2 g 扯 cat /etc/passwd 亦冽瑕銵
1 C! \# T; z+ _cat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀+ z ] f) e, g) O/ @
3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
% X% d- @$ f' ~ 4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql4 f4 u H0 Y/ ~/ h$ l
chkconfig mysql on
' |- u1 }6 c: A3 xservice mysql start --臬決ySQL
5 M% q7 j& I% X4 Y7 g4 J7 i 5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH3 ?9 H3 y" Y% T$ Q
export PATH
$ d: I- R7 g( ~6 I P4 f6 @ 靽摮source /etc/profile 扯嚗
: s! C( C3 n, G E4 i7 Q% a! gmysql -uroot mysql> SET PASSWORD = PASSWORD('root');
' p3 N% h- F* A* O: y. D
3 ^. O% B+ h6 N! P! \- g霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗 " t/ M9 l; q- m* c8 m! a- r5 I
mysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗
# L, G5 ^& ]6 h/ L#./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嚗 9 _& x, G# X4 P d! U# ?
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) F7 }1 o. \; n; Q: t
8 ]' d1 U5 T( l) b) M; ?" drpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm/ Y2 M. i$ Q) ~- [% e# V
Create /etc/yum.repos.d/php-fpm.repo file and add:
$ |$ S. G7 O- b1 q, N* N1 F- [nginx]# l9 k. l1 x' H. i1 r
- name=nginx repo) X7 w& O. g- a9 | A
- baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
$ q3 q# @( v i6 J0 e0 g' g - gpgcheck=0
7 A, _$ a0 n- V( X - enabled=1
銴鋆賭誨蝣
* B: p1 ^3 Q0 _% C0 W. n6 Wyum --enablerepo=remi,remi-test install php-fpm
* y0 O9 g- q; n4 L; l8 ]1 E6 u6 Z
- _: U2 B: w+ e H/ o6 [鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn7 u! \' `" W$ ^
嚗yum remove subversion //貉蝸雿祉svn" r4 @* U7 X% |7 C! [2 |& \
# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn; O1 w/ I2 ~, j' I# |
餈# 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]
" U$ n5 x/ L& V K0 B+ F3 R0 R6 o- Q# harry = harryssecret3 Z. ~7 G0 s$ u0 H
# sally = sallyssecret
5 m4 V& C4 h; G5 S% X* M9 mwangning=wangning
0 `5 u, k2 U- c9 }) d1 |% d+ h' Ryanzi=yanzi/ i: S4 E1 Z4 i) o9 U
#vim authz //霈曄蔭 " H% q4 ]2 R% m+ ~6 u# q
[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none1 a2 Z9 ?; O4 }4 \1 _( `) d
auth-access = write
" g" ~ ?+ D# `' c# [9 x" y### The password-db option controls the location of the password$ \1 H- e6 h, i7 H+ s
### database file. Unless you specify a path starting with a /,
8 I3 }# ^& P) S5 y### the file's location is relative to the directory containing
' _: @* o0 ]# T8 n4 e### this configuration file./ G( { @5 t/ `# P8 V
### If SASL is enabled (see below), this file will NOT be used.3 i5 M H/ B& v z, Q9 _, p
### Uncomment the line below to use the default password file.
8 G+ b; v/ e" T, n! ppassword-db = passwd
% Z' L- o1 ^& N, @### The authz-db option controls the location of the authorization
- H& A, K/ s+ j2 |5 _) a### rules for path-based access control. Unless you specify a path1 w/ f* O! a- u6 X8 C8 h
### starting with a /, the file's location is relative to the the
3 A6 f. N9 Y! N! L8 L+ a* n### directory containing this file. If you don't specify an
. E7 J& l# X+ C8 K! V+ A### authz-db, no path-based access control is done.
) z4 l3 P% ^7 Z4 ?, [### Uncomment the line below to use the default authorization file.5 r! D6 S# h( i
authz-db = authz0 n% h4 u5 ^. B1 R) e( e
### This option specifies the authentication realm of the repository.' d9 A: j" x' Y% y6 I, |1 m1 P: T+ O
### If two repositories have the same authentication realm, they should8 f/ F$ c8 A, J; R
### have the same password database, and vice versa. The default realm% H8 F0 W0 l$ H: O, u$ U- K
### is repository's uuid.
% J1 ?9 V$ g6 ^0 }; {realm = My First Repository+ P' I- l- M; `6 h, }
瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn3 Y9 t* F) T2 X k/ u
#killall svnserve //甇 n: t( X) N# V5 P* ^, v8 K' A0 M9 ]
敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx4 f- y5 w, Y- h4 [8 {5 i
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/web1 b# L, j/ ^3 w4 D" R3 w+ K# ~
b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐 ( T0 ]* t$ S9 d" O
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" :
6 K, |5 ]4 N) O. E$ w" D4 U#system-config-securitylevel 豢DISABLE敺OK嚗敹璈
+ ~* K. l2 A: u' b, W% Y0 O瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急
vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled
1 h) @# A( e, p, k- {8 T2 ]( Wvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
5 f) O+ w+ E6 y' d |