52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
% s) V* X4 r5 B8 }& m4 |/ A; m" B8 G; I6 {, |9 b

格嚗剖遣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
, S6 Y  q+ a$ ?" b; @! 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
5 m! h4 j/ W# X) O( S# ]

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
( G$ d5 h' c, x/ V7 G- f* 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; D/ R. }6 E/ Q+ H  q* V2 X" u  g
( p# @! D, f! O; `- b3 U
chkconfig --add nginx, [9 x9 W/ u# g- _! J

5 D% u0 T! h7 e2 J0 vchkconfig nginx on! R$ n7 L  c, t, \, @' j& L( d

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

#!/bin/bash
, Z  l+ b; J) \/ [, j# y* g# nginx Startup script for the Nginx HTTP Server
: [8 F; F6 W1 e( _7 ]# it is v.0.0.2 version.
* i/ d& F- p* [  ]* J& [# chkconfig: - 85 15
, x6 A6 J- ~( O8 r% ]: W7 w3 \# description: Nginx is a high-performance web and proxy server.$ ?7 U( G2 B' I, b
# It has a lot of features, but it's not for everyone.' J' A7 o7 h& N
# processname: nginx+ q4 K" z( A* @$ Y2 E8 [
# pidfile: /var/run/nginx.pid& l& R9 g1 c8 N. A% |0 c9 i
# config: /usr/local/nginx/conf/nginx.conf1 {9 J/ |1 f3 G
nginxd=/www/nginx/sbin/nginx
1 M# u: ~! h3 X1 c- L+ nnginx_config=/www/nginx/conf/nginx.conf
7 y# h3 |/ i/ C! G+ ~) C8 qnginx_pid=/www/nginx/logs/nginx.pid
2 K$ k/ E; y! @! ?1 IRETVAL=0
8 {% s- ?3 ?' ^% e/ l0 e, Gprog="nginx": L4 F. e# w6 [2 F
# Source function library.
8 E# x1 g" X( c$ v0 f% A& s9 V. /etc/rc.d/init.d/functions+ E5 Z+ ?) u0 z5 u5 L8 z
# Source networking configuration.7 `! G) t8 O6 R* x" y
. /etc/sysconfig/network" a5 ]5 V& y* m! J+ o
# Check that networking is up.
) ]: K+ V/ j2 C5 j! n/ N. E[ ${NETWORKING} = "no" ] && exit 0
3 _9 w6 Y8 y! y) l3 E[ -x $nginxd ] || exit 0
) h9 G+ F) k% B  f1 X8 z' g# Start nginx daemons functions.( \8 M$ N' Z2 \/ I# R
start() {
' A( e( [4 |) S' a9 t, [if [ -e $nginx_pid ];then6 _' b& \. ~& `/ v/ N- l
echo "nginx already running...."
/ e. T* X" I, W1 j0 Xexit 17 f4 v) j9 M1 d4 ~& A
fi* p: |2 w6 T8 \$ z; {- [
echo -n $"Starting $prog: "
5 u  Y* [1 c2 t/ z; \4 y2 vdaemon $nginxd -c ${nginx_config}* C3 l( C( o4 g+ W1 \
RETVAL=$?
+ Z" y6 o* f" s0 Iecho6 l6 D$ l$ o. f1 K! b9 F
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx$ R) \+ K. P+ h8 T8 z
return $RETVAL
5 d  w3 K! m. p  e6 e% X}
( q) c  ]4 P* j- g" i# Stop nginx daemons functions.
" b, x, n7 K6 T) Q6 A9 vstop() {7 z+ r8 {8 A7 M; L; |" v% N
echo -n $"Stopping $prog: "8 v+ J+ h8 R- Q' z( C
killproc $nginxd
! u' {5 g* H$ o' n) }6 [. pRETVAL=$?$ H  Q. V/ Z! e5 L
echo
% X5 r+ c7 s" H1 `[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid: u) A5 |, @; w! J
}
: `( _0 W: t) B0 K+ K5 ereload() {9 D2 e$ \& R2 E1 W" }. q6 M
echo -n $"Reloading $prog: "
8 I8 _+ a# E! n# x8 o; T+ Z#kill -HUP `cat ${nginx_pid}`
; p( R, }/ ~+ h% h3 ^2 E# jkillproc $nginxd -HUP# p* A9 n! q% O& Z9 P6 p' t
RETVAL=$?
/ r/ V% f  b* ^& J5 B; e- Xecho, Q" s# ^  M1 d5 T9 ?/ r# A
}* d* |" L2 ?3 z& G& A0 B4 {% d
# See how we were called.
" i% p+ u0 ]* @) v$ _! z0 k' U! Dcase "$1" in
1 l: t7 W3 a( b# M5 D. D# T  ustart)
/ x# ^( r6 D- X7 v0 sstart
& H, ~, p$ B! v;;- ?7 ~$ Z+ Y( A6 F7 @. g
stop)
( ?8 G1 w3 }8 |! dstop* u. c! W' B& L' W: O
;;
9 f3 R  D# w% |0 ?; t' Q: Z" ~reload), k7 d! ^# D( f* N; f. F
reload
! Z, P' Z6 {0 B3 \1 };;
3 S* N0 N' V/ c* h5 T% brestart)
  ]; Z4 X2 K% r' ]stop2 \. ]$ K# P  \+ x/ K
start
$ `$ ?' e$ a' [' p8 F% ^;;* j2 L: D# h; Y* i* W$ [
status)
4 p' ?) q9 N+ Ystatus $prog4 L% s: p6 j7 A0 u/ P
RETVAL=$?' q1 _$ ~- g, U' U2 S) N+ ?
;;
) U+ u9 A1 ?+ a" R4 i*)
" Q, ?( B! L; M& l' O8 `echo $"Usage: $prog {start|stop|restart|reload|status|help}"+ D% t5 s4 A' r3 t- g
exit 1
5 Z4 s, P0 n) E. y1 Z- p% @* f6 Qesac6 y5 x$ \9 @3 Y' e
exit $RETVAL
& S$ T, j/ V8 C3 M$ V- k% C5 a2 q' {0 V' y! i# A

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


