52AV璈A|52AV.ONE

 曉撖蝣
 蝡唾酉
敹急瑕
  • av隢憯BBS
  • 璈A
  • 芣瑟憭瘚
  • 鞎澆
  • 52av鋆貉摰
  • 銝剜-銝剖銝餅
  • 伐AI璁函移瘛怠伐
     
亦: 3901|敺: 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 G2 ^8 o9 _6 M
/ {% S, l3 c8 D5 x$ l  J( ^4 \

格嚗剖遣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 cmake4 U4 O- K+ q: }' p

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
' Y7 d: b( H5 e6 V: e5 [

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
+ N; `, h; K( u+ N3 Y/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx
' N+ @8 A6 `. \( d# S: i6 Z2 ], A- p  j2 p. Y
chkconfig --add nginx
8 H( ?& ?- r0 H8 \1 O* d6 u
: `5 m. B- Q9 ?+ A" B5 D# S- Ichkconfig nginx on1 l/ W+ e6 S7 P# b

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

#!/bin/bash
) i+ r. D4 R6 d0 q% P. [# nginx Startup script for the Nginx HTTP Server* Y) C- [/ Y! z9 B3 o! A) r1 r# [, a
# it is v.0.0.2 version.
+ d# l0 d, @% ^2 j4 S, }# chkconfig: - 85 15. x  h5 V: C3 N' ?8 {- m( R
# description: Nginx is a high-performance web and proxy server.. b/ x) e2 q- ~" }4 v( I- K7 P9 F
# It has a lot of features, but it's not for everyone.5 }( M) d8 b# r: c2 h, _
# processname: nginx
1 |$ c) a+ ^- W8 a1 d# pidfile: /var/run/nginx.pid
1 v. b$ l4 Q3 A' U/ D# config: /usr/local/nginx/conf/nginx.conf
0 `$ ~, Z4 h# Y/ c/ \* Gnginxd=/www/nginx/sbin/nginx4 k2 M- [+ l. G) ?
nginx_config=/www/nginx/conf/nginx.conf% b: o8 v$ s* @; C6 n
nginx_pid=/www/nginx/logs/nginx.pid
9 C0 H* J1 i6 wRETVAL=0
+ O  k) E: H4 o) z, F6 Eprog="nginx"
1 C- o8 c% g) ]( Z# T* e2 o0 k1 |# Source function library.
" M! x! e% j; W7 w5 [! k  A. /etc/rc.d/init.d/functions
9 @/ e! _* _* [) I9 T  D( H7 V# Source networking configuration.
$ ~/ t% r" {3 W. /etc/sysconfig/network" q$ \% W* x; c& H
# Check that networking is up.
; T: b. y2 C5 \  e7 q[ ${NETWORKING} = "no" ] && exit 00 v6 ~- q! s1 O+ V+ S& }/ D
[ -x $nginxd ] || exit 06 z5 H- t- c0 j' r8 t0 W' S
# Start nginx daemons functions.( m! Y0 y6 J5 V; u, X! Z
start() {
" z7 r( Y" d, s' hif [ -e $nginx_pid ];then
3 N3 z, A- J- _# d2 _* e# eecho "nginx already running...."8 ]* m/ h& a. C4 f! ~+ i! K9 {
exit 1" k  u9 O7 h; f" n9 @5 t
fi
' E7 c# \9 Q% c. C: J# V- l" necho -n $"Starting $prog: "& l+ p% W2 S8 I  b9 W" M/ o
daemon $nginxd -c ${nginx_config}
% e$ V, n) M; q' _: J& T8 ZRETVAL=$?% t, u% H3 g. U: e
echo
- l3 D; K4 Q& K' g( Y[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
$ {6 G7 Y  a2 o" X/ hreturn $RETVAL5 a/ U! H' Z* {+ M% O" \9 m
}
! o4 |! x/ \: h8 b4 I# Stop nginx daemons functions.
; s" u' c7 k! w& a& B, gstop() {
+ z9 T& e; U$ J" hecho -n $"Stopping $prog: "
1 F( z% W* t1 ^  i. J/ C* V4 }killproc $nginxd8 Y/ _7 f2 \3 u2 c; n; S; U0 }
RETVAL=$?
" ^2 a8 ?7 B) ~- F/ lecho8 b5 e7 V. i1 @, [* t' g2 E, P
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
) x4 _/ d1 b: h, b- S3 p}6 x2 G$ y% _. r7 d: M* H- O1 g
reload() {! E! X# {# z' w( S5 \2 k( s) k! z
echo -n $"Reloading $prog: "- ?7 k1 B* h) S: z. r, {! S; j
#kill -HUP `cat ${nginx_pid}`& p2 \% V& a3 _2 n* J
killproc $nginxd -HUP# i/ G# f; J4 Y
RETVAL=$?
. g0 F6 c. t) Qecho
1 l, p9 W, S" J}
. R$ c  G; O& Z, I; L# See how we were called.
8 [; G  |2 k' `: i! V& ecase "$1" in' y; j2 D* ^1 V! ?. S: |7 G4 h3 W
start)8 [0 ^7 \; d: W; }7 C4 B
start1 m# c! r" @  D; Y1 P: l( z
;;/ x) T7 a9 G6 w) V9 w5 g5 I
stop)
$ x" K. X2 ~  Y4 J" l3 vstop* g& y/ A6 f  I* s
;;
" p- o: i4 ~8 c* i1 R1 y, kreload). R( I+ M- w% p. N- x
reload3 S& K5 m( l( H+ E' c
;;1 }2 O0 Z% `  Z$ }) C! A
restart)
8 u& a! w$ p- G5 c" E$ Lstop
& ^0 P, I" r  Mstart
( w, k2 s6 h  M9 o. A, [;;& W! ~: ~1 R# y  E: {. Z
status)( `# E, G( `- J2 s
status $prog5 U( _9 T! E6 k
RETVAL=$?6 J9 ]( g1 u( T4 a, N. k; ^
;;8 d& i6 n7 o" Q: G) f
*)
, _7 @7 l  M" a1 X: v8 J9 secho $"Usage: $prog {start|stop|restart|reload|status|help}"% \+ x- z# h# L
exit 1
0 v7 W/ _: S/ oesac
5 z2 [5 p$ g4 P2 eexit $RETVAL. {2 |% _3 x2 E# O/ g) c& q

9 q( }( f& s$ Q; ]) L/ V: X( P

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


$ f" G6 Y( ^- }0 Kchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗6 @; `" S( D$ L$ X

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

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

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

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

- q- F0 Q7 c' G  L9 n
       location / {
' t% |& V" ?7 p: Z' K( e            root   html;* R( M9 H8 x+ z- v$ x9 @) l/ N# S
            index  index.php index.html index.htm;5 Y/ m7 r  ^: w0 a
        }& ^5 q# o8 B7 A; G
靽格嫣蛹嚗
- e2 u9 Z# G+ v/ J- {' p0 O+ K- r
* G5 z% Y  v- u7 s

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


0 f* }* S# {3 hlocation ~ \.php$ {
( y) p1 [7 w3 I. K! p; G            root           html;
8 ^3 c' F+ n) R8 V3 i            fastcgi_pass   127.0.0.1:9000;# I3 c. A5 [' Q, j' R# \9 w
            fastcgi_index  index.php;
) E2 ]& l$ a% }8 C            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
9 S. `/ s. U$ R$ ^) u            include        fastcgi_params;
- g! K! a0 e& ?8 V        }" G/ |% X" N5 @" W! E+ s! n
靽格嫣蛹嚗
( c$ H" J8 D6 @+ i% \$ c
: L$ F8 A9 c& c  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

閫蝻拙僎餈唳桀嚗扯嚗


' f. p+ L  U) h

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql5 D, u9 o# |" K2 x5 z, _* s
2 G8 T! J; y! b2 _
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
6 Z% N$ f( U, R

cat /etc/passwd 亦冽瑕銵" T. Q' ?" A. Q( g
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀* P4 U/ ~* W. Q2 c& U! @  p- }

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql9 K$ Q+ K& g) h& T5 X! {% ?

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
! q# ~: s6 j: R9 g) r5 `chkconfig mysql on$ n$ P1 d( @( w( q( d8 c, T$ h
service mysql start  --臬決ySQL
6 b: T/ c2 t! J& C8 `$ A

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
" m" _. f3 v; z. q6 B0 dexport PATH
* `5 ~6 L, D8 E" A+ u5 _4 B4 h# `

靽摮source /etc/profile

扯嚗


9 v6 h% I+ q1 u5 A( mmysql -uroot  mysql> SET PASSWORD = PASSWORD('root');, W" G* f' e4 K3 A
0 h8 p8 F( M* e' c% A! Y3 L: y5 c

霈曄蔭root冽瑞撖銝氳oot

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

0 M  H3 G' H' J1 `( o! l

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


* ]: j+ E/ U& g& I! y: \9 P

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


% K" @& V, x, [) y

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. j7 w, g$ ]: m8 _$ ^

7 d- \1 I  E" j6 S8 erpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
8 q: g  s+ |8 [9 |7 [$ V& e8 {Create /etc/yum.repos.d/php-fpm.repo file and add:: m- v& i) l& R; y) W/ c
  1. [nginx]
    5 E) P0 ?9 o' M& L
  2. name=nginx repo+ [$ s1 ?# F' C2 |) G+ v
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/% x& M: H: d0 [& Q- M5 T
  4. gpgcheck=0  g8 G/ X+ ^! [1 m8 M
  5. enabled=1
銴鋆賭誨蝣
/ `" n% G1 a* k( X+ G
yum --enablerepo=remi,remi-test install php-fpm
% n7 M- U" ^4 ?$ a3 H, q* ]' L) v9 Q$ `. P
! y# K- T1 v: `4 f$ J  b
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn3 [- q- e) D. h+ ?

嚗yum remove subversion //貉蝸雿祉svn
1 y0 Z5 l& O4 y7 D5 Y

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn  H$ G) G" \: A- \/ c- y# r* 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]
: c7 S. a$ w* B" S# harry = harryssecret
* n. c6 K7 l/ S( K& C: U) S  P9 G# sally = sallyssecret
' r2 H1 z9 {& a6 M' `wangning=wangning$ A  Z% |6 c! p; T4 T9 y8 ^8 m+ L  ~
yanzi=yanzi
+ l0 O  e  J! Q& g

#vim authz  //霈曄蔭

5 s2 y8 k# }* I5 l# J0 j4 F* e

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
! z) R2 @: y7 W7 u" mauth-access = write1 ?1 R2 h! ^2 M8 h0 ?
### The password-db option controls the location of the password# ~$ }- s4 k* \7 s
### database file.  Unless you specify a path starting with a /,3 G. ~3 x' T' `  @7 v
### the file's location is relative to the directory containing2 Z3 h! G6 [( J9 C- s( P
### this configuration file.) E2 S2 {8 T% S9 i" ^# T' t
### If SASL is enabled (see below), this file will NOT be used.- S9 q* F4 N, _" p" p) L( P* A
### Uncomment the line below to use the default password file.
4 r2 Y1 ^. o! G; v. M3 Xpassword-db = passwd9 [; t) ?, F/ P" _! y) }
### The authz-db option controls the location of the authorization
! I- O; j' x" B" k### rules for path-based access control.  Unless you specify a path+ b; j+ ?# H! ?5 s
### starting with a /, the file's location is relative to the the
3 C1 ?! d# m) v### directory containing this file.  If you don't specify an
4 X$ U9 H0 d5 g* {) |### authz-db, no path-based access control is done.0 P4 e0 ?9 y& U, \& L. k
### Uncomment the line below to use the default authorization file.7 y' ~( f$ j" @; \% W1 Y$ m
authz-db = authz9 w7 Q* v8 R/ G: u5 I& J
### This option specifies the authentication realm of the repository.. I5 ]% i8 ~! |4 G3 j
### If two repositories have the same authentication realm, they should# a2 x# o7 H$ L
### have the same password database, and vice versa.  The default realm
. r$ s8 K8 F' R### is repository's uuid.
+ O# o1 f' P+ urealm = My First Repository
" k7 P. n/ ]/ P/ s

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
& a( g" o: d$ ^7 C  G

#killall svnserve    //甇$ i( k7 t! \: ^9 s3 {

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx  [  a/ e  J* `6 {

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
" S  X9 o7 b1 K

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

vim post-commit嚗券Z伐

3 K. }/ e' N( Y) C8 X; {5 k

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" :
$ E) a  a7 \0 T9 M

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


/ b& t, b$ k) u+ ^0 ?! b) s. c瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


9 V3 \2 O! U% u) d+ A1 b; A9 A' svi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
3 [: e( a. S8 K& E$ W! M% N" U# j% I. g1 j

雿輻券

祉蝛閬

撠蝝詨

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-10-21 17:39 , Processed in 0.072150 second(s), 18 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