52AV璈A|52AV.ONE

 曉撖蝣
 蝡唾酉
敹急瑕
  • av隢憯BBS
  • 璈A
  • 芣瑟憭瘚
  • 鞎澆
  • 52av鋆貉摰
  • 銝剜-銝剖銝餅
     
亦: 4117|敺: 0
銝銝銝駁 銝銝銝駁

[nginx|php-fpm] CentOS憪蝣澆鋆剖遣LNMP(歪ginx嚗mysql嚗php嚗svn)

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659+ h" b! T& L# _% Z) e( B9 E3 j

2 I4 u8 S" @2 u/ B- H

格嚗剖遣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
/ S. e* m: L+ w7 m

湔亙敺摰鋆靘韏摰鋆摰

嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗

舐 google search engine 撠啁

撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝

鈭嚗摰鋆nginx

閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗

./configure --user=www --group=www --prefix=/www/nginx
/ X) f  Z4 b5 f9 X5 d

嗅make嚗make install撠勗鋆摰瘥鈭

摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯

扯嚗

/usr/sbin/groupadd -f www- ^# `& J* {/ V$ P2 n
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具

chmod 755 /etc/init.d/nginx
# h; h  \+ x3 _+ j* U7 D, A) Z# V1 n% ]: R! x0 z/ V
chkconfig --add nginx; j/ X" x# L. O1 R7 ^/ v( J! d5 M9 a2 ]
+ U$ S2 ]1 ]* }3 \5 k) g# s
chkconfig nginx on
+ p- ]! [0 L6 }& P! J9 Z4 F

cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗

