: http://blog.csdn.net/yanzi1225627/article/details/491236598 c! x( o: n" t
& d5 h6 R0 C2 y5 {2 L
格嚗剖遣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
; ]; c% F L: l' x$ B$ R! b% R 湔亙敺摰鋆靘韏摰鋆摰 嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗 舐 google search engine 撠啁 撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝 鈭嚗摰鋆nginx閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗 ./configure --user=www --group=www --prefix=/www/nginx3 M! o" E8 v$ w8 o# M
嗅make嚗make install撠勗鋆摰瘥鈭 摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯 扯嚗 /usr/sbin/groupadd -f www
?3 w( f" V q2 `' c/usr/sbin/useradd M -s /sbin/nologin -g www www //-M 銝撱箇雿輻刻桅 nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具 chmod 755 /etc/init.d/nginx
) q V/ v2 F+ c: I+ F/ `0 A
+ ^- Q; ~! r. d( [/ G7 Hchkconfig --add nginx
8 e& }5 [" d( R) O9 h. ?+ `% @1 X$ C. M. d3 r8 s8 T
chkconfig nginx on
! x7 q7 Q5 J8 L+ Q$ Q5 h; p T 嗅 cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗 #!/bin/bash
! H6 @. n0 F5 v7 ^6 U% ^1 ^# nginx Startup script for the Nginx HTTP Server
' x5 T6 l1 ?& E0 @( p# it is v.0.0.2 version.8 Q: h+ L; K9 ~# m0 K
# chkconfig: - 85 15" u I W! H; Z: w% f8 P+ ?
# description: Nginx is a high-performance web and proxy server.$ Q, x; s/ D8 \
# It has a lot of features, but it's not for everyone.; R4 E+ x5 e; j- I# q% r
# processname: nginx5 {; h% V* Q+ G% h5 h7 [
# pidfile: /var/run/nginx.pid$ y( `" }$ b( M+ H$ O7 d
# config: /usr/local/nginx/conf/nginx.conf; {2 e5 ?) Q0 M; e7 p
nginxd=/www/nginx/sbin/nginx6 S* p* ?4 z- P
nginx_config=/www/nginx/conf/nginx.conf
% l% d; j' o8 k4 i0 q' Hnginx_pid=/www/nginx/logs/nginx.pid) S# o% x: ?* j1 H4 g# ~
RETVAL=0) c& Y" B4 m* t: p- {$ G
prog="nginx"! O2 O2 q% Y6 t [7 c. ]
# Source function library.9 ]7 m9 Q9 ^$ B- c3 Q
. /etc/rc.d/init.d/functions
1 n# ~5 _' O( }; \: q8 l) m# Source networking configuration.
( M0 W6 t) O: v. M& @# u5 Z. /etc/sysconfig/network
( Q( X F# d( @; D }$ W. ]9 m: P# Check that networking is up.
: J7 h8 x, ~/ d/ U[ ${NETWORKING} = "no" ] && exit 01 [5 x# c: }5 n3 T4 k. w
[ -x $nginxd ] || exit 0
2 H7 I9 i9 i. I8 Q# Start nginx daemons functions.0 B, n' K+ x5 j; j1 Q. k3 a1 M
start() {
* m! O2 `; V8 U4 }if [ -e $nginx_pid ];then
) Z4 R, W7 a& wecho "nginx already running...."" \; f5 I2 K4 k1 l% G6 d' ?
exit 16 I% Y5 C; Z* U$ u
fi ~8 N: l) J2 W; ?5 \
echo -n $"Starting $prog: "
1 x0 Q' U- u) `* y" @; a' N) P! `7 Kdaemon $nginxd -c ${nginx_config}" k7 M/ ?' \- R* s( \$ o
RETVAL=$?
# g* Y0 q. J# @5 t5 Y- Kecho4 x0 O L; M- s% b3 f$ {
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
1 [0 ]& s7 Y+ O; greturn $RETVAL B4 N! u, s: v: A6 X3 O
}) e! X. P; s2 v# t
# Stop nginx daemons functions." |4 S E4 a- L
stop() {
. n% r3 r* @! z& gecho -n $"Stopping $prog: "1 c% L0 Q6 ` d5 b G, X% a' l
killproc $nginxd5 O; f4 f; e; J# F9 j
RETVAL=$?
7 W' i& `, j, Recho
8 `4 g( M6 @/ D[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
: f# ?4 g6 r. \" w}3 T$ n; R+ y/ ]. z) n- L
reload() {
# B' ]* i1 m0 G) q7 ^7 E5 Xecho -n $"Reloading $prog: "
( C" M' h& P$ b- y- Q#kill -HUP `cat ${nginx_pid}`
$ m3 v% }: q* n; [0 Ykillproc $nginxd -HUP
/ B6 h# q7 B z' R9 tRETVAL=$?
* R9 [. H% R4 j# O) d. necho
8 |) j3 ]. i' O: S4 L* ?}
, r( v8 |8 r7 ]2 w2 z# d* P* V# See how we were called.9 R% L. J2 [+ z R7 W7 H6 \
case "$1" in2 P& y/ b6 `; Q& i* i+ b
start)
* W( U( d( h- B# @% ? ostart' h! t$ K8 M0 ?
;;, M9 V. g: g" O9 f
stop)5 m( F* F& _& k4 X# s! b" `( @
stop0 p# ]; {, l" E: u" }7 z. I& O0 v0 L
;;, J* H# ^6 ?/ B6 @- s1 w
reload)
; A M g, D$ P$ r6 V6 E4 j. y+ n! ereload. C9 @# {7 k+ f: Q! \3 ^
;;
8 S& |& x8 e, }4 l1 }restart)* h6 ]4 s& Q5 O8 ]2 a8 ]" g; @
stop" @# |1 r5 ^+ i8 w/ F( V
start. y7 e; {" Z! j2 a% l) |
;; o% \) H s, u( X$ L( q6 P* Z) G
status)' h, P1 V& Y7 Q& ~ g- ?& v
status $prog
& T6 ~" R, m7 W/ D* ^- \7 ARETVAL=$?
( F% _' b, w' J* G4 K- q" m/ H' Z;;+ g% ^1 h) V$ ?% q+ N
*)
4 U% l1 ~1 `/ Wecho $"Usage: $prog {start|stop|restart|reload|status|help}"
5 \& f; u* N! `exit 13 v* m6 q4 n- Y4 y9 m. U
esac
/ @8 l+ Q. r3 ]8 v$ n& Oexit $RETVAL
4 b6 ?( ~2 Z; P
5 T6 {- e) c! u$ ?* f/ ~ 瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬
6 V' o* u3 o& O; Achmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
9 Q( I) J$ T) u, B1嚗舀湔寥霈已eb寧桀/www/web桅 2嚗臭php游嚗暺霈孓ginx臭霈小hp敺 撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝 餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠 3 M( q9 B" k- K( I" Y8 p a+ V
location / {/ ]/ C' F0 s9 y/ W/ t
root html;
, P6 S# m3 x% y4 ]# z index index.php index.html index.htm;7 j5 t7 M% \! T
}/ X7 _' L0 x8 o) |" g: @" d4 R
靽格嫣蛹嚗
' [+ R. f( Z$ W9 r6 ?; [6 t+ [4 z% x" X, M3 v! w1 Y* [
location / { root /www/web; index index.html index.php; } 瘜冽嚗憓鈭撖隘ndex.php霂怒撠
, V$ ?5 u8 i: l6 H1 D% k; Llocation ~ \.php$ {
) t/ s! A. P8 c' l) ^: \ root html;
: M$ z1 V7 N3 a" B0 \; @ fastcgi_pass 127.0.0.1:9000;1 r: i4 L- k: ?+ ^
fastcgi_index index.php;( i5 c+ s' r, r1 M5 L5 |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;8 y( [* m! h# V0 X: Z! o3 K& J1 p
include fastcgi_params;
9 R1 ?/ J4 p( d2 D8 L! U, y }
6 Q. K8 Z4 H3 M6 y. Z" B靽格嫣蛹嚗
: F' D* ]) I8 W4 y* l1 P1 P/ x9 {8 p6 U4 {0 R5 N
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閫蝻拙僎餈唳桀嚗扯嚗
% ^. N/ i \7 E' V9 ^7 \2 ^- }#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql 銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝 my.cnf.backup ps嚗甇斗郊撉日撣賊閬嚗嚗嚗 2嚗撱榦ysql冽瑕蝏 #/usr/sbin/groupadd mysql
: f2 e4 Y; e9 T" Y) G r
0 k8 Y' Y) G4 a5 U6 d$ l' U#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
; v9 h# n( v% _3 D O7 q 扯 cat /etc/passwd 亦冽瑕銵6 g# R2 |. l9 n- W+ h
cat /etc/group 亦冽瑞銵 chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀% G- v' g* n" o1 I Y
3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀 scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
/ W! e" h \7 t7 G3 A q6 x 4嚗瘛餃∴臬決ySQL cp support-files/mysql.server /etc/init.d/mysql/ v: h( S" f/ _8 v& s- l0 T
chkconfig mysql on" ]! v& W$ w' n+ n2 S9 E. t
service mysql start --臬決ySQL
8 ]& u% q( M" q. y) m 5,霈曄蔭root撖 銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile 瘛餃嚗 PATH=/www/mysql/bin: $PATH
+ C$ J X) C% o7 K: c# `8 ~export PATH
1 G* |: h+ s7 G' W" H5 @* ^. K! J 靽摮source /etc/profile 扯嚗
- n9 J w4 `9 r4 N9 E( Gmysql -uroot mysql> SET PASSWORD = PASSWORD('root');' X: J9 N" h, v
( J7 P$ a2 l+ q1 x/ n5 K a8 U霈曄蔭root冽瑞撖銝氳oot 6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗
0 W8 T3 K. U, D6 ~* amysql> grant all on *.* to xroot@"%" identified by "xroot; mysql> flush privileges; //湔唳 餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀 ,摰鋆php(php-fpm)閫撟嗉交嚗
0 U' }! ^6 D( r0 \0 i5 U3 s3 d#./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嚗 $ ^; Y" o# w# b; [" [) b( ~
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.rpm3 V w) E; q: T7 [. M- M
: l7 t2 Z2 j7 T- A0 Qrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
2 q1 R5 f C; i. @, l: _Create /etc/yum.repos.d/php-fpm.repo file and add:% I. i( ^, p, Q
- [nginx]! D+ a+ `6 n4 q9 F
- name=nginx repo9 @9 ]+ x; Z: m; `5 N
- baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
1 z$ m a+ l8 W5 V - gpgcheck=0$ q( R E2 \8 w/ P$ V
- enabled=1
銴鋆賭誨蝣 . P, `4 M) g$ K% G, S" A0 f$ \2 ], m
yum --enablerepo=remi,remi-test install php-fpm
9 Z m4 `0 z8 C/ z2 t1 h+ h% n. t; c' | b) n: x
& O0 {3 u" w1 O4 N" I鈭嚗摰鋆svn蝵峰ost嚗commit甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯 # rpm -qa subversion //璉交臬西芸蒂鈭雿祉svn/ q. |& Z6 X" T# [. R
嚗yum remove subversion //貉蝸雿祉svn
( U7 w; D. r% _9 F8 H # yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql //摰鋆svn# x$ @/ k9 V0 ~8 a: d/ R
餈# 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]8 z5 W+ G8 w. A0 M8 Z4 w8 z! Z- ]
# harry = harryssecret
/ r3 e& c8 d1 w. P+ Q) \7 [5 Y# sally = sallyssecret9 L p& |+ t7 m7 m6 a3 b3 F8 l
wangning=wangning
7 n3 ?+ g$ i1 [5 t5 y8 h- F- E4 Pyanzi=yanzi. G7 l5 n$ u& H: Y' p3 p
#vim authz //霈曄蔭
7 N. {- h. z6 u[/] wangning = rw yanzi = rw # &joe = r # * = #vim svnserve.confanon-access = none# [4 ~$ e+ Z6 ?- Q; g
auth-access = write8 S; f. ^' `& c& a6 H
### The password-db option controls the location of the password
" F" w! j4 L; h3 q### database file. Unless you specify a path starting with a /,$ f, G/ X+ U$ N1 ~5 f3 z) W- k' F( w7 M
### the file's location is relative to the directory containing- N# E1 C" B$ c% v s
### this configuration file.
" w! Q6 W+ V! u- r. ^% P/ K+ V: }### If SASL is enabled (see below), this file will NOT be used.: b+ j2 Q- ]! r; i8 r2 z* A: o) {$ M
### Uncomment the line below to use the default password file.2 E( g. z; n# X0 G' z! s
password-db = passwd
1 v6 Q0 V7 K; c### The authz-db option controls the location of the authorization
& u; ]8 |2 h8 \+ z& B% y% W### rules for path-based access control. Unless you specify a path* g: M; d, g9 C+ P* v. q* q* d. _
### starting with a /, the file's location is relative to the the
~& H% T* I8 g9 _7 Y### directory containing this file. If you don't specify an5 V& A% d& N; J) R- c& n
### authz-db, no path-based access control is done.5 H5 ^$ A! `6 w2 I* N! @
### Uncomment the line below to use the default authorization file.: B$ E4 I( Z3 N% a" a) R
authz-db = authz" i _. ?3 y+ Q
### This option specifies the authentication realm of the repository.
( I9 f. w; m, G. u- m* a) h" E### If two repositories have the same authentication realm, they should& q4 c) U! _# M9 D
### have the same password database, and vice versa. The default realm
( \! T# Y8 y2 t6 {. I* V2 u2 ^### is repository's uuid./ p9 O$ H. ?/ U# N( }: h
realm = My First Repository
. k2 }0 v. D/ v2 h 瘜冽嚗銝Z鈭銵V賣蝛箸潦 3,臬典甇┬vn #svnserve -d -r /www/wwwwvn //臬究vn- Z, E5 K) R: k- M! e1 V
#killall svnserve //甇
, z9 f# k4 L0 |; P; f# S 敺臬究vn嚗臭誑典X霂鈭 svn checkout svn://192.1.15.222 --username xxx$ A0 t" G0 e% `$ J! m1 K6 H9 n
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' Y. F' O6 D# l7 A. y% c9 f
b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit vim post-commit嚗券Z伐 ' v% m: E1 h' g1 [6 h* l% T
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" :
1 o# @& U$ H6 o" f, i6 d7 ?#system-config-securitylevel 豢DISABLE敺OK嚗敹璈
" F7 M; R8 P8 w' t S瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急
vi /etc/sysconfig/selinux SELINUX=enforcing 寞--> SELINUX=disabled
' D( X3 W" ^2 t; M& z( T& w2 ivi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿& C ^8 H5 Y' X+ g) o
|