52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
# \- R2 @  ]" h8 ?4 ]! A3 v  t. N2 E; x4 p( p# o8 d6 x! k- Y

格嚗剖遣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
( T1 u1 j+ `7 {: ?1 p& M! Z

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
  t$ b# `- |  \* x

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
* I# |6 D! m9 i8 |5 t. n7 ^/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx) V: R) T3 [9 Q2 k4 C7 |; @& c

+ a3 {( C9 o! c9 G7 schkconfig --add nginx# k. N( [& A$ @3 }( |* d+ `6 M% ]
; k$ I4 u; ]. g, b$ V* q1 G
chkconfig nginx on/ H# J$ y% ]$ \

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

#!/bin/bash4 @3 r0 Y* U6 \0 ?! R+ B
# nginx Startup script for the Nginx HTTP Server
) Q- F" ]$ c/ I1 `' @9 h: N# it is v.0.0.2 version., P, c5 z8 Q( x9 _
# chkconfig: - 85 158 E3 o6 Y5 X, N( ^# t0 i
# description: Nginx is a high-performance web and proxy server.
4 O6 ^$ p+ Z$ g% H  Q) u/ y% e# It has a lot of features, but it's not for everyone.
3 H( G3 ]7 i2 y# n5 z5 t+ Y# processname: nginx' Q8 ^+ {1 o9 ], k$ P5 f6 L
# pidfile: /var/run/nginx.pid
+ e2 r( t6 e8 L# config: /usr/local/nginx/conf/nginx.conf
: R7 ^+ J9 l5 K5 rnginxd=/www/nginx/sbin/nginx3 X+ B; s9 C/ O: W5 [- Y- \& i
nginx_config=/www/nginx/conf/nginx.conf) ]; x: n! K' {  D+ O
nginx_pid=/www/nginx/logs/nginx.pid
( M# r+ j. v  i& q* w, L# _3 YRETVAL=0: z  x) P$ x( ~% C8 O) ~
prog="nginx"
/ z* l1 f6 O7 R4 V3 L9 F5 X# Source function library.! \8 O$ E2 Y% F+ `
. /etc/rc.d/init.d/functions: j/ }: x2 K' k  X+ M- K
# Source networking configuration.. u; ^7 \/ |2 U: ~- s/ p& J
. /etc/sysconfig/network
; T- V7 ]/ T/ I  @# Check that networking is up.
  t- @; l. U! r! B% Q7 m2 n& C[ ${NETWORKING} = "no" ] && exit 0$ m1 X- [) ^" w1 {" H6 z. r6 q# y# N4 t
