52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659# ~0 }$ R+ {) b; S

" o5 b) w/ i6 W0 K% Q

格嚗剖遣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
( L6 n( Z4 B7 S/ F2 H

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
/ G8 S: `: I# S  ]  L/ e5 @

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www' ~/ ?! W5 s( }, b/ v
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx6 x; y( p) X" f  P( B& u* ]% \
  ?, h7 T4 T- F5 f, r2 }
chkconfig --add nginx+ m' Y$ S  M7 h7 f2 B9 ?
  R) t+ u! W1 [2 F: u/ P: b
chkconfig nginx on
  E: t' T# E9 f. j6 |4 Z8 E

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

#!/bin/bash3 c7 r% D7 a- V3 U$ P* r5 r+ m
# nginx Startup script for the Nginx HTTP Server
1 W1 M4 q1 ^- H* F# it is v.0.0.2 version.' f. a, C* V: _" ~! F  `! Y
# chkconfig: - 85 15
, N; J1 d: w0 Y3 p; w: _' O! ~# description: Nginx is a high-performance web and proxy server.
/ e# K# y3 B- S: }; a" L# It has a lot of features, but it's not for everyone.
: {/ C: f7 v. j/ W7 D4 P/ I4 A# processname: nginx
% \% u4 t: V1 M$ L/ x. R& `# pidfile: /var/run/nginx.pid" J- Q% c0 r8 r; g- p! E7 k8 x9 Z0 f* a
# config: /usr/local/nginx/conf/nginx.conf# m+ A! D# Y; ^- e5 w/ x2 }
nginxd=/www/nginx/sbin/nginx9 ?. z4 Y2 z$ v
nginx_config=/www/nginx/conf/nginx.conf
, U, W4 L* u9 ?9 ?2 Znginx_pid=/www/nginx/logs/nginx.pid3 u! |) x2 B1 D5 @! U) I
RETVAL=0
! n+ s* ~  B3 ^/ |* F4 ]' p1 vprog="nginx"; f$ J6 ?$ S' Z" M3 p$ h1 E+ x
# Source function library.. M8 O1 N& |! `9 H
. /etc/rc.d/init.d/functions
* i+ a) p5 Y0 ]. E, l# Source networking configuration.
% e7 d" d5 B5 F$ m: N1 S% x. /etc/sysconfig/network
* \& A5 S6 ]8 f6 X# A- d, Q) d# Check that networking is up.
! t* u4 w6 R, P. I4 U5 G8 P[ ${NETWORKING} = "no" ] && exit 0
/ f9 U: W. [* C; g  _$ P[ -x $nginxd ] || exit 0
! j3 @! M# H) T( E3 ]$ x+ R# Start nginx daemons functions.
9 H) `! ?$ x9 @3 a% J# _start() {# t9 b, g, d  f1 W# Q8 }
if [ -e $nginx_pid ];then
, P% F" I, i- r" p2 ?- n5 h+ o0 T( mecho "nginx already running...."
1 R7 Z( n7 g7 Y& D% E# Sexit 1( F7 Q6 v: g7 m3 M& b  A. H
fi5 O% B/ [5 V  k0 {1 u; w, ?
echo -n $"Starting $prog: "
$ ?1 {; p$ I) W0 {& _/ z  adaemon $nginxd -c ${nginx_config}
) x9 u2 z, P( d  s+ ?RETVAL=$?3 _% e0 e+ L6 ^
echo6 |& I7 b4 `" V6 \9 H
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx6 B$ I) C8 `& }
return $RETVAL
  [4 R! H$ `+ ]8 T}: x+ J- K9 E' E% p0 ~. r7 r
