: http://blog.csdn.net/yanzi1225627/article/details/49123659
" @; Z8 k0 H% j% v; \
+ I& I/ |+ D0 B6 U$ M格嚗剖遣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 cmake6 ~4 \) O* `5 i a: S* r
湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx+ c6 A9 ]$ L" T) u) u7 s4 H% j
嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www; q- K0 J: Q- E* 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
3 a. w3 X) j8 |" d) _% z/ [5 ^
4 P8 X7 z( D' {4 r6 Tchkconfig --add nginx
3 C/ g1 g! a) |- V0 W0 b& k$ I* h" P8 l+ ]& b2 h& ~
chkconfig nginx on
" D* u& |& | p 嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash7 @) [2 V2 |$ E/ E5 _
# nginx Startup script for the Nginx HTTP Server
& s; z$ v4 s, w9 u# it is v.0.0.2 version.
6 W% j9 c: V6 K$ Y3 u# chkconfig: - 85 15' I) D5 w i9 I' t1 Q( m$ e
# description: Nginx is a high-performance web and proxy server.; @2 y9 k a% E5 [; g* B- X
# It has a lot of features, but it's not for everyone.$ Z: l+ `% W* f: u6 g }; x
# processname: nginx: d( g0 ^' V4 }8 w/ j
# pidfile: /var/run/nginx.pid
3 l' [+ t& K8 u" y% b. r4 ]# config: /usr/local/nginx/conf/nginx.conf$ X( L \/ g8 X
nginxd=/www/nginx/sbin/nginx5 O3 I' ]$ b3 E) f
nginx_config=/www/nginx/conf/nginx.conf
! p0 H- g6 \: r4 a9 |nginx_pid=/www/nginx/logs/nginx.pid V! j) Y- c; g F/ @
RETVAL=0
0 y* b9 A* F2 Pprog="nginx"
5 m% L5 ]- G. r) [8 k, }# Source function library.
; k* M3 X: E' _9 [$ U+ a/ P+ q. /etc/rc.d/init.d/functions8 H; }2 M7 |: \4 D$ Y: l+ _6 I
# Source networking configuration.1 R: l9 [2 |" [7 B) C
. /etc/sysconfig/network$ g$ ^8 \# n: Z# S1 w
# Check that networking is up.
: }1 C/ y) P7 k[ ${NETWORKING} = "no" ] && exit 01 h; F; N# [5 Y3 j/ R
[ -x $nginxd ] || exit 0# r8 m7 d6 L* P/ c+ |: [ G% C
# Start nginx daemons functions.: }0 G8 J5 v1 M5 d+ y" \- L! u7 u+ K
start() {0 V+ a9 X. ~3 c1 s. \" F8 L
if [ -e $nginx_pid ];then
; f5 n, b2 w8 @. M. techo "nginx already running...."
! P5 X9 G8 m) n7 Pexit 1% M/ h% i+ Y6 Y C. u+ {
fi% ~+ G# O5 m, A7 q; I
echo -n $"Starting $prog: "- ?6 @9 r* ~+ Z/ T+ A
daemon $nginxd -c ${nginx_config}
: D% ?+ e$ \ r7 H: v7 A/ URETVAL=$?% |- W& n% `$ t$ F+ O
echo
0 c" r7 ]0 y1 @" C1 p" s$ a[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx! W j" t5 z7 o w$ g1 O
return $RETVAL
1 T- a3 `, V+ p}% }7 [% V3 d5 ^; z0 v8 l2 b' k
# Stop nginx daemons functions.- i; C5 z6 A" \( L
stop() {
9 y: ^3 c- z6 |, S. k4 _! I& jecho -n $"Stopping $prog: "
& p4 T/ G8 R- ]; Dkillproc $nginxd( ]6 \2 w: d2 _1 Y: X
RETVAL=$?# L9 g1 S0 K# l; p
echo" w) B& Z8 U N# O0 K; H% t' N
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid; Q a s* _, h0 s* ?8 ?
}8 g" }. Y; U' D D3 h
reload() {+ P( l9 \3 u- ^" g2 B/ S
echo -n $"Reloading $prog: ": L( g7 e$ P; u3 g2 y J7 }
#kill -HUP `cat ${nginx_pid}`! D/ L2 ]$ C7 q! p6 w/ D# R# J
killproc $nginxd -HUP& g0 g. R7 | X$ t3 A0 S
RETVAL=$?9 h: m& `/ S$ S; C
echo8 B( B& @3 P& Y
}4 |! f) C' x6 B
# See how we were called.
7 }, v8 T! B; A; q4 {$ r3 Bcase "$1" in- H8 P: V1 {" ?" H
start)
( U6 s6 O2 q" D3 N2 y9 Xstart+ ]6 y6 N. Z" p$ \9 {
;;
0 S% L; q. L) \3 A: kstop)' G5 Z0 w, @4 d% z% |( q% |9 L, s- n
stop
* t2 w/ }: B/ z7 I6 C2 L0 o8 r( D5 p0 x/ `;;% m& S# k* g% k0 K8 e+ N0 _) @
reload). B W$ f3 |1 J' M3 Z7 u
reload- K: f/ l6 }4 B1 W0 ]
;;9 x; x1 O2 q p1 v& Y; a5 ?
restart)
! L1 w7 F3 D% h5 W& e' ?1 Estop
# Z" K7 i) R4 d8 d1 A, P6 g$ Lstart
7 {) P: W0 N1 b;;
, w+ p% C) S; ^: }# R$ istatus)
: ~1 l. z! ]7 {/ zstatus $prog
& W- B, Q- s3 X( m5 gRETVAL=$?
" j5 \! W) F4 S- O+ r;;9 }3 C; o0 G, `8 j8 N
*)
8 S+ a' F9 a5 hecho $"Usage: $prog {start|stop|restart|reload|status|help}"
7 I, } n6 T6 c7 v9 s1 Gexit 13 g) M. ]4 j, q$ ~) Q' d5 s' _" h2 u4 E
esac
) E" t! T& |( J3 o. N/ L3 _& mexit $RETVAL8 v) G8 F) }; S8 D% ^& W1 @* u
4 F6 X$ t/ D3 S! M
瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬
8 d; p" u! i, r6 {chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
& V& C8 B3 D" G& B9 @1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠
6 E- W, D+ C7 V location / {- V+ {& E* c4 e# ~% h+ k, R9 \' n, I
root html;
, b% J( E3 |3 F/ T4 w3 D0 R index index.php index.html index.htm;
/ Q+ n+ D- Z8 [; k; f6 v4 Y: E }9 A& S2 t# g8 A! P) m
靽格嫣蛹嚗
- D( o& ]) l& V4 o
5 ]5 l4 `9 ?" z' Y0 w+ w, X0 r! j location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
: U0 Q0 D3 ~! J& ]: R3 Y, A% k; g: Olocation ~ \.php$ {3 r- D1 A. l! t J- E' @5 t0 d4 q
root html;% j5 }. {( U1 E* i* l
fastcgi_pass 127.0.0.1:9000;4 Y8 P" V7 p Y9 }1 ?
fastcgi_index index.php;
$ P7 _+ e% K, l0 I fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;2 t, A0 p; l2 w! ^
include fastcgi_params;. s& G0 b) Z( i1 z. }
}
& ]( Z& f5 X7 z+ P. I+ N靽格嫣蛹嚗# G0 l* v+ H6 Y" G1 k8 [9 |' D/ P1 ?
8 E$ p# ]7 |; p6 y9 R; Q+ R
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閫蝻拙僎餈唳桀嚗扯嚗 `4 |" U" b8 z) T, ^5 f
#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql5 K9 H) T" }+ `$ X5 r
! f0 G2 \2 [. e, W#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏: Z. x; i, ]% q# m
扯 cat /etc/passwd 亦冽瑕銵" B( l' @3 u8 A% B: H' K- X5 a8 W
cat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀: z* Z4 V7 r* Y( c
3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql: d+ X" b' ~" d! r9 G( R
4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql. d3 i$ T) s* W6 U5 E5 d& w( e1 g
chkconfig mysql on6 N# B2 P$ n/ \( Y7 P
service mysql start --臬決ySQL6 Y% f9 Z8 ~( L% ~% c
5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH; D7 Z+ p9 Y1 T9 I7 ^$ r) U; f- x
export PATH: J! m6 s% o1 o7 ~
靽摮source /etc/profile 扯嚗
) Y- L+ a' u# \% u$ jmysql -uroot mysql> SET PASSWORD = PASSWORD('root');% ^/ H P+ u9 q h+ {/ {+ `5 \) W0 H
. E, q; E5 W, @/ l8 C5 A2 b' ~9 D' k
霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗 6 p, e" N8 C& A4 w- S
mysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗
. K+ s0 k9 i, q#./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嚗 2 _2 V/ `/ n8 `5 }
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! z. m& m8 O- v/ O% [1 D
# T5 N" |1 {( S9 q* drpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm* d8 I/ \) w( f; t/ @/ m+ v
Create /etc/yum.repos.d/php-fpm.repo file and add:
% }- }7 ?7 {. W- [nginx]; L3 Y; R# L% K* R
- name=nginx repo
" [/ [3 N5 _/ B - baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
) L* X3 R5 p7 Z1 i - gpgcheck=0
# u. W5 l5 \! k5 N7 a# } - enabled=1
銴鋆賭誨蝣 : n* y% F$ o0 ? L& R/ P
yum --enablerepo=remi,remi-test install php-fpm( Z2 E* ^; m, e2 e9 }. r" n
( q0 W" ^' ^$ q3 @/ T" Z* ]$ Z6 T9 R- y/ N
鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn w/ z8 x3 |7 b5 x' _; d
嚗yum remove subversion //貉蝸雿祉svn, C$ g7 i1 |; L. I, S7 [# P9 N
# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn
# u3 W( G/ A; c2 r% C& Z6 n 餈# 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 K( {4 E0 L# c. }0 j
# harry = harryssecret0 _9 b* r( n# m/ ^# B
# sally = sallyssecret
! Q6 a3 f" a+ M/ E" W1 ?) `- zwangning=wangning/ B3 |- O5 e. G3 K5 P+ q
yanzi=yanzi
* R" u( z, _) K- r; U: ~8 R #vim authz //霈曄蔭 ; r! Y/ o6 y0 o
[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none t2 \2 ]# m3 E! ^' W3 h
auth-access = write- S) O, n1 O9 M) H
### The password-db option controls the location of the password I0 I1 q% h! E5 H1 S
### database file. Unless you specify a path starting with a /,! J5 B$ Y* i& m' h; x" ?& f- K
### the file's location is relative to the directory containing6 J+ T% ~9 P1 C u3 ^& g
### this configuration file. _/ N$ o/ ~2 C; ]' }
### If SASL is enabled (see below), this file will NOT be used.
( T. B L, Q1 s, @. x3 g" t/ e### Uncomment the line below to use the default password file.
" k2 ]" e7 D' }# J w7 Cpassword-db = passwd8 c" Z% e4 A- S2 J, r
### The authz-db option controls the location of the authorization e P; T. F& F" u8 V
### rules for path-based access control. Unless you specify a path: _/ J$ [: n+ w; i+ t, L/ A
### starting with a /, the file's location is relative to the the# V! R- o$ y" L
### directory containing this file. If you don't specify an; I% O u6 K$ Q0 ~( K
### authz-db, no path-based access control is done.4 A' Q P! p% g! G
### Uncomment the line below to use the default authorization file.
; p8 l9 D6 k' F2 l$ L7 O0 Oauthz-db = authz [/ } a" b3 V: K+ T
### This option specifies the authentication realm of the repository.
6 x4 V2 l# Z, j0 b% S6 I### If two repositories have the same authentication realm, they should
1 `( a6 q0 E2 o1 \( y# _$ E7 l### have the same password database, and vice versa. The default realm( ~" y9 G% B6 G: e
### is repository's uuid.
c3 Y8 Y2 F, `1 | Srealm = My First Repository
. u; I* f l; g3 ?0 W: [* T 瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn8 I" x5 M! k7 p7 Z9 j( y, o
#killall svnserve //甇
9 c- E1 h; o0 N; e( [2 i 敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx) O8 K( S$ f; _& i& i9 H
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+ W7 D. [0 V3 }7 U& q7 F
b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐 : q) J6 ]' z% \
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" :& W/ t+ K" b ^$ b- @; ]: n& X) W
#system-config-securitylevel 豢DISABLE敺OK嚗敹璈
# I( d7 q! {0 w- D# ?- B1 W瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急
vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled q% e& W* Q2 I
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿7 W# I" D& C) h4 x2 ]+ e
|