6 V6 X; A, R4 _1 H8 \" @9 \chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
. ~) E( @) K( L+ y5 P! s6 Z

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

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

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

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


# w5 P+ i4 o, t% e       location / {
5 j# t6 L/ k" F            root   html;
) R4 l0 h' L0 B  f            index  index.php index.html index.htm;
/ {/ {; }7 T! w( O5 g        }
* O; I$ g: T; R" o0 K0 i- A9 G9 O靽格嫣蛹嚗
# O$ ^1 {, o6 u& [, z/ y! {. m# d  ^6 a0 ~0 O2 o

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


; {- S2 c$ M2 U% R% olocation ~ \.php$ {4 [% n6 {4 g* I: ?( Z' v; G) v
            root           html;
* A8 F% e2 Q' ?; @0 k, y            fastcgi_pass   127.0.0.1:9000;
2 W1 c# j  C0 W8 O0 x            fastcgi_index  index.php;/ o3 n# }6 @0 U7 i# q) `
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  T1 l8 F+ {( z  h            include        fastcgi_params;# E; }  z  f9 {6 E3 X: }& U( g
        }  F& s# _- L- t* ^/ B5 x
靽格嫣蛹嚗. {& j$ h6 p  A- F8 }( ?! n

3 P% M* W0 \& ^" P: Q

        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 I0 P- t* _0 ^3 r

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
3 A. e1 o8 {. I; m; {3 p# z7 `$ V$ n6 M& m0 K
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
( u' I7 Y0 E# |. z$ r( ]

cat /etc/passwd 亦冽瑕銵: v7 L/ G  R8 S5 ?3 s0 X1 Y
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
( j' t6 r) E5 m) a: I

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql) T( c6 _! A/ h" ?

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
2 P  T4 U  a! U% n! C$ i/ g2 Vchkconfig mysql on* p- B% g  K5 j" D* Q
service mysql start  --臬決ySQL
0 I) c* u( M& Q

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH- G$ A. A  S( [1 R5 j
export PATH
2 S& K* i, K% u9 S0 L

靽摮source /etc/profile

扯嚗

6 [4 [. e- E3 s- R
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');- T1 s+ r6 g: F  ^6 m* E" [% J

5 c. n6 O. o: ~" i

霈曄蔭root冽瑞撖銝氳oot

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


) r( e* _" U: G7 l

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


4 u$ s& R) ]# u6 C4 k- Y$ C

#./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. p6 d1 J7 p  J" @

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
4 {4 `, h& v# s1 S1 b: S4 Q  B2 M. H* v' \
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
4 E/ B6 P! \3 E+ d1 b' GCreate /etc/yum.repos.d/php-fpm.repo file and add:
: L. e8 h$ ~" L
  1. [nginx]0 Y% F+ P  H9 i7 m/ h; U' U
  2. name=nginx repo9 w: y! p1 _( q$ p# k' W
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    - ?8 R+ b6 I6 k' d8 D, r7 Y( H
  4. gpgcheck=00 B: _9 X- G- g# h! ~3 h( E
  5. enabled=1
銴鋆賭誨蝣

# ?' e. B6 C% s- b7 [, O. jyum --enablerepo=remi,remi-test install php-fpm- q) Z  {5 q8 I+ q

$ Y6 M( d- N5 f4 f$ D
6 j: H; R; T# a: l7 L2 B$ F
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
& U" v' f/ a/ v: P/ D: F1 L

嚗yum remove subversion //貉蝸雿祉svn& V" ~& p) `1 N" r# ~% C

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
. d; e  L$ ^: v& y8 B* t1 N0 ~

餈# 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]
9 K: |3 n- r- ]" Z! L0 \# harry = harryssecret
. y6 P3 X+ m' L' c# sally = sallyssecret
- k: V' X* q7 D/ Q; qwangning=wangning: I) _+ f# Z2 A+ A
yanzi=yanzi$ p% P( J0 \& a

#vim authz  //霈曄蔭


" _! }+ j6 W* C/ P

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
% {9 v# ^$ W* B9 G# R, Bauth-access = write) P: o4 G. ^, W6 C& J! P
### The password-db option controls the location of the password% P4 L& u0 J, F% t0 z
### database file.  Unless you specify a path starting with a /,. r4 a8 ?6 \& ?3 B5 d
### the file's location is relative to the directory containing
  i; u. r  y! E### this configuration file.1 l+ M/ o  T( ^9 i1 ]! V7 N
### If SASL is enabled (see below), this file will NOT be used.: S( f# v; h3 n8 E' q5 M& b+ X
### Uncomment the line below to use the default password file.$ E: V; X/ x' [' `& {2 V4 L$ H
password-db = passwd) Y( ]5 P$ X" V
### The authz-db option controls the location of the authorization( {- G9 `6 d4 |6 g
### rules for path-based access control.  Unless you specify a path
* \* }% k% _$ `! c0 S### starting with a /, the file's location is relative to the the  A  H4 R. Z( x( u/ e
### directory containing this file.  If you don't specify an
) ~& ~- j! t/ m) f! o### authz-db, no path-based access control is done.
* ]  k6 Q4 p% H; s### Uncomment the line below to use the default authorization file.
4 \( I7 @: Q$ B: W. [% `* u8 mauthz-db = authz
& J% q! A; h, R. K) c### This option specifies the authentication realm of the repository.  J  i: {0 h; w, V1 e3 h) D
### If two repositories have the same authentication realm, they should3 w; e, r# q% _. T) m( t6 E
### have the same password database, and vice versa.  The default realm
0 Z: }$ R- M) F; w### is repository's uuid./ Z$ O- e, V2 I( ]" S
realm = My First Repository# Z7 B, A- m3 D- Q7 a; K" Z0 e8 W

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
/ \% \4 H0 ]4 t9 A1 ^  c0 g

#killall svnserve    //甇+ R, }/ B5 \3 h/ Q* N

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
& J* }. H7 U7 V4 k( `: q, l) f( ^

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/web8 n/ y+ K$ S, Q( i  q7 b

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

vim post-commit嚗券Z伐


+ `2 x1 T+ E% i8 B0 ]2 t' H

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" :
8 e% C9 Y: r  r

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


( f2 y! M1 O$ f% G瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


% U* Q0 _; Y& T' U( v1 x7 {+ e! b+ Avi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿3 ~3 \/ D7 m% I

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-1-29 16:31 , Processed in 0.074936 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