52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
  s5 ?; `, ]8 C% v9 Y' `& j' a( N, s! }5 [" D- F$ E- k8 p

格嚗剖遣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% G3 u4 y( Z3 L

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx4 P8 V4 r2 Z, j# D& H2 Z

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
  k2 g+ Y! |, I( _6 F/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" d& r/ S  ^* m
4 }/ K2 x5 v  M# K" _! N0 Y
chkconfig --add nginx; n; m, e) [# t9 v3 @
8 o* i$ n5 g: ~* A" h& F4 B
chkconfig nginx on
" \1 C/ r! Z6 u- x4 {$ u

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

#!/bin/bash
" }1 z! F6 z( S; G! C* B; X# nginx Startup script for the Nginx HTTP Server
. k8 w" _) S1 C# it is v.0.0.2 version.
2 w# C" d, q" m. H! w$ U, B# chkconfig: - 85 15
6 i: p: h5 l7 L: e$ r. W# description: Nginx is a high-performance web and proxy server.
. X9 C6 H( U  [9 J/ a# It has a lot of features, but it's not for everyone.6 i1 \3 r0 u! f4 k* c8 r
# processname: nginx
5 S1 z, S, M* O3 _# A: _! Z. o% v# pidfile: /var/run/nginx.pid/ U! j" Q: Y( R' e& Y
# config: /usr/local/nginx/conf/nginx.conf
. V3 j% t0 K. N0 W( vnginxd=/www/nginx/sbin/nginx( x. u- t: e9 W3 e
nginx_config=/www/nginx/conf/nginx.conf
( Z- a1 u5 C+ g$ Gnginx_pid=/www/nginx/logs/nginx.pid* r  M% K7 q7 K) `
RETVAL=0! n' F9 z4 p/ A4 V; @/ `3 |  I' Q
prog="nginx"6 v$ `; C4 s* M  @3 }" z
# Source function library.: r+ p( o3 H# R3 W# x' O
. /etc/rc.d/init.d/functions9 [% U9 I. e! E! ]
# Source networking configuration.
0 X' q6 P7 o* Z& i+ T7 o5 k' X. /etc/sysconfig/network6 d8 y0 I/ G' w* r2 {  N( P- S" P. K
# Check that networking is up.8 F' f0 U6 G2 V. ^% q- D: m% ]7 E6 H
[ ${NETWORKING} = "no" ] && exit 07 W& m2 v1 i, P- w$ ^
[ -x $nginxd ] || exit 0( s. c$ H$ O; h$ J2 H" s  [
# Start nginx daemons functions.8 K& s) M, a; l8 [/ h( h- Y
start() {
* v9 j0 W2 W# \if [ -e $nginx_pid ];then2 i$ U8 _" o4 m+ L! }4 E% E. e# S
echo "nginx already running...."6 k% M* J9 N9 q3 x
exit 1& @( @4 B$ G% \0 k6 O% Z2 o
fi- S7 j* @' q7 c* ~. ~
echo -n $"Starting $prog: "/ l- {: a/ S  u1 J# ]$ \/ q( l
daemon $nginxd -c ${nginx_config}, ~) j: q4 w* C9 W" e+ j
RETVAL=$?% n% _+ Z: ?( L( J9 ^
echo
6 q; p/ _% S4 W: m5 e) u[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
# g$ u/ o* {6 P8 _2 E6 nreturn $RETVAL. @4 c* r, o; \- i* B+ l
}
* ?$ R; b% h1 Y+ F' P# }0 Z; t# Stop nginx daemons functions.
3 }( ~* v5 C* ~  D, C) O3 Qstop() {/ v' o4 [6 k" v) F$ p, n
echo -n $"Stopping $prog: "5 ~. S1 ^+ k6 i) O1 O2 G& Y7 S
killproc $nginxd! Q! S, A& d. o6 p8 d+ i
RETVAL=$?) x1 M( E4 ?$ y
echo' E2 d9 {# I" Y: r1 R) Q- C) {
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid# o  V6 y5 j7 d  L* w
}
) e. j- Z) ]$ e" H3 r$ Areload() {- W! N1 ^. n! _4 h8 h: P
echo -n $"Reloading $prog: "' b4 k' A6 `) ?* a
#kill -HUP `cat ${nginx_pid}`; \" S+ `% k! u1 B3 b
killproc $nginxd -HUP+ G  A  Q3 Z8 ?1 L+ Z: |$ l6 V
RETVAL=$?
. b! H7 B( S# G& n8 \/ R0 oecho
# j# z5 L1 J$ M; ^( `' O3 f) A$ c}
9 f* y, k' |( r" W3 c# See how we were called.
2 P/ P: \/ s& [$ tcase "$1" in
* J) L/ f/ f' ^: a  ^7 _  vstart)
2 ^5 }/ n" y% o( kstart6 B/ N3 O% {) T# T3 o6 E0 u
;;
( M; T$ X# [( g" S1 pstop)$ R; J  P( h' Q8 }" \1 l
stop( F$ d9 e' E/ V3 h# T% C/ l$ Z7 d: C6 f
;;  n, i1 b) O) _- _' W
reload)
+ ?  @$ u3 D0 |' ~7 Yreload
: S2 H  ?0 @& p  w$ G;;7 k) _" j# b4 K* i
restart)5 k; @2 p0 B" Z% D
stop- B! C! W& ^! r9 \! D
start0 q. i& ]( Z5 f) x/ b4 O5 x/ F: @3 U
;;* Q2 Y- {- s5 h+ Z
status). v" Q( Y9 |$ j! d; Y: j7 O3 z
status $prog
) F) K6 V/ O5 y+ n& d* SRETVAL=$?
( a3 N$ J3 [( J4 A$ R5 Y0 L;;' {1 P4 P1 R0 h' z1 |6 q+ u% I
*)
3 {* n- T6 c) a% @7 Vecho $"Usage: $prog {start|stop|restart|reload|status|help}"+ C- k% U. C6 k& H8 O; H; _, j
exit 1/ Q+ `; D) U! c" n- t" c
esac2 g: [- c- O+ |2 ]( e
exit $RETVAL+ d: X/ P1 _, H  u8 H) m  |1 ^# W

9 |2 ]  u1 l8 ~4 P) S

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

( ?# m& J( ^. ~4 y
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗1 K% T% c! m+ C# |5 ?

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

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

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

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


3 K% O/ L1 I, F. @       location / {$ b; g' o: U& A$ D
            root   html;
0 l( |2 s4 j( R. `            index  index.php index.html index.htm;
; f$ B% o8 X# Q, _" k        }
5 Y. h0 q4 o, B靽格嫣蛹嚗
( ^- ^6 g0 O! x7 ^/ ~. N9 a3 e- B. O; c' ?& B* M7 ]

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


; L6 ^5 b! P4 \* k6 o% D7 t2 Rlocation ~ \.php$ {: o4 p1 o  y5 f* k7 u" ]2 D* |
            root           html;8 m5 d3 p! U& t# H& {
            fastcgi_pass   127.0.0.1:9000;
# q  R3 j" H' Q4 O0 U& Y4 T            fastcgi_index  index.php;9 f3 K# a9 u. ?
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
6 Q$ B0 D: O+ m4 z, H9 |            include        fastcgi_params;) N7 ^/ L/ i# e0 C1 k5 S( j% ~" C
        }
- t0 T& ]8 G2 d* g. A靽格嫣蛹嚗
1 ]5 M- |# @7 J. a, ^( s- G
6 Y0 T# }2 X' s( ]. P/ \7 i

        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