[ -x $nginxd ] || exit 06 ~) \9 m, F' ^# n7 x
# Start nginx daemons functions.
; H4 K6 W# _3 Istart() {, _( g0 Q; L" B: }
if [ -e $nginx_pid ];then) L3 R0 {5 d6 R  F* K
echo "nginx already running...."
) E" ^/ H& K: b* L) sexit 14 I% S( V5 X+ t5 C
fi
& T7 B( H' U' d7 kecho -n $"Starting $prog: "
  L6 |# f2 B- B6 C$ qdaemon $nginxd -c ${nginx_config}
: a/ i) L! N6 Y2 ZRETVAL=$?
. o# d) @4 [: I0 A& zecho" R6 l: ?: u) {6 h- |
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
7 t/ Z6 F1 _) Areturn $RETVAL
8 z( m" Y$ S: J9 F) r! R}
8 g% i. W& {0 r" k5 n/ @6 Z1 j# Stop nginx daemons functions.
/ P% P$ i& i( L" ?- F) j. Dstop() {& R/ [3 d" p- m9 K/ M, u
echo -n $"Stopping $prog: "
- ^2 S* P, o: a7 Y1 W) hkillproc $nginxd
* f; V8 Z5 Y6 u5 MRETVAL=$?$ P2 b5 r2 s4 Y) N& m
echo
9 ?  o3 f  b6 [[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
' X3 H& Y; m% |$ ?- n- k}
6 D0 a5 ~% r; nreload() {# M6 p5 a0 i/ {; }
echo -n $"Reloading $prog: "
! o1 x8 [* E0 i* a4 v#kill -HUP `cat ${nginx_pid}`3 h* y' z# X; I; i- r
killproc $nginxd -HUP- w  p* v1 K5 x
RETVAL=$?
) J! C# Z) g; n1 w0 b0 yecho% x1 R% h* {4 A+ j. g9 ~
}; p3 h% I8 ?0 i/ G/ {) b
# See how we were called.# g1 s% l- C7 h. x
case "$1" in
; ]6 a- ~, s$ f1 [  k1 Tstart)
/ h7 I5 j7 l* zstart
( B1 s' o+ O% j3 ~5 |, G;;) F4 x) W0 A5 {& _+ _  u( q8 q1 Q
stop)
+ a8 |2 O# ^! F" N  l( Z% sstop7 S% ]. I, H: }0 X
;;5 _4 A5 \9 i+ Q+ c8 |- ^: N( T2 C
reload). o& k, q/ I4 e' B8 P: b
reload
$ @  C6 O% ^7 \;;
+ _- S+ H* |# ?- a; Brestart)
7 ]- U2 y- h5 O3 Mstop
6 m5 }. Q' [) v7 u7 M  gstart
' c) O0 ~; |' i( t4 g! d- J+ w8 f;;, B  T5 n. S" `8 _" E0 s
status)
! A9 }1 @6 @$ K9 ystatus $prog, N* q( S: j# \- l3 u
RETVAL=$?
/ H  j( n& ^! k5 P;;2 x6 T( m! l! }" C
*)$ p1 C* O6 l2 L- G3 q1 b/ B. g  P& h
echo $"Usage: $prog {start|stop|restart|reload|status|help}"9 o. p5 d% @0 Z6 l1 i# ?; V
exit 17 {* r; v6 b+ W" q
esac
' j0 @# |6 ]' gexit $RETVAL7 t% J8 z0 i  E; p  o
4 e' T+ u, y; g$ Y( `9 U% F

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


. @! f1 p# O: S! o$ H6 ?. ]chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
8 Y- T2 A% q7 Z! l) M" B

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

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

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

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

- j' E- [# T! J" s7 D. O$ A5 F
       location / {
" Q( M" I+ Z* \/ f            root   html;; ?' [; H& k& t; D+ d6 w4 Y' a
            index  index.php index.html index.htm;7 k4 }# a/ m& j; r) L2 K* r
        }6 R4 S8 E$ _; I: {
靽格嫣蛹嚗- P6 I1 C. @7 a. J; ~* E+ O

( R0 X. C7 g& s. J

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


, J8 u0 F# x9 x7 |location ~ \.php$ {0 j, s) P6 F. V4 E# n" @$ Y" V) b
            root           html;
2 ]: I& s9 d0 @& e( N            fastcgi_pass   127.0.0.1:9000;
6 u1 D* |1 X, e5 v+ }" g1 }- L% F            fastcgi_index  index.php;
) Z" ?  E; u: g( V& ~" e! g" c; Y            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;$ I# ?! b3 O4 A
            include        fastcgi_params;
& y/ @/ y6 c& t0 y' j4 p1 s, [        }; D. ]# |, g# {( Y9 A0 z
靽格嫣蛹嚗  u) |( j- u" R) c" Y

0 D0 x) F: A" |7 q/ a1 O" j/ o

        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

閫蝻拙僎餈唳桀嚗扯嚗

  E# S& t7 x9 a8 |+ U: J" g- V

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
" m! y5 f( J- K1 i
- d6 S" J0 s9 p2 H8 G0 n#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏+ \" ^! R! V7 T% B* x

