52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659. i* C$ G, Z, E$ `/ E; ?
! L. u0 B) c2 p* R

格嚗剖遣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% D7 D. v) g% u2 N+ |/ M

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx6 p  p: I5 M3 H- [: p. l) d, @; E

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
/ T+ H7 L. m3 Y; P/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx- V3 S1 {- Q  Z
$ ^5 l% ]; ]) ~: ?7 w
chkconfig --add nginx& a* f: j* ^( h

7 X( `, j- t2 G, R7 M% n7 V& pchkconfig nginx on' i6 ~) K9 R. F1 p. f; Y6 \

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

#!/bin/bash
9 |$ y+ |* I& A( F4 W6 M4 f. ~- Q# nginx Startup script for the Nginx HTTP Server% _. v8 V2 X, c
# it is v.0.0.2 version.7 B: w8 e8 d5 \0 x
# chkconfig: - 85 156 L% c& E/ f/ x9 }/ A
# description: Nginx is a high-performance web and proxy server.
4 n! @0 `2 G  k" X$ Z1 d# It has a lot of features, but it's not for everyone.8 T# E% Q7 ~8 r( e7 V3 Z
# processname: nginx
1 `% N& g" t, k# pidfile: /var/run/nginx.pid
* B' X* D5 ^+ T- L5 @# config: /usr/local/nginx/conf/nginx.conf
/ k/ v2 t0 B, h/ [1 e+ V9 E' H' Rnginxd=/www/nginx/sbin/nginx: q) I$ c- i) \) a5 n4 j
nginx_config=/www/nginx/conf/nginx.conf/ Z0 T( K6 ^  b  T( _
nginx_pid=/www/nginx/logs/nginx.pid
! J$ h/ o+ }9 _: Y( JRETVAL=0
, s3 e) d( S" [5 C6 K5 X' o/ kprog="nginx"
* I, i) V8 C: i& _8 ?# Source function library.
. p1 \" c( i. C# a. /etc/rc.d/init.d/functions
4 G2 u# v7 G' E$ Y8 ?3 j; n0 D5 Y# Source networking configuration.
/ m: o) s, `9 a2 {# k  E* m. /etc/sysconfig/network
' e- E4 j: h* Q: k# Check that networking is up.
3 i4 \( F, a9 g[ ${NETWORKING} = "no" ] && exit 0# X0 C- O5 M; F) f
[ -x $nginxd ] || exit 0
! Q+ A5 k2 N  B# U) n# ]( \  P# Start nginx daemons functions.
4 h- I  [6 M/ p% l4 Z4 i: Bstart() {$ k- P4 n  t" D3 j1 X+ ?
if [ -e $nginx_pid ];then
  \5 s2 k4 v# g3 f/ Eecho "nginx already running...."
  u  V, N1 ]; W, T3 w& |# j" sexit 1
0 w% g3 f  m, e5 _/ Nfi
4 o8 o* y% Y9 _- o8 V, Oecho -n $"Starting $prog: "( W( ~3 @) ]6 Q  W- w9 |
daemon $nginxd -c ${nginx_config}0 X8 q9 o2 p: m. R5 U8 o9 `- Z
RETVAL=$?& I) H0 @% S" G. E) ]/ t) l
echo% d7 J! @" f7 ^$ l2 q7 X. v% ~/ B2 V3 O0 x
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
" h" S8 f6 g+ a& o$ q( `# {return $RETVAL
% K6 Q: X1 H, r; i3 O}
3 }1 F3 s9 M; T- c# Stop nginx daemons functions.& M0 J, i/ j9 ]
stop() {& F- N+ [4 B: U& l
echo -n $"Stopping $prog: "1 Y( L* s* g& O. ~$ I
killproc $nginxd  y1 q" w$ ^$ S3 ^$ f4 C: x
RETVAL=$?
, d5 r3 m5 Z) u& W1 x9 recho7 G) W1 g2 z7 e$ o! A
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
* Y1 F& L. A$ s8 e3 h. \}
0 p% [5 O, p+ q) N% J% ?reload() {
1 X$ O8 S% ^% X, W( S" eecho -n $"Reloading $prog: "
, k& E1 g9 p  q3 s2 J: S#kill -HUP `cat ${nginx_pid}`
( ~: ^* h2 F6 L* V1 X% Ikillproc $nginxd -HUP* R& d0 Y& F0 q* L' K8 d) V
RETVAL=$?
+ T0 E0 L( t$ y! N8 aecho" w  l' v9 @4 O% z
}
: C; m# b% f* G( `+ d; Y- ?, Y# See how we were called.
) {/ _  z: I2 J# vcase "$1" in- L6 i2 p' m( m
start)$ \3 i  i9 R. A- H& p# @: G9 \
start+ w# o, b5 R9 P+ X0 d$ y
;;% o4 [: `. t# u& J! e  ]- i
stop)
3 h0 Q4 v) l- q6 A3 D* @" kstop* a. M% u9 z: Z* W# u
;;
% F# X  X0 b9 U+ Q& j4 i+ Y* K! preload)
' g, U- J# w( M9 n( W4 p! Sreload; w1 t* ?& z+ }) \) P. s
;;& t( X( }) G- E& H
restart)( Z9 Q7 a1 p9 J6 n$ R- \
stop4 F, k7 }$ e# |$ G
start
$ x. e. q' L( J* W6 L;;
6 j2 n! t( \/ v) m* ]) rstatus)
* }; q* K6 y+ S+ T' |; w# k9 Qstatus $prog. K! b+ y: c) l, X; _) c
RETVAL=$?
6 A/ v" F- `* L$ c;;
) }, a' u1 n2 _! |$ @*)6 k4 B% P5 m$ v( m# |0 Z
echo $"Usage: $prog {start|stop|restart|reload|status|help}") q" Z. _' ^0 o. }1 L! c8 u0 b
exit 1
3 i/ Y) Z4 q4 Iesac
1 b- T: @3 `* U) U0 E4 K) ]exit $RETVAL3 N7 Q# W% |* g) \6 `4 k3 U/ g
1 g$ H9 `3 T  E( a0 @, S

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

) e8 |$ w$ r8 ?* ^* o" n
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗( J7 b3 L! p: i+ O, a' G9 T

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

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

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

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

/ r  s2 I+ J) M9 V8 M) X6 ]% S$ D: c
       location / {" A3 T5 H& N- o
            root   html;
4 u2 k/ x  t, [            index  index.php index.html index.htm;
- [' h: \) _- b! ~; T$ ?  ~( W  Z        }
3 K) c. H3 v* e; @. p8 A2 z靽格嫣蛹嚗
* n" _& ~! O- Q' B* J1 H: h+ a( g7 S' F

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


0 {, V# l* E. @$ elocation ~ \.php$ {5 L6 e3 y3 N1 N9 Y
            root           html;3 Z% ~. `( s4 W- P7 k* _
            fastcgi_pass   127.0.0.1:9000;
+ K& Q6 c: k; x8 r- i            fastcgi_index  index.php;0 q6 w7 L2 w% C, b( o! \' Y
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;, p% d2 y4 G% {* N* z
            include        fastcgi_params;
# b) @! p& g" `% G, V5 Z        }0 g& t5 F- e1 X, ^
靽格嫣蛹嚗7 d% p0 B8 e6 X, ?& N

, A1 A7 V9 B# K$ g

        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

閫蝻拙僎餈唳桀嚗扯嚗

# S  U$ S3 ?- f# V3 v! Z

#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 ~3 W- x6 i1 C) {: I# L
, R" I) d* Z3 P2 E3 W#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏  m: [! _8 a& |: |; Z+ r9 M

cat /etc/passwd 亦冽瑕銵
. o" p2 H3 W7 Ncat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀, g. h  `/ {- m5 z; t/ p

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
, v' v- e* |* Z1 S! x

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
6 q8 F( G* ^* V7 echkconfig mysql on1 }7 {2 X, I& d: G
service mysql start  --臬決ySQL
0 Q8 B/ d' {& @0 @

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
# i5 D5 J3 b$ C6 {5 H$ texport PATH5 t- }9 {4 }4 x

靽摮source /etc/profile

扯嚗


8 i1 C$ r0 ~5 Hmysql -uroot  mysql> SET PASSWORD = PASSWORD('root');+ ^: H! X. K  F( N! a" }$ \: Q6 B
3 A( [' L" b- _$ |6 ]# D

霈曄蔭root冽瑞撖銝氳oot

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

0 \: u0 I3 [' c/ m. _

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

+ z9 i$ Z0 |$ [. b0 D/ k# 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嚗

% ^, F7 ^& f/ Z$ }/ {" ~' `+ w; u

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 \' G" M" l4 f& R- U. w
, T, B7 S: u0 E* y( w0 U/ {0 \5 Orpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
0 C6 K* t: r  A$ e9 H! V: ?) m# E* RCreate /etc/yum.repos.d/php-fpm.repo file and add:  I" N4 Q% W+ D) y) L. f
  1. [nginx]2 w5 Q* d: f: T  g+ q8 W; N
  2. name=nginx repo
    & `1 `/ p' g2 I( b
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    & [% \# v4 |3 `; t; ~5 m
  4. gpgcheck=0, e( y! u1 ^3 ^! f# [9 V
  5. enabled=1
銴鋆賭誨蝣

* w; K& c% F" Z$ L* `9 L# Hyum --enablerepo=remi,remi-test install php-fpm4 U% @/ H1 y; ]' ~
8 {0 A1 W- n7 F  C" S

4 L# E$ H! y) D. s  R" \! D鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn  q: [5 I+ d' \5 ~; [& ?

嚗yum remove subversion //貉蝸雿祉svn
! v+ O7 ?* e7 A! U0 W5 f* r. K

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
3 w- F; t/ |  j

餈# 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]$ H2 f7 w. m8 W' f
# harry = harryssecret0 B1 P' }% y' o
# sally = sallyssecret
5 d1 \* `" H" t7 X9 E* y+ Bwangning=wangning2 `; ~" V4 O* h& ^; y: {9 ]$ G
yanzi=yanzi
! g# g0 Z3 T! h* Z

#vim authz  //霈曄蔭

4 D% u; @. d( |( }. C

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none, t/ d% U' |2 N# r0 [. J; E6 p# h8 S
auth-access = write2 m8 ^- r& D. `+ j7 Z
### The password-db option controls the location of the password# E, W# H, D# M& T2 n: F
### database file.  Unless you specify a path starting with a /,( l' x' k! p; ?/ W0 Q' ~) c
### the file's location is relative to the directory containing
; C( f2 u6 y) }  M1 s0 J+ R### this configuration file.0 G9 d! W& Y/ N, n# R+ }7 g
### If SASL is enabled (see below), this file will NOT be used.
6 `0 o* ^9 g. Y1 u  n0 y### Uncomment the line below to use the default password file.
4 a- _8 t/ @* U5 Opassword-db = passwd' {( f( B: u% s
### The authz-db option controls the location of the authorization7 U) P: Z0 w4 ^, B" F) v5 W1 V6 X
### rules for path-based access control.  Unless you specify a path
/ P  W/ V, x6 I2 [### starting with a /, the file's location is relative to the the
7 E; L' v( u5 O8 F### directory containing this file.  If you don't specify an
. G. `8 m, t' y, a6 c  _5 S$ K### authz-db, no path-based access control is done., Y# I( l) _5 d; D0 |- ^* P3 Y2 n$ s
### Uncomment the line below to use the default authorization file.
. D7 ^5 }) W, g, V! F# r  Mauthz-db = authz
# P- a: j* A2 t8 E* E### This option specifies the authentication realm of the repository.3 s3 k- e, e7 _) I! Z
### If two repositories have the same authentication realm, they should4 H  b% f7 h9 d0 d& `0 G
### have the same password database, and vice versa.  The default realm* d  v8 _+ Z7 o# D+ c; [$ O) p) ]
### is repository's uuid.
. }- [1 \" ^$ ~$ lrealm = My First Repository8 e' g; C! L$ I" J

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
4 V! J, t% j: a+ ]* d

#killall svnserve    //甇4 I6 d) Q4 @! P5 X2 G& o

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx$ R2 z; v& a1 P9 _7 v; ~

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
# j1 x" n+ G; o1 C) B# m( f6 x

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

vim post-commit嚗券Z伐


  h2 d; u9 A; ]; D4 b

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" :
% A/ ~6 @! y' k  u) f

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

  q) Z8 C& V0 s" z9 \- j- _9 A
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


: E$ r+ o8 P% ~. A( A; {& I( Pvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿6 p+ Y% |$ Y, ?

雿輻券

祉蝛閬

撠蝝詨

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-5 21:16 , Processed in 0.066120 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