#!/bin/bash
( q$ I, A* E3 g5 d# nginx Startup script for the Nginx HTTP Server
4 O% C4 s( V  P# it is v.0.0.2 version.' U% |) L+ \# F$ d9 J# O
# chkconfig: - 85 15
" L) S2 `6 g0 e% t# description: Nginx is a high-performance web and proxy server.& Q" |" h" q  n1 O$ A) w6 G+ ^) O
# It has a lot of features, but it's not for everyone.% g2 m' {) L& w7 }
# processname: nginx4 H) w/ v. t+ h2 S
# pidfile: /var/run/nginx.pid7 b: p; W7 Q0 J' D0 m6 D- _
# config: /usr/local/nginx/conf/nginx.conf9 v# f1 P, \' y! |$ [2 W: E- m8 h
nginxd=/www/nginx/sbin/nginx. B5 y% ?+ m; h4 E
nginx_config=/www/nginx/conf/nginx.conf  c: B) w2 j2 P: w* v. l
nginx_pid=/www/nginx/logs/nginx.pid
2 Y) n, w6 {) ?7 ?RETVAL=0
% N9 I: V0 q$ a3 \* |# e  Eprog="nginx"+ U( o; z9 g1 }1 i" [4 `
# Source function library.
" W6 J6 ]2 `0 _* @" G: @. /etc/rc.d/init.d/functions
- x' Q2 ~$ P& E; ~% B( C6 L# Source networking configuration.
% ~: u% a# _, M. /etc/sysconfig/network5 v. z. j: C- s5 Y# ?3 m4 k( ^. f
# Check that networking is up.- H" V5 Q4 `( y0 ^- q
[ ${NETWORKING} = "no" ] && exit 0
* ~+ F! B/ t% g4 a9 P[ -x $nginxd ] || exit 0' l/ P; [6 ?( a* m4 j
# Start nginx daemons functions.7 p2 @4 g9 l1 f  n# x2 P6 \3 g% Y
start() {" D$ o3 D1 r/ U- P' }/ P( j
if [ -e $nginx_pid ];then
! q& M4 x3 i" S/ J# y. wecho "nginx already running...."& K2 W8 M- ~: f8 c. n7 t5 Q
exit 15 H3 [  P0 C; L7 P. U4 ^
fi+ b9 k0 g  |5 W4 ^: }2 H9 L
echo -n $"Starting $prog: "
0 e8 t. w( {2 l  z; j  Vdaemon $nginxd -c ${nginx_config}5 a1 n6 _7 c. x6 P; S) T1 M2 W
RETVAL=$?& D4 R& ?+ `( s* C+ J9 @8 @% l: m
echo3 n+ `! X" |- h% H/ D% c5 H
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
3 \0 i. O, r: [/ @. j4 i1 [return $RETVAL
+ w+ ]# ?& u" o6 ], ?( j3 @% k}
: K; d! _9 s! }# Stop nginx daemons functions.
: A( L! Y+ f' e- c9 ]stop() {4 F" e& L1 B! u
echo -n $"Stopping $prog: "& x" @% j9 k. E& c4 g% ^" d4 X
killproc $nginxd
" E- a4 x4 n8 WRETVAL=$?
4 {5 R1 X- w) @: I7 |echo; f. Q# g1 C  @  @
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
: o* ~# Y- i. A6 k( T}9 w3 X. O# M( ]1 W3 {3 m4 u
reload() {' H0 z& ]; u* y) ?
echo -n $"Reloading $prog: "
; i& R! z3 ~9 s#kill -HUP `cat ${nginx_pid}`, N- i4 x% {8 V2 c4 S
killproc $nginxd -HUP
& Z3 C! v+ Z; L! ^9 BRETVAL=$?
$ m* M8 g! v9 H8 b( D! I& R7 R6 Zecho
2 V0 g1 R$ j9 v( k5 u8 @! Q7 C$ n" l}( e7 E% e2 l, V5 H
# See how we were called.
( @4 F# L+ d3 Lcase "$1" in* \) k  `+ |& W. ^/ {& D" `
start)
: e# B, t# {1 R9 J# s) R0 wstart
7 b, H3 Q5 \* b% t$ d( T' u;;
  s4 \# a4 |+ Z5 z4 M9 U6 \/ Hstop)
$ J2 N7 a, Q0 q, @+ }9 {2 qstop
+ d6 `4 H" c: a* u+ ]' w& z2 |;;
9 _9 _% S- ?- }reload)
2 X' P. W( _& f% U9 f( d0 wreload
$ I# _9 j; w5 Q: I) I, h;;
3 m, w9 o' u8 G4 E* G6 {restart)3 {# T0 ?7 s% p* w+ n
stop0 M3 @* p# U! X
start
8 o$ g1 I$ f& l- B7 K# P- H;;
7 o0 q( d  H3 S5 ]0 k2 |0 J* j1 ?status)
/ U2 w) I9 t) x6 j3 I6 estatus $prog
+ Q% z! a" ^2 L1 P4 LRETVAL=$?
; X0 i: R9 N2 [& d# C8 m; i;;: h# ?# \* A0 u) w5 m9 x0 O) I. _
*)* `1 k/ y3 x7 ^
echo $"Usage: $prog {start|stop|restart|reload|status|help}"; C# b% g; r9 M  }/ F( `
exit 1
+ U/ y9 w& z/ p2 ~esac+ `: q) u; n3 g; V
exit $RETVAL
4 g) d; M9 A) @5 ^
. ]( Q- Y4 f$ A5 Y

瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬


8 B* G+ Q  d& j. echmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗  O5 v$ ?- K8 f" k5 ?

1嚗舀湔寥霈已eb寧桀/www/web桅

2嚗臭php游嚗暺霈孓ginx臭霈小hp敺

撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝

餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠

3 X9 S4 e4 d* R
       location / {* i& T" N& x+ U" l& ~
            root   html;
6 B# [# u' k+ b            index  index.php index.html index.htm;# j+ M3 \9 w! r  K
        }# y4 T, X# U- W
靽格嫣蛹嚗: J1 I' F1 u0 {. J, z( @* }" u
5 o# _' }; C. v. e# W

        location / {

            root   /www/web;

            index  index.html index.php;

        }

瘜冽嚗憓鈭撖隘ndex.php霂怒

4 n* G; E. Y" f7 T4 q/ |. m2 x, O
location ~ \.php$ {
) |- B% B0 M( G8 n0 x: n  S            root           html;$ \/ Y9 h3 n; l& S
            fastcgi_pass   127.0.0.1:9000;  V* K: Q7 O9 R! F. n' v
            fastcgi_index  index.php;
8 v' y  o: p9 ]& i* ~4 @! A/ H            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
6 _% L: L: h9 M            include        fastcgi_params;
  @( F6 V" l  g0 |4 j" D0 I        }/ e; y. f6 o" z% H9 x; m5 {/ L* t
靽格嫣蛹嚗
: H4 G6 v! S1 E7 u0 a: [! h
) I: E/ G) X0 p$ @

        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& U+ l- e2 T6 d, F

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗

1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝

my.cnf.backup

ps嚗甇斗郊撉日撣賊閬嚗嚗嚗

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql! t! z. R- w/ u! o6 G- b

- h: s; p9 D8 M+ q#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
% c6 m6 g# b8 o3 h7 J

cat /etc/passwd 亦冽瑕銵) l1 f' U1 }+ Z4 n5 f% g+ g
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀/ X- }% Y- K* S) _: D3 C' G/ ~

3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
9 `" E) Z2 ]  s3 H: s: ~% j

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
4 S4 ]/ h( l. N+ Y  b5 q: U& gchkconfig mysql on
0 r& c+ a$ _# ^8 s# s: t% fservice mysql start  --臬決ySQL
6 f; ?1 ~, U4 [7 Y  h* c

5,霈曄蔭root撖

銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile

瘛餃嚗

PATH=/www/mysql/bin: $PATH
  m% I' v8 v3 e, d, O6 Pexport PATH$ n% u2 K; F  ~1 J

靽摮source /etc/profile

扯嚗


1 N$ j$ `8 b4 }$ E) i7 Gmysql -uroot  mysql> SET PASSWORD = PASSWORD('root');" g5 O9 N2 o& y8 C1 H, Z
- [* x$ a- G* t2 `) g

霈曄蔭root冽瑞撖銝氳oot

6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗


! H: X5 b8 T8 ~- s# d

mysql> grant all on *.* to xroot@"%" identified by "xroot;

mysql> flush privileges; //湔唳

餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀

,摰鋆php(php-fpm)

閫撟嗉交嚗

! @  d/ O3 r5 c# V9 O2 y

#./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嚗

* A5 E7 y4 U6 T; u4 x

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' Y! {/ N) Z, `" u1 o# O& f, a* P) T

1 v5 @. o7 r4 q9 {) Urpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm5 [/ g8 q  M5 h1 O/ M
Create /etc/yum.repos.d/php-fpm.repo file and add:
$ v9 m7 G) P9 L( I" p' k
  1. [nginx]
    3 U  T8 ~2 f6 I# E1 _" }4 F
  2. name=nginx repo
    2 M5 b$ J8 z" A7 C7 C8 y& p
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/' H$ d& H& s9 K( ^: B
  4. gpgcheck=0
    0 M& O; i- K& b7 W
  5. enabled=1
銴鋆賭誨蝣
1 F3 V# l: b" f1 B' p. n: r
yum --enablerepo=remi,remi-test install php-fpm
/ w8 `7 k) k! F* W( m8 l6 x- s
: K+ y; B/ \  g: e7 f( H) e
/ \8 X9 j/ Z" G: Q
鈭嚗摰鋆svn蝵峰ost嚗commit

甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
4 Z/ ?- w2 k% Y* h

嚗yum remove subversion //貉蝸雿祉svn5 A1 C2 A! P7 H/ }

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn' p, @  g6 n; w( 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]: B. h. q% J% k2 G$ I
# harry = harryssecret
( s9 R# C' s0 X# sally = sallyssecret1 f4 M! v) Z+ P  B( m3 Y7 R
wangning=wangning
( S$ _3 `# `' V4 Byanzi=yanzi) t- Y+ X7 S( p

#vim authz  //霈曄蔭

/ k$ `& V) ^6 }

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none/ M7 t  x' T0 e
auth-access = write) A0 ]; H( W) }1 J6 {6 N
### The password-db option controls the location of the password
5 u( m* P+ Q. Q: o0 Q### database file.  Unless you specify a path starting with a /,$ v; Z# E0 c1 }: K' l2 m" y3 |. v7 h
### the file's location is relative to the directory containing
. L5 U& X9 s& N* V" _3 \### this configuration file.
( D4 x8 O) N0 k4 M% U3 B' O. p. P### If SASL is enabled (see below), this file will NOT be used.2 p1 f* D1 `3 F5 ?4 W
### Uncomment the line below to use the default password file.% P  ~- ]$ f5 m
password-db = passwd
0 ~( x% g: C. V0 N### The authz-db option controls the location of the authorization
8 z: j3 X( ^  l0 {### rules for path-based access control.  Unless you specify a path
" Z9 ]6 r# q5 L2 S  l+ I* c$ S### starting with a /, the file's location is relative to the the
! M: h3 a) ?: y7 \9 I  p### directory containing this file.  If you don't specify an
9 w4 Q; j9 ?. d9 h2 S9 C### authz-db, no path-based access control is done.
* W0 j9 E5 ]. y  v### Uncomment the line below to use the default authorization file.7 ]0 Q/ s0 @, w& [5 V4 Q
authz-db = authz: N/ ]1 i: u7 g
### This option specifies the authentication realm of the repository.
9 A2 M" I- A8 d5 |### If two repositories have the same authentication realm, they should
6 p) M* I$ r/ m9 M6 _2 P+ d### have the same password database, and vice versa.  The default realm
5 _# v/ b* f& U8 j### is repository's uuid.$ Q0 _* R& j) Y3 l4 ]
realm = My First Repository
  b  ]! m; s1 c0 G7 B% ~$ a0 d

瘜冽嚗銝Z鈭銵V賣蝛箸潦

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn  z7 b  m1 F; E  Q

#killall svnserve    //甇
1 d% @5 N- y. a# O. I) h. X

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
% h' f* ^% y) O; _5 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
9 g  Q2 R/ h0 \6 f' k. t) b. t

b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit  

vim post-commit嚗券Z伐


/ \9 h. c) ~2 a! s

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" :, C8 x, Z! o8 c# L( B0 _5 M

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


! f( P  J; L6 d; Y; j6 s瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


0 N- |8 z6 J9 B+ o) W" q5 f6 qvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
2 j  ]4 a5 d$ y) ]! z  P

雿輻券

祉蝛閬

砍憛批捆靘餉衣雯頝臬批捆蝝颲行粹嗥蝬脩嚗摰撟湔遛嚗嚗甇脖誑銝嗅啣摰嗆摰撟湧翩鈭箏ㄚ孵舫脣伐銝憿亙祉璇甈橘芣遛18甇 雓蝯脣亦閬賬粹脩芣遛18甇脖芣撟渡雯閬賜雯頝臭嗥批捆鞈閮嚗撱箄降典舫脰蝬脰楝批捆蝝蝯蝜ICRA蝝摰鋆閮剖 (粹蝯行霅 祉蝬脣銝蝝瘛函隢憯啣嚗祉閮剜蝞∠)

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-1 18:16 , Processed in 0.089284 second(s), 20 queries .

蝯∠.撱

52avtv@gmail.com | QQ:2405733034     since 2015-01

鋆貉憒 敹恍敺 餈銵