# Stop nginx daemons functions.
& J! u+ b( T. `: X* e) |! @' Zstop() {
. @# \0 E: L! |/ V4 R2 J* u( yecho -n $"Stopping $prog: "
4 W* @  r; C' ]' Jkillproc $nginxd6 [6 `% |7 z1 b7 _3 o
RETVAL=$?
, G1 ~: L* `5 V+ I/ j1 i  Oecho) }$ v9 v1 R% r. z; U
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
8 B; O9 ?! i4 x}
8 s+ x" k- v, u. x7 A0 A: n8 Ireload() {; W2 s! w' q4 M8 j: ?) S( Q2 Y
echo -n $"Reloading $prog: "
( w, a5 C4 K% ?+ r#kill -HUP `cat ${nginx_pid}`
. q/ M1 w. u3 M) N& Y: a, w6 zkillproc $nginxd -HUP
3 Z: F: T1 _, W- W5 L. S: _RETVAL=$?+ R2 _- u2 X' S9 f8 b
echo' L0 V7 H4 |6 C
}
# B' u, x: a0 w; L( |; R# See how we were called.# m: W: z8 W0 c& ]3 ~+ B
case "$1" in' P" m$ ~% @0 B# N: D3 w; E
start)# |2 y* g8 M! L2 H7 P, n1 h
start
$ q  S- d/ ^* B- y! Z( ^; U0 \;;
5 L7 ]; E& \2 I% b1 Q. i/ xstop): {& {' E* V- I. s9 G& `
stop
" n5 N  q: g7 m, r, y;;; u; t- L) J9 Q8 n9 O
reload)7 ^0 }! Q- a- q; R
reload( j( d  O9 E2 M" \: ^" `3 Z* p$ O
;;) e, L% Y2 R" z/ Y/ A8 G
restart)
- H: Y4 M* o) i" G+ N6 gstop9 a! N' s# F7 ~' Q" t8 }, L4 n
start
% Q# [: I; \1 v: A;;
" ^5 F! s% g! Q2 U0 W# zstatus)
% |+ {$ e, Z7 E7 K1 cstatus $prog
# R& C) }( i+ }& n+ ^RETVAL=$?2 D. F! m6 s) e- ?( d) U) K1 v
;;: }, S: D% u  A- ~2 ~
*)4 [3 d2 Q* W5 m; [( S8 ^9 ]
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
( A9 f  s  f- R* iexit 1+ `2 i6 u  W9 K4 s" @6 M
esac  l' @- x+ c6 A+ _( c  N  p. }
exit $RETVAL
: C, C+ h% a6 J/ J/ R8 l1 A* S/ @! n8 c) F' L

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


5 Y; g7 W: g: M0 S6 g5 Q7 Echmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗% J# S+ j0 J; B7 D( p) a

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

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

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

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


( w6 Y; Y* K  Z; S       location / {2 E6 w: S. m# P
            root   html;
3 @! {* o" Q! c  u. W/ P            index  index.php index.html index.htm;
- E: ]6 ]8 E# O) P1 ~! o6 ^        }2 T7 M3 V  }  F0 j) w  V
靽格嫣蛹嚗6 x& l' [* I7 N

* v; h, s( e' s4 f: S1 U$ X1 o: Y) J

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


7 D( U& y% b! X9 v# y0 ?8 ^& @location ~ \.php$ {
, q9 P. T6 I3 P7 d, G            root           html;
5 U( Q* ?6 w: [* H- [9 L1 n) Z            fastcgi_pass   127.0.0.1:9000;: H; y# P/ S+ L+ V9 P6 O
            fastcgi_index  index.php;
$ i9 J( j' w" T2 c6 `            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
) b7 z& [. R% j: ]& f; G, L            include        fastcgi_params;
1 s" H8 x- ~1 h+ M        }# c0 N' ]; n  {) J0 _4 i
靽格嫣蛹嚗
& i$ M: f9 r" U2 p( j+ M- I5 H- S: m# ^* e

        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

閫蝻拙僎餈唳桀嚗扯嚗


( {. @6 z" E/ W1 k- ], u9 k

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
* C% V; t4 l0 T' X& W
% u, b0 x' C& r) ]#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
: A# ]* E9 U8 h( H, f

cat /etc/passwd 亦冽瑕銵
7 D. I! B) w5 [cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀0 A+ t2 y, H& c! j2 t5 p

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql( u6 T. z( ?- }$ V2 r$ k- |

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql) m8 e$ D, A( X$ q* T
chkconfig mysql on
( [. d) `+ F" p  Wservice mysql start  --臬決ySQL& A/ G; F1 F. T" L# V

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH3 N* R1 S: n0 F9 v( R9 v( a, ~
export PATH% i  {4 l) o6 ?5 [

靽摮source /etc/profile

扯嚗

$ s4 j" h! q) `4 e8 \3 ^
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');' P/ I6 v' ]+ z% Q$ i# d

* K/ ~- Y) d1 }! g( D5 d# d

霈曄蔭root冽瑞撖銝氳oot

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

. W: g+ T2 q4 c* Y' H- _2 Y# C

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


- _9 w3 j. V' T. D, }: k

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


3 R, d5 M$ }; G& V& h

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.rpm8 s/ E/ Y% j/ O# l, ]
1 o& j$ o" d/ g1 R+ X
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
! q9 ?% U2 t3 Q* R( X5 GCreate /etc/yum.repos.d/php-fpm.repo file and add:
3 h! W/ L, w3 @( {
  1. [nginx]  x5 z/ d. T/ ~  E* ^0 J
  2. name=nginx repo, f" ]/ t3 J$ W. ~
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/6 z  f0 t) V% {  q( {
  4. gpgcheck=0
    : a/ L9 s4 @: C: x+ C
  5. enabled=1
銴鋆賭誨蝣
. Y0 V2 l2 Y( s
yum --enablerepo=remi,remi-test install php-fpm  X: _1 T. u6 m' J0 Q0 W
$ x6 C4 h! q, \$ R% |& Y% ]2 T  T

, [7 M4 K: ]7 q$ m5 [鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn: b/ |. Q2 `. A# n& n/ X4 u

嚗yum remove subversion //貉蝸雿祉svn( t: i, x0 N% G4 V

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
/ `6 v9 d& ^+ _

餈# 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]6 z: p* g+ D. R( y
# harry = harryssecret+ Q; m, F5 a6 K! X, g
# sally = sallyssecret
, H* M1 G& ?. ?8 V1 |8 fwangning=wangning
! K+ M2 Z- B! y8 ^; V+ u6 {% myanzi=yanzi
. j( K3 D% M9 m; b

#vim authz  //霈曄蔭

3 V+ h! @% f8 |; t6 y4 ?4 k( V( X

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none9 t6 G) D5 p  r) ]/ R) _6 D- w
auth-access = write2 ]% u/ v6 H% q# p
### The password-db option controls the location of the password0 O' V! @  U: ]/ k
### database file.  Unless you specify a path starting with a /,1 E! P: _/ W+ T% H; W) R
### the file's location is relative to the directory containing. n" u3 s* s  F$ ?# I- B3 e
### this configuration file.
0 j3 f/ s5 t. w* f7 r$ V### If SASL is enabled (see below), this file will NOT be used.
! g: y  q/ u1 x- o( T6 ~### Uncomment the line below to use the default password file.
! p; L) U- W  ppassword-db = passwd
5 o: W4 g( ]* r### The authz-db option controls the location of the authorization% k4 D" ~9 E: @% e
### rules for path-based access control.  Unless you specify a path* @. C1 h$ t2 T4 i/ J
### starting with a /, the file's location is relative to the the; A& t9 M& Q/ X7 B; T$ A# V# V( P
### directory containing this file.  If you don't specify an6 s7 z2 f6 Z- r' V8 M" J  w
### authz-db, no path-based access control is done.& }& C2 q+ W/ G% }4 y3 Q- R  ~
### Uncomment the line below to use the default authorization file.
- u7 ~# E" `$ S! P* r7 Kauthz-db = authz
1 y/ R" R% [# z5 y* c" b( {5 g### This option specifies the authentication realm of the repository.' s) k0 G, d' G8 U; ?3 ^4 {4 X
### If two repositories have the same authentication realm, they should
' }% A) U0 n1 {! @, U: K### have the same password database, and vice versa.  The default realm
  U* K$ y! ^- [& x' a### is repository's uuid.. J% {/ O/ _. x, n5 w" ^1 H
realm = My First Repository" E6 N" H2 f$ ]: ~4 k& g

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
3 M8 {' X! g- @/ C; y7 a6 B

#killall svnserve    //甇
2 K+ v1 E' n  t/ e, ^5 o  c( u

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
+ N' p* w) D+ c9 e; B! r

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
' _0 }& h& S4 x& F

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

vim post-commit嚗券Z伐

+ y4 J* R: ?- m! Q# X# a6 q% G

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" :, l0 [( s7 ]- m* O! ?

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

. C0 Z# ]5 w+ X; [
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


: X/ h. H/ G1 ?) E  dvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿% T( ]' F4 t3 \5 Y

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-1-27 11:30 , Processed in 0.071243 second(s), 20 queries .

蝯∠.撱

[email protected] | QQ:2405733034     since 2015-01

鋆貉憒 敹恍敺 餈銵