閫蝻拙僎餈唳桀嚗扯嚗

( [5 H  ]3 X) ]& A9 K* d) s

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql* \4 g. ]0 \/ q5 K) a' C1 A
* m& s; P( E8 g) W* h# e
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏/ P& M. [, U/ p8 S

cat /etc/passwd 亦冽瑕銵
1 T+ y; G  @7 w4 q! L# _# ncat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
0 R* b. n( K, j1 @) A( G4 {. e

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql2 _8 e- X* E" Q" {1 N

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql7 Q4 y; k6 N9 F
chkconfig mysql on
% r: h7 i1 u. @$ Tservice mysql start  --臬決ySQL4 v) V7 L) n* S

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH, j+ a8 V1 J) h+ `2 O
export PATH; h" k# r+ @; L7 d: P) H

靽摮source /etc/profile

扯嚗

& C0 M* b+ q8 F# |5 S
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
3 M, b9 l1 X$ e6 b8 i( B

; v4 ?4 T) _  C/ @* ~  y

霈曄蔭root冽瑞撖銝氳oot

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

3 g3 ~- `, S# o: j

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

4 L; ?) b3 s  L& O  Q# w4 M' \

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


; |9 u) ~1 \  @' U' S& d. }6 l

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
8 _( P9 n5 ]7 N2 {  X5 d
' @2 a4 I7 }  K& `rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
) M2 A& t9 K1 z. O; q" I" h2 OCreate /etc/yum.repos.d/php-fpm.repo file and add:2 W# u# r3 W, K! X# G9 q
  1. [nginx]
    4 w1 ~& d" p! k
  2. name=nginx repo* m5 _- D/ b9 s& z
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/! K# G2 v2 d8 q" t. h: o, v
  4. gpgcheck=0* L$ C- o- g- S8 N2 k# [
  5. enabled=1
