: http://blog.csdn.net/yanzi1225627/article/details/49123659
5 P: s4 U" P0 x |6 O% D" z, v: @
6 q. `, ^5 u5 Y/ C6 g格嚗剖遣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+ e# V5 J( B9 D+ o) W0 Y1 r
湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx4 z& \4 m3 C J9 Y$ Y
嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www. A# m1 H- @- u" m- ?2 o
/usr/sbin/useradd M -s /sbin/nologin -g www www //-M 銝撱箇雿輻刻桅 nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具 chmod 755 /etc/init.d/nginx( r1 Q$ _6 I* E" U& Z2 F
3 T2 L( ^2 ^, O. s& X: j1 N* x0 N N4 cchkconfig --add nginx7 D. K v' d* V m# E* V* P, j
: ?* n0 c6 A# o# `0 G
chkconfig nginx on7 {; q, g) | A4 u& M
嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash
% M5 ~6 Z) L+ U) p& J4 N# Y9 j' W7 F# nginx Startup script for the Nginx HTTP Server/ @4 N0 B8 O c. A" q- Z+ `4 f
# it is v.0.0.2 version.
2 e) x/ Q! Z2 y0 I6 @# \# chkconfig: - 85 15
# N& x# Z+ i" Q; u0 }7 d. N8 M& z4 o$ f# description: Nginx is a high-performance web and proxy server.
7 _4 j0 n% Z$ g2 w7 a# It has a lot of features, but it's not for everyone.
. i3 B7 Q, Y$ |" R1 L# processname: nginx) b& ]( {! R" n; u; ^
# pidfile: /var/run/nginx.pid
# N" s8 M% q. ^7 R/ k b8 E# config: /usr/local/nginx/conf/nginx.conf
" E# s' O& f: B$ J, e5 Vnginxd=/www/nginx/sbin/nginx
5 v( d% I8 G* C! Y2 V8 {6 znginx_config=/www/nginx/conf/nginx.conf/ Z% M% v' v1 b) P6 H" ~
nginx_pid=/www/nginx/logs/nginx.pid
) }5 Z+ S) W, K* J! P" JRETVAL=0
9 c1 O8 f% L3 E8 u h8 bprog="nginx"4 I) \$ `1 s$ W8 E6 ^7 [
# Source function library.
4 O' R$ j: I. H! m9 v+ `. /etc/rc.d/init.d/functions2 N$ L5 U9 u! ?. O9 V9 I
# Source networking configuration.
) D: l* s, b+ c/ R* {9 U* u; ^. /etc/sysconfig/network
" ~, r7 q' T1 u# C2 s& q0 t# ]! O# Check that networking is up.# g! O9 `/ s! A+ n$ V; R3 m$ V0 R5 g
[ ${NETWORKING} = "no" ] && exit 0
; N' \8 G9 [6 J[ -x $nginxd ] || exit 0' ]; w' c8 l2 Z
# Start nginx daemons functions.
8 S" `2 h$ [6 K; Y. zstart() {
' j2 n$ i! n: F9 F! ?if [ -e $nginx_pid ];then
# A- W( J% @8 I; Qecho "nginx already running...."- ]: t' A7 ~* J% w Z
exit 11 S. }' Y% O0 X( s- O: G
fi
( C, q# n* |8 G3 m uecho -n $"Starting $prog: "+ c1 G2 z( Z) y& k4 [; i2 K
daemon $nginxd -c ${nginx_config}
% b3 w/ V8 C* g( w0 {7 qRETVAL=$?6 ?) U" J- K/ I M: `! `
echo
: G1 ?5 |$ i7 C9 M7 X[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
* W9 D7 {: B' O* Wreturn $RETVAL, }1 U9 ~; t; b% G+ m
}
( B! Z& v/ R9 |# Stop nginx daemons functions.4 r" r% ^% }1 b1 @ b
stop() {8 c) D6 z; I1 O5 S
echo -n $"Stopping $prog: "8 j/ w E1 |+ i6 Q) L" ? G
killproc $nginxd
* D% v( L4 r1 \! M6 _2 Q$ DRETVAL=$?. p' R) A- U- I! P) }; I3 t/ p
echo
+ }9 ^6 @% R1 W9 A[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
* c8 M2 A6 [* y+ r}8 T5 a3 |/ G/ F
reload() {6 f' r F( y$ u- V# \
echo -n $"Reloading $prog: "9 h4 [$ y7 g8 F0 b3 `
#kill -HUP `cat ${nginx_pid}`
( B& D8 E% T. F/ d( Jkillproc $nginxd -HUP
; Y$ C' n1 |! b4 X9 R* ]/ n. @; zRETVAL=$?
1 |% h2 M( ^' aecho
% y) D& R& P; z/ k* _) v}
; B+ D5 T+ s' S0 I0 E1 V# See how we were called.2 p4 r$ {9 u8 }* B1 }
case "$1" in
( q) x* j* H4 Istart)
# Z/ ]* ], N" p1 P mstart- G9 U- a2 B) T' v2 b" ]
;;1 \: ?. g' e0 h1 R
stop)
! v6 Y+ C! O( S* \, }0 }stop
* W' T0 o- K4 n0 O( t( ?;;8 P/ C) h% V" u
reload)& F* D: k7 ]( I4 B, b: X" h
reload
7 Y! C6 K# f8 w7 i5 };;8 v7 b5 X5 R. f) w/ {
restart); v3 ], ]% a B# }3 ]" A
stop
6 C- P& U) `& N& O2 S+ [$ D% Gstart( U7 P& v, P* ]- Z
;;5 Z7 x7 P0 ~ b4 ]. S" q$ [! K+ T, T
status)+ f* @- d5 T l6 |4 U$ S
status $prog! ]3 c/ X. z: P8 [& @
RETVAL=$?8 C( y' d0 V/ B4 Q' p
;;
6 k0 F) V. q& h2 c6 @*)
0 X1 d5 p5 g& \$ b# Aecho $"Usage: $prog {start|stop|restart|reload|status|help}"- v1 E9 O# w: E* k% A6 A
exit 11 G M+ g G) n) g: J- U
esac
( N' J; P5 g, {) P2 F# wexit $RETVAL1 F$ E0 f" x6 |) r; i: H
4 z1 C9 N: o5 U E
瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬 3 G( \) B# ]2 t# e
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
9 f+ u5 M1 N9 h1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠
& Y7 P8 k+ o" P* }" q8 D" d location / {
$ x* U) \" K' @* e2 i root html;
' E$ z p, P) \. q index index.php index.html index.htm;2 p! t$ U6 J0 s0 D7 M
}4 K6 Y! M/ G1 U; y9 F+ p7 }. {* _6 b j
靽格嫣蛹嚗
/ o3 |- t+ `' Y# f+ m% b m) T3 M$ w$ F& s
location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
# Y. E7 Q6 D2 r* I* u1 I4 b4 [/ Xlocation ~ \.php$ {' }8 _/ J4 d4 G3 ~) |
root html;+ o2 @! y5 u# U% d& H
fastcgi_pass 127.0.0.1:9000;
/ x: S+ n, V5 _; s7 t) ?$ A0 r fastcgi_index index.php;
$ a- r. `$ u) w& [, F fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;; t# i" ^" N9 h: U
include fastcgi_params;
1 j6 A' |$ L9 r7 x }
; _. j5 ~: d; w. A% L8 M靽格嫣蛹嚗
+ ?7 }& g* h ~2 o, M
! ?0 v L3 [. 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閫蝻拙僎餈唳桀嚗扯嚗
' m3 w' m8 m' N8 R+ p# f8 Z: D5 l2 q#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql( ]0 q$ n" m3 }9 d5 L0 _. J# C8 r8 N5 s
3 K' [' [$ {9 Y: r- C" I#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
. z/ G9 S7 B" G1 t4 ]8 z4 |. T 扯 cat /etc/passwd 亦冽瑕銵
0 l0 p- R+ {, }$ l0 @( A2 S- h* Icat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀& T* C% _1 y4 t
3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql* _& s2 A1 q, S
4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql
/ H, X0 ^- j5 `chkconfig mysql on
; \2 h4 V0 d8 X8 B7 ]service mysql start --臬決ySQL& l# Z3 x# G- n0 D1 j) F6 {+ x
5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH% I# F3 F1 v% A/ I# {. h+ S
export PATH7 F$ i7 \! q% d4 m% n4 n
靽摮source /etc/profile 扯嚗
/ K6 e5 u4 H7 `8 j. V8 Y( [mysql -uroot mysql> SET PASSWORD = PASSWORD('root');
% F, o7 }4 h9 S6 r' r- w) k/ g
6 }( j, [5 T3 [9 @( N霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗
& a* M0 f( c) h$ Ymysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗
2 L1 G$ V2 ^7 [6 ^#./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嚗
# X9 a! g: p: U* ?$ v/ l! {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
1 J$ |8 O: k9 M% b3 }
" |; _6 u' E8 C) e5 |' B) prpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm& i9 K0 n8 o' T+ \) w/ ~
Create /etc/yum.repos.d/php-fpm.repo file and add:
" A4 J8 \7 a. h+ K- [nginx] O: a- T4 R6 }9 t; L) U
- name=nginx repo* K* A; ? O+ u6 ]( M
- baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
q9 i3 b$ K E - gpgcheck=0 U# B% X6 n% _! V: _9 u
- enabled=1
銴鋆賭誨蝣
1 f7 Y* G5 b- s- A& Oyum --enablerepo=remi,remi-test install php-fpm, A! G, k7 N* {% k5 @& {; }
2 a$ A, X- o5 J7 }
) G" M. G! B' y鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn
0 G# c0 o: K' d3 Y9 t" k 嚗yum remove subversion //貉蝸雿祉svn% R+ q, C6 w$ L$ w/ U
# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn
3 [! {1 e5 K) j7 z' z1 R1 ^9 ]: K 餈# 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]" y0 y0 ]# Z5 c/ A* ]9 K
# harry = harryssecret
8 O, A! o3 C6 ]$ u4 C @# sally = sallyssecret9 Z3 H( C. V/ Q4 o5 |9 h3 _
wangning=wangning% O, J# K: U) o7 H0 s
yanzi=yanzi
3 T2 \) ~$ I- H# T* P9 o9 p% B #vim authz //霈曄蔭
+ a; R' b+ E; \1 b[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none7 @$ B# D% c5 T0 j5 U: I. |; v9 \, X
auth-access = write7 c. E+ m& @3 T; S
### The password-db option controls the location of the password
2 k, D% E5 V/ H6 F) x0 F0 i### database file. Unless you specify a path starting with a /,
# L# M* N- L& C### the file's location is relative to the directory containing. H5 h, k @, X9 D
### this configuration file.+ H: s# l. x7 h' s, z( g1 C
### If SASL is enabled (see below), this file will NOT be used.
. k6 I/ _/ i& K a- U: G### Uncomment the line below to use the default password file.
* l) p2 q- c9 m* Epassword-db = passwd
- J- Q0 W! L1 w4 [### The authz-db option controls the location of the authorization
. C4 N, v; b1 L& t3 Y, |, Q: {### rules for path-based access control. Unless you specify a path
' o2 Q0 i( r) W3 U" S### starting with a /, the file's location is relative to the the" E% W$ e0 O' w2 H+ C
### directory containing this file. If you don't specify an- @1 z% ?3 Z" d( x
### authz-db, no path-based access control is done.1 l" y) y6 G9 @" V" V2 p Q' K( r
### Uncomment the line below to use the default authorization file.
7 A* n+ r: ? c& Q# q' jauthz-db = authz1 ~+ K; v# ?/ s0 c
### This option specifies the authentication realm of the repository." E r2 P) K& \ \7 \
### If two repositories have the same authentication realm, they should
- W8 e7 @& U- z! H9 B. N& l: R) ?### have the same password database, and vice versa. The default realm7 Y. e4 C4 K: r- \! U; }9 v0 M
### is repository's uuid.- ^* R& F5 D0 D( S' v! n
realm = My First Repository4 r5 S/ _2 W+ g* d1 }5 f8 I, ^
瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn
6 s0 b H: G `, p #killall svnserve //甇8 A" {/ ?9 r6 y# Q, S# z
敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx; e# I* U" M! [# V6 b+ x* d* E
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
8 H Z+ D% u& S6 A- A. {1 z, O$ } b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐 * Y) ?, n% T4 r
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" :
& z& `# G6 N/ u#system-config-securitylevel 豢DISABLE敺OK嚗敹璈 , }/ s) R$ A" l, { h" S' y8 m
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急 vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled ; P3 b. C2 w& C: n. X$ \
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿2 y U* v- g* R+ ~* P+ b9 f" K! U
|