cat /etc/passwd 亦冽瑕銵
" t# J4 e- J2 k$ Q4 Z3 ~  c( a9 hcat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀9 G  e! E+ f" Y

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql! ~) l# Z+ u; L' L5 n

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
3 T( `+ C% c. @2 T; fchkconfig mysql on
* G5 g; v" S, y' O4 P( c0 Mservice mysql start  --臬決ySQL. \6 h" ~/ k) o$ r( m: X

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH0 |' B8 Y3 }3 u9 H8 u$ J$ }' F  v
export PATH
/ M2 b3 u) {. F* k1 Z+ ~! Z, M

靽摮source /etc/profile

扯嚗


. z( f+ s% ~8 x8 T5 V1 V) ymysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
  w  _0 H! B0 u9 J* N% k+ f

" r& }4 u9 _' j. H" `% q$ c

霈曄蔭root冽瑞撖銝氳oot

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

" d( z2 k# Y1 f

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


9 h+ \; \& t0 a( @, L' n! Y5 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嚗


: d) N0 r4 @# _: e- m

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
7 t# n3 D! P/ k) x; e- f- c# N
  O3 a' N+ U3 o6 Y" rrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
  e8 f/ T/ M+ \Create /etc/yum.repos.d/php-fpm.repo file and add:
7 |1 {1 _5 x3 [; e
  1. [nginx]
    0 F$ E5 f7 D1 H1 M' Q# K- F
  2. name=nginx repo
    : D2 c6 Q+ Y% {- j% N/ G; a
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    1 z) i8 @8 y) M  }* ^# f
  4. gpgcheck=02 z* ~1 u9 H4 H- r
  5. enabled=1
銴鋆賭誨蝣
. j/ n2 X$ f0 f. q) ~0 ~) t; U
yum --enablerepo=remi,remi-test install php-fpm. _$ a9 L  J" k& b5 U
3 I8 w5 s: K: h$ H2 R

7 g- K! `, W7 A) c2 d鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn, |! q& Z: `% k+ Q: k

嚗yum remove subversion //貉蝸雿祉svn
5 _. b) b" K: |1 {: L( k

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
( i/ A# q, x% ^- Z

餈# 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]; D4 o( H& h6 _* N; S
# harry = harryssecret/ l9 S  Y0 \" `7 T  w. F7 [
# sally = sallyssecret
4 n4 V  B: a: _3 v6 r! dwangning=wangning
# O  V! x. ?$ E; ryanzi=yanzi
4 }- z+ f3 |/ S% v! ~7 A* O

#vim authz  //霈曄蔭

; R! u( |, U: x3 K

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none1 m) g, A7 d$ V; }" B+ u
auth-access = write# {8 u8 ?4 |. S
### The password-db option controls the location of the password
7 |. q$ c& a4 r% @  D### database file.  Unless you specify a path starting with a /,$ i' q9 W6 I* T; k, z5 I% u6 f
### the file's location is relative to the directory containing
; n, q. Y9 ~, Q5 T6 A### this configuration file.. t: E- F0 \# v3 V
### If SASL is enabled (see below), this file will NOT be used.
) e1 h! G4 h+ e; g( G; `### Uncomment the line below to use the default password file.
' D! W2 B- V$ I5 h) [password-db = passwd* C% O# b4 M! P9 U
### The authz-db option controls the location of the authorization
8 \+ ^6 U7 ]5 A: P- m8 f6 w5 @### rules for path-based access control.  Unless you specify a path
# Y, s) K  A7 U) k% I' @### starting with a /, the file's location is relative to the the& t& J+ n/ f7 z# C) a
### directory containing this file.  If you don't specify an
# e* Z5 O$ V4 l$ I1 b9 Y### authz-db, no path-based access control is done.
! X# P3 u# E" v7 `  d) t### Uncomment the line below to use the default authorization file.9 _; s+ t# R: Z# r
authz-db = authz4 g* P" J+ L3 O5 u: @( z
### This option specifies the authentication realm of the repository.
3 T% h1 A; ]2 B" L### If two repositories have the same authentication realm, they should% d: \1 d, A1 A* B
### have the same password database, and vice versa.  The default realm
& U: q+ i3 H' N& W  b' E& w1 M### is repository's uuid.
& V! E, v+ U7 z7 ~$ e3 urealm = My First Repository
2 \4 R- g" ]& t5 c  ^* \! d

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn2 A- x% p2 a2 A1 O/ H; X/ l3 e

#killall svnserve    //甇: }: j! g. j' l0 k

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx8 u1 M- y4 R+ S6 ?/ n# l6 Q

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
8 B! }& ~6 N2 \: t0 M( I0 C

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

vim post-commit嚗券Z伐

: g/ i7 @0 R) g, V: D7 |

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" :' x+ k5 n0 C1 u+ v' Y% U) j

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


' W2 U# }& \  T0 o瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


3 l' W7 e+ o) r. q9 {- jvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿: w* _' Q& g' J1 S7 l) \1 q/ G6 k

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-28 04:13 , Processed in 0.096922 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