: http://blog.csdn.net/yanzi1225627/article/details/49123659
* a5 z0 h$ U; i7 g: V1 `. c& ]" V( m8 }
格嚗剖遣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
" B1 S* q( X S) Z$ \. r5 I 湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx
0 Q. R4 @( i* D: `3 j 嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www
9 O/ w1 [9 {- [" {- e' 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
% `. P7 R. v3 `4 O9 o
/ L3 d/ b, f: }. o0 B3 ochkconfig --add nginx
8 ^2 H6 S4 j0 K( D$ i) O5 l6 v0 F5 ` c! N( K3 E) y$ p" a0 \
chkconfig nginx on
& ~; S* B4 ]% g0 b+ R, N4 N" l3 i9 | 嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash, H0 |+ i9 j4 A) q$ ]
# nginx Startup script for the Nginx HTTP Server4 j% p4 e$ E \1 e
# it is v.0.0.2 version.- P6 k* H0 F; o9 _, u
# chkconfig: - 85 15# n; A3 B$ w& S4 O- V3 I, y
# description: Nginx is a high-performance web and proxy server.' X. Y5 z* o+ y" V: O- P
# It has a lot of features, but it's not for everyone.
, P* b" P2 P* |4 x+ j( z, }7 J9 @# processname: nginx4 D5 @ ~6 E# [1 {5 N
# pidfile: /var/run/nginx.pid
1 \% H9 }+ {1 O2 Q# config: /usr/local/nginx/conf/nginx.conf
8 _: X5 T3 v7 p- b/ S7 D& Nnginxd=/www/nginx/sbin/nginx
! x- A+ Z6 z( |+ U- C4 W; q0 G6 Pnginx_config=/www/nginx/conf/nginx.conf
: J. b& p' O8 c9 P2 B3 C! Inginx_pid=/www/nginx/logs/nginx.pid
- U$ D: |5 x5 J3 m lRETVAL=0* O5 u5 y% q$ H
prog="nginx"9 ?# d0 G, p" f, G; X
# Source function library.
6 o: x+ \# X7 n" ^/ r. /etc/rc.d/init.d/functions
0 U+ y7 `" F: I( w- ?% H9 s# Source networking configuration.
h$ p& G: m/ [7 f0 k. /etc/sysconfig/network
5 Q/ I6 J6 O* m6 K) a2 N0 M# Check that networking is up.8 [& M; o) Y& j; \/ e
[ ${NETWORKING} = "no" ] && exit 02 z7 @! v, s9 U# q" q+ _
[ -x $nginxd ] || exit 0
# L3 P8 ~' P. @: ^9 u& x# Start nginx daemons functions.
0 o; J. @1 c" V- |. D3 ?start() {
; T; G9 I; \9 j( ~if [ -e $nginx_pid ];then
) `6 T$ Y* i. C0 i% `echo "nginx already running...."
" ~1 _; z, ~" Vexit 1& H7 a. \) r9 j' k' w
fi
* U3 U ]# g* k: A' y- P+ Recho -n $"Starting $prog: "
' w9 }& _% K/ r5 n% K! \daemon $nginxd -c ${nginx_config} P7 { u) M3 F6 _3 c: U0 s
RETVAL=$?6 I3 m# x4 Q7 {# h5 {
echo
+ X4 l5 P' K" {2 i6 B[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx, K9 K. }, t- E) f, [1 t* A M% ^) A
return $RETVAL2 z. \1 J. m# T6 _& U" Y
}
( t8 j% _: x4 t2 c1 [# Stop nginx daemons functions.
! z- K" S4 Z# C& s+ F- @stop() {
3 B" V2 @! r" V, l& s0 hecho -n $"Stopping $prog: "
; X) p! ]3 p: }$ U3 o3 Qkillproc $nginxd
: R- ^" M7 r1 H# g( s7 ^- y1 PRETVAL=$?
1 [$ q4 P& @7 x7 [. ?! W! |echo# N0 x9 v; H: Y {' \. O5 _
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
# r! M- h4 k- F- u7 G}6 u. }1 W/ T! F0 M1 p* D+ p
reload() {
5 y) R! D. g; n, P& f C* \6 decho -n $"Reloading $prog: "
# i7 A; o7 T5 N( g4 k {#kill -HUP `cat ${nginx_pid}`
# A1 x8 n$ D' X! l+ b8 Vkillproc $nginxd -HUP
$ C7 f5 n1 c0 `% ^6 a' r9 j) hRETVAL=$?1 W2 }9 L$ i7 ~2 i* [ O+ q# F# V
echo/ ~6 L) o9 a" |, _8 s) B
}
% w/ F+ K+ G- F" z# See how we were called.1 Y' M; x% m& y" z
case "$1" in4 p! I0 B) a" h5 L7 [" J3 I' `
start)
- m2 V0 g4 `! W" D9 Bstart
) G0 B5 O$ i' h8 h2 o+ T;;7 Q* h7 o4 L% O
stop)- t8 `* [. W% J: o9 g
stop% O6 H8 F! J% i+ G
;;
4 h/ j' c( V" X0 h8 qreload)7 e5 Q$ T7 C- g& u
reload+ l* j8 U6 s7 A( n6 I4 t; D
;;
! o7 k: Z2 }$ F1 n$ T6 n( wrestart)
" M Z3 ~' U$ F# X5 Mstop
* W( v; b2 Y; `. M9 o/ x: tstart
; K+ E H3 r* m- n2 x: m4 E/ T;;
5 ?; h4 A* }3 m# w# |2 Z4 C1 G" cstatus)
$ J+ b) g5 c( d& ~status $prog
- d( V- {* Y5 k' [: [RETVAL=$?
: Y$ M6 r9 K% n8 d7 ` \. K;;3 {5 q0 d' G: s' ?; V! ^
*)7 N3 ]8 R" a- g: }* X
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
9 M4 L: k8 |% `7 Z5 F" texit 1. V! k9 O# ^3 k6 D
esac/ ~5 D9 `, h: W$ c$ ]
exit $RETVAL
) U. s8 X" H, T# X; |6 m- f' l" t; w. H/ {4 P6 r% T" c
瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬 9 Y( T# ?, H2 n
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗& B* ^4 c, O" |6 e* f
1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠 , B( M8 O7 h1 J! Z, E
location / {( x7 o& h `% v* l; \
root html;
6 X- w; j; M2 _! |! V" j, Y6 r index index.php index.html index.htm;6 J9 k5 I" _" i3 w/ n! @/ d2 j+ x* x
}
! ~+ `( S1 \4 F7 ]2 k! g! e靽格嫣蛹嚗
8 E9 [/ u2 X; K
: C d. O5 A8 o; p, C! Y location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
0 i! B7 Q- O2 S- p- Olocation ~ \.php$ {
/ K- u$ b \# G root html;( g2 I: S+ U4 n* ]) Y/ ^8 i
fastcgi_pass 127.0.0.1:9000;
/ p! Y4 q! t. K2 Y) ~ fastcgi_index index.php;
4 P0 U; K: n4 d+ f fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;2 G+ z0 X% e+ G, J
include fastcgi_params;; S" | ~) Q( ]! M
}* l* V8 X: \ K m1 r
靽格嫣蛹嚗9 Y1 ]8 p" r" |3 b
0 K/ b0 l$ I- V 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閫蝻拙僎餈唳桀嚗扯嚗
8 j& R* j9 `0 E- A#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql
: N: |6 m0 @; z q4 V* l
2 X' t$ v& _# d5 J: B#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏5 x7 ]2 u U$ o. V+ C; S9 {
扯 cat /etc/passwd 亦冽瑕銵% P& C$ s$ U! V
cat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀9 c" w! E8 r& M
3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
9 {0 i M. I* n { 4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql
+ s: v0 _) I% @/ b; t8 q+ N0 uchkconfig mysql on" x& e8 j1 d e
service mysql start --臬決ySQL
9 f& H* Y' k& t% P1 w 5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH9 ~: m7 L! ~+ C: f2 }
export PATH! L3 K( d. e6 I |7 m7 z$ j1 |
靽摮source /etc/profile 扯嚗 6 ]6 \/ l( t$ K
mysql -uroot mysql> SET PASSWORD = PASSWORD('root');
7 l' `0 C6 G9 h
. W( E( s( _2 p霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗 0 F$ M- P/ B( g& _
mysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗
* H6 c" @5 M9 H& i a; U#./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嚗 ( j% j0 [# z- D8 d) k% \) B' O8 v" o
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
$ P @; u. g8 G/ w4 M1 j* I2 ?& A
, T8 n" A/ Z4 K' |rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
" T7 V5 U$ ~* I: _3 K7 m1 F$ XCreate /etc/yum.repos.d/php-fpm.repo file and add:' h. S' D/ i0 l+ P: R! L$ Y- A
- [nginx]
" ?; X( g: X" n( F, ~) a - name=nginx repo
( d1 F* s ^( F$ n7 i# O0 p - baseurl=http://nginx.org/packages/centos/$releasever/$basearch/$ K+ s2 E1 W' G0 }2 g% p$ G' A
- gpgcheck=0. V5 \/ |. E# }$ p2 a# \
- enabled=1
銴鋆賭誨蝣 ! k% d# R& L3 c
yum --enablerepo=remi,remi-test install php-fpm
9 g1 ]& @3 |0 V* D" t3 O6 h! O' Z& l7 r! H* q. A
( V5 Y3 W5 a9 f0 d% d B+ _鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn, V- h8 }2 j4 w# A2 u% N- a; P
嚗yum remove subversion //貉蝸雿祉svn4 N$ l9 D. D8 z- m1 |6 Q
# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn- l5 v2 d! {0 q5 J
餈# 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] b; h- K) D4 a& s
# harry = harryssecret4 [5 Y3 p. W9 b5 G/ ~! v
# sally = sallyssecret( b; { ~5 w' t
wangning=wangning
r, g8 c4 b: E% w$ N0 B3 hyanzi=yanzi! M6 h, \7 T4 H
#vim authz //霈曄蔭 2 E3 I7 P( `! M+ d0 }6 y. e
[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none2 b4 Y; P1 D" w" E
auth-access = write
4 A; A! g9 {. s( U# y7 E7 q4 l1 {### The password-db option controls the location of the password8 d( C) S z) x) e! X
### database file. Unless you specify a path starting with a /,+ O$ g3 X* P# N4 ]
### the file's location is relative to the directory containing% `) l+ O M( M5 u- ^
### this configuration file.- T8 M0 O* T; p1 y
### If SASL is enabled (see below), this file will NOT be used.( f6 j* o; w! W/ x9 l {
### Uncomment the line below to use the default password file.6 Z* W& k6 I) ^, h7 @" e9 f {7 n
password-db = passwd
2 z% B1 T ^* K3 h### The authz-db option controls the location of the authorization4 @$ ] S5 J& @7 d
### rules for path-based access control. Unless you specify a path
! F5 [" X' I+ z& O }### starting with a /, the file's location is relative to the the
! Y% {' @" t" y### directory containing this file. If you don't specify an
! E5 O: {$ z( h### authz-db, no path-based access control is done.& P' S9 q4 W3 y: l2 p
### Uncomment the line below to use the default authorization file.
" O h+ X J3 G" N' K, U4 g& i! Rauthz-db = authz
. U; q' j$ ?9 W$ j, ^) A1 l! D### This option specifies the authentication realm of the repository.
! o% i6 f7 f, w/ I& G) I* ?0 I# I### If two repositories have the same authentication realm, they should
1 _- F0 W7 L& R& ~- m, k' B6 L### have the same password database, and vice versa. The default realm
8 q9 t" Q7 n5 b& R# ]7 V### is repository's uuid.
! L5 B) v; n( T0 `8 t8 Vrealm = My First Repository
: j9 D6 i" h2 @' l4 O 瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn
# S3 _. O' T% `8 m. D8 L #killall svnserve //甇
, F7 f. I8 I; k; f/ W4 b$ [0 I 敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx
7 o7 p, d9 q" D' ?% S5 a 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% n# d9 z+ S) M4 D, a6 U
b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐 4 U: G& Y% D) p, e8 {. L
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" :
# M0 w7 u7 Q1 y& `$ o#system-config-securitylevel 豢DISABLE敺OK嚗敹璈
$ c3 `7 `& M* G) b7 ]瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急
vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled ' b3 |5 ^& ]' ?; N
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿) t7 v; a; y% R( x8 N9 K
|