: http://blog.csdn.net/yanzi1225627/article/details/49123659
! I, m" J9 C- @0 ]4 ?5 i! `9 B f f" _
格嚗剖遣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 cmake8 v* y i4 z6 l9 D3 w$ ^ Z
湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx
& `8 Z0 F5 k0 p/ Y 嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www
4 }7 Q5 G, D. F$ N9 I7 r- w0 N, u0 F/usr/sbin/useradd M -s /sbin/nologin -g www www //-M 銝撱箇雿輻刻桅 nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具 chmod 755 /etc/init.d/nginx
' q9 a# Q$ r; T" E' I2 [8 y4 e$ O# c N2 V! Z W- S' O5 @3 C& O6 w
chkconfig --add nginx
, ]& V" {2 S) d8 u9 ~8 F% ~$ d M/ w( r3 f" ?! w8 U
chkconfig nginx on
+ c( b. k" a9 v1 A2 X 嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash
b. g2 ~5 H# s# b3 Z2 m: m# nginx Startup script for the Nginx HTTP Server
: k5 `7 L' u- ^; r* ~' H7 b# it is v.0.0.2 version. z( h! v0 q1 N. m* X3 e
# chkconfig: - 85 156 N) ~- P! ?$ x j: R& Z% Y4 q) m0 T0 a
# description: Nginx is a high-performance web and proxy server.
3 q9 N' s* R: y# It has a lot of features, but it's not for everyone.
; a4 ~ F0 x0 Z. v2 F- s9 d& S# processname: nginx
3 \3 P0 j1 ]% R3 d* b3 J4 l# pidfile: /var/run/nginx.pid l' l. `' ], b( \
# config: /usr/local/nginx/conf/nginx.conf- p) L2 [' J$ J4 d
nginxd=/www/nginx/sbin/nginx
1 F4 ^4 o5 D3 Xnginx_config=/www/nginx/conf/nginx.conf
# h7 A. ?- ~4 G( g. Ynginx_pid=/www/nginx/logs/nginx.pid
6 I7 q( @' _+ [0 _RETVAL=0
1 I0 b/ s# n: [& }4 sprog="nginx"
' D3 j# Y; L6 Q0 d( _( E& R9 L3 j# Source function library.$ y: K. w5 l. x( i( R; c, `. S
. /etc/rc.d/init.d/functions/ o+ \; v* {8 T" ?. T: l) v, J
# Source networking configuration.
2 x" r# d6 `5 |6 D. /etc/sysconfig/network
# ^0 w" H7 e, v* N- p" K7 M( y# Check that networking is up.
1 r N, P8 h2 V& g[ ${NETWORKING} = "no" ] && exit 0) }. B* y0 [& j0 u
[ -x $nginxd ] || exit 0
7 B6 B% T/ t7 d7 E# Start nginx daemons functions.% N/ N- c3 p) Y, d5 h8 t& U
start() {' R" P* T# {. _
if [ -e $nginx_pid ];then
7 a, _6 N7 H7 eecho "nginx already running...."
# W' e, a6 M8 A6 eexit 1
0 Y* t* A2 I2 z6 N! S+ V9 Ffi
& N, R) Y* `5 ~: uecho -n $"Starting $prog: " S& r1 Y; \$ ]5 w4 h: q( |3 [
daemon $nginxd -c ${nginx_config}; y. Y8 P3 D6 v- v: x+ a; Q
RETVAL=$?
% P) F+ R" x4 N0 Hecho7 Y; {+ S: k) w& U. S' k
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx" Z1 f4 m4 Z5 c6 f0 {
return $RETVAL' v* O. x/ Q1 y
}
* W8 K/ C/ S. m8 L* H1 H+ Z9 u# Stop nginx daemons functions.+ v# ]7 w U: v9 q( m
stop() {1 R9 Q. [" @3 F4 M
echo -n $"Stopping $prog: "
6 S; } s+ E3 n8 b8 Gkillproc $nginxd
; }$ I. C3 v5 a$ x- ARETVAL=$?
3 y0 V' {. x4 q0 e6 becho) d' t* `5 }5 j# f
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid6 o' ]+ t9 s7 B; B3 ~" ~
}* }) f) F7 |8 G
reload() {6 u3 I$ c5 |$ z% ?8 n# u F
echo -n $"Reloading $prog: "$ L# y: g) m9 T$ u3 K/ f8 X
#kill -HUP `cat ${nginx_pid}`; A! q6 f/ ?1 j+ U2 B
killproc $nginxd -HUP
9 x( ^$ M! L" h2 g1 o# JRETVAL=$?
% V6 |5 z+ Y5 Z [/ w& Vecho o$ S+ J4 }% ]
}
V4 C$ P3 t) I- h- U9 j( C! z# See how we were called.
9 o4 x* t6 j Y0 ^) U& K) _+ fcase "$1" in1 w7 E8 U5 O8 u" F
start)
. s7 B4 T4 e4 A. j4 [3 H2 D7 lstart, c9 O, J7 y/ S2 o. y4 v
;;
8 ]9 j* F; E; p! S% Bstop)% R( B* G! c4 r
stop' Y+ N/ Q! u* H# M4 G4 r+ O- n
;;
4 u4 O* f* O; M1 K9 Dreload)
2 ?1 X+ e: {' ~reload* U# M) F- |; W, Y) ~3 f/ h( d8 Y
;;' s4 v4 Y2 H, p' }
restart)( a& S$ E8 P+ W" O5 N8 z
stop7 i( o' l; Q. x$ z* {. D. T- }6 ~
start# b! ?4 J* I1 q0 e
;;
- P( s; b( R; `. ~& @$ j" Zstatus)/ A( G* w/ P4 R4 d) r8 P2 Y
status $prog& @) o' W. z, [8 I# m5 M' Z: }6 s
RETVAL=$?
* y, c z, u0 l* s;;2 p7 d, P j# \& t9 D' G" x
*)# U: o _/ J* ]0 r1 _* |, F `
echo $"Usage: $prog {start|stop|restart|reload|status|help}"- P0 q# |& ~+ y: W% N9 |$ S" v
exit 1
! G: C' s2 K* w6 eesac
$ y) U6 q! n/ p7 v# ]" @0 V: ~exit $RETVAL8 i' P' ?9 R/ P, }
& e) b& ~4 Z' \! Q4 L. S2 j9 x 瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬 $ ~' i4 C) |7 A( ~( n1 p3 Z4 g
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
% m* N+ m! {2 L3 k/ `1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠
' c7 @) j& S. `* P" F0 M Z location / {
" W" \8 t M) j2 ]$ Z9 B, N- H0 e6 B root html;) y6 i/ q0 I- N
index index.php index.html index.htm;8 l0 H$ E/ G; V( T
}7 v t& A/ D. M' p8 N
靽格嫣蛹嚗
: O& \" N8 h! ]% U+ N( ^+ ~
+ b* g) H* y4 g x: L; Y location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
6 s- w e& y) i1 A# glocation ~ \.php$ {
! c; r! O4 v7 P1 O, P root html;
) y( n* \2 F3 L fastcgi_pass 127.0.0.1:9000;$ B; W9 W- ` W
fastcgi_index index.php;* Q: L+ A1 r/ k: N- ^$ `7 y9 Y
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
" {9 q$ I6 P9 b; G include fastcgi_params;. A/ J$ |( ^3 |4 g. |6 I
}" Z& v' n4 P1 d
靽格嫣蛹嚗. `+ h; B7 L$ R+ m& E# R
i0 c/ h- S8 x# g- n5 e3 G3 K
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閫蝻拙僎餈唳桀嚗扯嚗
3 Y; i( E3 Y* o5 G7 ~2 J$ C# r#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql4 Q5 G' k5 D$ Q/ H4 J
i1 t* s, W9 t: k% a/ Z
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
9 @+ b& c6 ^* L6 T, v; U9 b# N& t 扯 cat /etc/passwd 亦冽瑕銵1 s9 T+ c8 U4 i' C9 Z& W6 L0 ?
cat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀/ U# }- J3 \7 h$ H& p" a' T: I
3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
0 _; g3 G) O+ N. b1 m 4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql
S ^' u6 E- E. ychkconfig mysql on6 ~) A# ~" w# h. p3 s. A/ c3 }
service mysql start --臬決ySQL9 F7 _9 l3 f) x; l0 X
5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH
6 ?* Q( q$ E( Qexport PATH8 q% c& B1 p% T; y
靽摮source /etc/profile 扯嚗
$ r1 [' [ h/ x) Z5 h: Xmysql -uroot mysql> SET PASSWORD = PASSWORD('root');& d0 R5 l' M3 H$ B! B1 P9 p3 K
% m3 x' z7 o/ w( I, C/ ]& @
霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗
9 Q; B2 t$ `5 u' W7 f9 R0 cmysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗 5 o8 x) P/ f/ s) \$ r; s
#./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嚗 % R- l# I* |2 ?( V$ o7 w* z9 z8 |
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
( f6 \7 ~" \8 ?" A" a' Q" q: Z D, H( |% t' z
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm" _7 G. U' \: f5 z9 r
Create /etc/yum.repos.d/php-fpm.repo file and add:
( y2 o9 J' C7 S1 @: K0 E- [nginx]7 l! W6 F, {- P
- name=nginx repo
8 ~: b# B! z; m/ {2 A! A: ]+ G' y - baseurl=http://nginx.org/packages/centos/$releasever/$basearch// k. K. i4 K- N7 _, |
- gpgcheck=0- U2 ^% {4 a/ _' `, k
- enabled=1
銴鋆賭誨蝣
& o z: x/ Q: @; p2 V7 d% s6 e9 S# X* lyum --enablerepo=remi,remi-test install php-fpm% L6 ~9 t0 `' X" [4 Q; _
+ V( l3 [8 X2 n5 x
; @6 R) x; I* u5 \) t! p: t( y鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn
. P1 v9 E7 n! @ H 嚗yum remove subversion //貉蝸雿祉svn
% `9 L- Y: [0 B( V' Q$ B # yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn
: l0 m% [: J( A1 p 餈# 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]" e3 |; h$ O3 Y8 Q' a; ^/ b3 A2 R
# harry = harryssecret9 G" N5 X- a3 C! D- B: _. ?1 U
# sally = sallyssecret
$ J S6 k/ p$ q8 X4 G8 G+ A Ewangning=wangning
, f) C1 o7 O% {, ?7 K- }0 _4 r; syanzi=yanzi
5 v: Y. K6 j* m% W #vim authz //霈曄蔭 " |* W9 l* {0 O3 P% f" X8 l/ z* @
[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none
; M# c# S v3 g( Wauth-access = write
$ Q! J, X6 P" k. Z' d8 Y% B0 T### The password-db option controls the location of the password
- R/ X1 D) r! w; {: t9 N### database file. Unless you specify a path starting with a /,$ Q+ i( ?$ D# w) }9 V; C' P5 b
### the file's location is relative to the directory containing E( }1 i$ V8 W- r: v
### this configuration file.$ B; d' L7 G; U9 A$ K2 Z+ _
### If SASL is enabled (see below), this file will NOT be used.
/ w$ n$ L4 P! R6 Z6 H### Uncomment the line below to use the default password file.: G$ n1 E. `/ _' S; E
password-db = passwd
# I' W4 B$ r8 ]4 A" C### The authz-db option controls the location of the authorization
/ s/ O( A7 k1 t: g+ G2 f3 c6 }### rules for path-based access control. Unless you specify a path1 ~9 v0 K! }8 k5 k
### starting with a /, the file's location is relative to the the
0 W* E% B/ u) l2 `8 D( O& S& H2 n- K### directory containing this file. If you don't specify an
! b0 {$ A1 \$ v/ O### authz-db, no path-based access control is done.; Q/ @/ J: J% E. P `+ v
### Uncomment the line below to use the default authorization file.* E+ z" v+ o8 n6 f P
authz-db = authz
8 B! w. T2 K( H6 p4 ~2 t! |### This option specifies the authentication realm of the repository.! t. ~: Z8 a' q: L9 ~! j4 |# Q; Z
### If two repositories have the same authentication realm, they should
& `* i0 v9 f! ^) r2 ^4 x### have the same password database, and vice versa. The default realm
! F: O8 n. ^ |" h### is repository's uuid.
9 e, B% E8 F$ L+ F% v& w' Arealm = My First Repository* l+ S& Z; s* O
瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn1 y' Y$ X0 ]- }1 W$ c/ `
#killall svnserve //甇
# \0 b+ `; ?7 x& q 敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx
" W0 @! U9 l& ?( ]' ` @( b: D 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
7 a& \: m& Z7 O5 h b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐 % m( z0 v# A, c2 t4 T/ B+ l" y! M) q
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" :- q: P$ j! [ L5 H6 s$ r0 g& y
#system-config-securitylevel 豢DISABLE敺OK嚗敹璈
! q0 f% {$ d+ y& u( l& K- D瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急
vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled
2 b/ K8 r. y3 q" avi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
+ E! d' ^' ], `+ K |