銴鋆賭誨蝣

5 |8 j$ I3 [0 U* b2 a  eyum --enablerepo=remi,remi-test install php-fpm
5 v  b, g$ L) H$ J# J4 Q$ u) z/ ?0 S: Z9 X3 A- A

  S" d# z/ G0 H9 G鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn9 P0 V, {' A' N  o( L

嚗yum remove subversion //貉蝸雿祉svn
4 U& a: a( D8 I' f* Y0 F

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn) N, x9 |( E& w# |8 a- y5 ]5 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]
  J) `* T* L) v: q" {. A. a# harry = harryssecret
: f4 O: M" g' A4 o# \/ c1 W# sally = sallyssecret
& m8 O7 ?- X9 ]4 ^9 T% N3 iwangning=wangning
! r' \! q1 V; V, [8 dyanzi=yanzi6 b+ ]$ |& y& l& N. r) U3 |

#vim authz  //霈曄蔭


, |! I' X# j% y

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
' o/ H) o: c4 i! x) Aauth-access = write
- h. K  o" M  C# ^& N8 s### The password-db option controls the location of the password- W+ A  T! ~3 T  h
### database file.  Unless you specify a path starting with a /,
" ~: r0 p# [/ s6 ^4 L### the file's location is relative to the directory containing
1 f8 Z) v9 J! }+ a# a3 C/ Q# j### this configuration file.
" f, n+ _& y* p0 [/ I, V### If SASL is enabled (see below), this file will NOT be used.
( ]% b: F7 q) S/ z; d; U* m### Uncomment the line below to use the default password file.
& O) r) U; n6 x% k' x4 L) g2 Wpassword-db = passwd
0 ^4 v7 L( N8 y6 t4 Z1 z" N) `### The authz-db option controls the location of the authorization6 C/ c5 |: w- m  x+ e
### rules for path-based access control.  Unless you specify a path
: U- Q; Y7 M0 P4 I1 N8 _### starting with a /, the file's location is relative to the the% m5 S+ ~! e1 O* y8 P/ J4 C! F
### directory containing this file.  If you don't specify an
4 a4 b; f) j9 o### authz-db, no path-based access control is done.5 h: f! M7 K& b
### Uncomment the line below to use the default authorization file.
3 c6 ~, v6 G' w  cauthz-db = authz
# O( v/ Y1 L. K- {### This option specifies the authentication realm of the repository.
7 T+ x: }0 \% e* j. L### If two repositories have the same authentication realm, they should% [; \& m7 T6 A& W# O9 `4 D) M8 G4 J
### have the same password database, and vice versa.  The default realm
- E8 h4 w) Q0 o/ a" J% |### is repository's uuid." I* o4 X, ^! @! k
realm = My First Repository8 Q% Q4 _, x. }% T  `: z1 j3 G" |

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
+ x" h8 |8 Z/ z

#killall svnserve    //甇4 v! b$ f2 r8 @( a

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
- a( i" j8 ^  G0 K4 s

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
: b0 ?7 L; z7 m

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

vim post-commit嚗券Z伐

& b' x9 ?, Y% F' u

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" :0 e& Q+ d! R0 Y' l- ^, N

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

6 E! L  s  B6 }
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


+ r  `4 O( I; h. g' Q( Y- T. m( Gvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿# W$ M1 ?# ?9 p# ?

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-20 09:47 , Processed in 0.069640 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