52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |甇摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659/ e6 X" ~* m; n/ @  ?2 K$ v2 X5 H
/ a; g3 U7 e5 p( j3 n, z4 v

格嚗剖遣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
) A4 O1 W1 ^7 {( M

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
: [# A7 T2 X# L

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
1 R2 W: L# C& ~# t) q. m$ J/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx. h8 t+ J' Y8 R% w6 s

& r9 X1 q7 D+ Nchkconfig --add nginx
& d8 P( H" m% x( `+ I8 g1 ]) v! z: p& q3 I6 e; ~
chkconfig nginx on: `5 J" e" C5 J

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

#!/bin/bash
' S/ r/ {+ F* q( g# nginx Startup script for the Nginx HTTP Server. j( C$ K0 u: ~) B
# it is v.0.0.2 version.
6 i* @# J  q: p/ t  w) q8 @# chkconfig: - 85 15
0 i/ f/ f* q: c, Q# description: Nginx is a high-performance web and proxy server.
+ l, N# V. }2 @' P" B+ O# It has a lot of features, but it's not for everyone.; F9 Z0 P! X( [5 x( \+ K
# processname: nginx
" X% @( E& b! Y# pidfile: /var/run/nginx.pid8 ]9 R1 R* Z: {& z$ e$ f. h
# config: /usr/local/nginx/conf/nginx.conf
$ W! ~2 S! ?. s( ]5 D1 Inginxd=/www/nginx/sbin/nginx
' h$ p; {7 m% I7 M' j& fnginx_config=/www/nginx/conf/nginx.conf& P, O8 o4 u# R; A: [5 I  x
nginx_pid=/www/nginx/logs/nginx.pid
/ e; ^8 y8 @! `& i0 F4 Y  PRETVAL=0
6 M0 |# f" `/ iprog="nginx"
7 J" s% E# |7 V2 _& B- L- O# Source function library.! O5 M2 ]- V/ L6 @1 K. T
. /etc/rc.d/init.d/functions
' Q+ a+ c9 f( e: u! ]; h+ q# Source networking configuration." X! D/ _. i% Q; I+ _
. /etc/sysconfig/network* g+ ]& c& J1 F5 K! @4 ?5 j5 @
# Check that networking is up.2 V$ [" B7 B! Y- I+ c7 o7 H6 d: v
[ ${NETWORKING} = "no" ] && exit 0/ r# z& y5 `2 D9 U8 f
[ -x $nginxd ] || exit 0; E8 |# O" \: x, `9 D% T
# Start nginx daemons functions.
/ R/ r  A& n( {& Estart() {
' t7 _( _. S/ u9 T; c+ A% O5 Fif [ -e $nginx_pid ];then, s6 v: B$ w8 \' s1 ]0 S
echo "nginx already running...."3 n* b. I3 y3 J1 W
exit 15 {$ T. v3 [. m3 u1 `3 D
fi
0 n, F7 A8 f# S* a9 yecho -n $"Starting $prog: "
5 x% F( x+ O4 Bdaemon $nginxd -c ${nginx_config}
* P" j0 a0 z2 X9 Z+ c+ ^& P8 TRETVAL=$?
8 u! ?; c; _& Z, y% Oecho7 u$ P4 m' h# G
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
' f" f, A) l9 L1 Hreturn $RETVAL0 _5 b- z* w4 ?2 w
}3 @* O2 M' v4 k% U" i3 l
# Stop nginx daemons functions.3 A0 h6 B* p+ r# J# R, h/ R4 q' |0 T* G  k# b
stop() {
- a9 o% J: U( i2 x; _echo -n $"Stopping $prog: "5 x, g& |8 |& N+ J( E
killproc $nginxd
  R( y! v; ~" ZRETVAL=$?; M% `( l% T- F; `: j
echo
  B/ E' {% S1 S[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
% y8 a1 r5 ~  V/ f& a}( t, l' Z8 r$ o" A/ d' o8 `
reload() {
, o1 ~, J& N# ~echo -n $"Reloading $prog: "1 U" G4 M6 A5 k' S$ `: o5 b
#kill -HUP `cat ${nginx_pid}`4 {! S/ w5 p0 Z$ ~
killproc $nginxd -HUP: b7 s# d$ @3 W6 F6 l! K$ P  s
RETVAL=$?
6 B2 R: m2 o, ~echo
8 S5 i+ t" U5 B" p1 b# a- @- l}
3 n  B! g  t- x. o# See how we were called.) Q4 z7 T" ?6 ]
case "$1" in$ N! P# @8 y, Y- e1 ]  z/ z
start); @8 g4 n, C5 {  i$ M' O: k" R
start
$ }* G& S2 x2 G- P1 `;;
/ l/ k# Q% h5 h) `stop)
5 \% X: {: {7 I2 B) o" H5 cstop
7 Z% u) Q/ L& U) l;;# w' {4 g9 w6 |8 B/ F
reload)6 B5 S3 K9 A  T6 X) V+ q+ J6 T' [
reload6 ~5 `" V3 h+ q6 A2 f% [
;;
6 n7 J  {2 \+ c2 R& |! D3 q3 Grestart)/ u1 ]/ x- _3 P: K
stop
! s" \% L! i* p7 {: z' ~% P; vstart
+ [! F$ l) W& {, n$ W% @;;# y+ O! M4 K6 L) i
status)$ |" D" b) c7 Z9 v( [  P4 T
status $prog6 Y- y8 C- ^8 `8 k5 F& M
RETVAL=$?
; w- L  ~/ E) O7 t( @;;
& @0 U: T: |. L! [5 H; h- X2 q*)
  Q* s1 [6 q% z" W6 Recho $"Usage: $prog {start|stop|restart|reload|status|help}"7 [7 a1 E# z0 j% r
exit 1
4 |: _5 v$ D. J1 Qesac/ S/ W1 V- _! E: K) l
exit $RETVAL2 v/ R2 }/ @& u
9 d$ ^) Y' N( y, r' A. r6 F

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

  V' C1 B+ b3 {7 x0 f+ S
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
1 f$ ?+ I* K) G' f5 P! W, Q

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

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

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

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

0 Z7 a0 {7 F1 }
       location / {! s' g# [2 h; L. O' t0 Q$ K8 I
            root   html;, W+ i, h" y/ t# O. {
            index  index.php index.html index.htm;3 J( y$ f, w# a& _8 D0 t
        }
* u4 |) g5 p8 T/ c$ @' U# e: |( V靽格嫣蛹嚗
: a& K+ M% H) Z- I; t. T$ d" i0 u
: e2 v: e' X( b* r4 Y1 v1 Q& x

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


9 n' ^% F0 o0 g3 F- elocation ~ \.php$ {
: J$ [6 z  {3 |3 r7 o7 R            root           html;
; k# c1 g+ v$ E/ q- h            fastcgi_pass   127.0.0.1:9000;
; j, K. U9 ^' H4 d            fastcgi_index  index.php;
, H  w6 r8 t; S3 E7 o4 s& c            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
8 w$ H6 G& y. J( G! n            include        fastcgi_params;
8 L& t; `7 {, \- n! L7 E( i$ Y/ M        }6 x* ]7 R0 c9 x4 x/ a1 f
靽格嫣蛹嚗
% N' H' `$ ~) D- s" C; P) P$ x) p. |$ _. Y1 f$ R- X7 Y! v

        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

閫蝻拙僎餈唳桀嚗扯嚗


, \# A6 l9 O! W( p- R6 O' E

#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 h% w) g- O: }; X0 j) a+ U/ t: W8 h
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏* w* Z! F3 H* m$ h* C2 C. E

cat /etc/passwd 亦冽瑕銵( _6 {& |: E% B7 D7 }: p( g5 p3 F
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀. L9 L0 k9 M& G) I* K- V( T8 Y. m

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql3 F, s( ]1 Y' L" s$ Y

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
$ K8 i% L) S  r' Echkconfig mysql on
* I& d4 J, \  c* z4 j  rservice mysql start  --臬決ySQL# G* ~2 g* s# Y0 v

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH/ B8 S6 y; {, w/ [: Z- v  k
export PATH
* r. g: {( V% c6 M# k- U9 ^

靽摮source /etc/profile

扯嚗

7 I7 E  g) R. ?+ V8 V3 e1 k
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
. v- D: Z. d5 Y4 U* _
- m# i' e+ q3 P$ l" Q

霈曄蔭root冽瑞撖銝氳oot

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

3 g1 G8 M. v! z( R9 \* W$ L

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


! J! q7 k# X6 d2 D( Y# 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嚗

0 p  i7 `& b) e! b7 z

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
, A9 j8 w1 K7 C
/ ]( m+ r2 p$ T, Wrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm& D5 v9 \3 p1 S2 v6 V
Create /etc/yum.repos.d/php-fpm.repo file and add:
1 x* I& J( i/ P% M; }. y: m% \
  1. [nginx]4 e, U; S0 \$ A( f% |, ^; n3 l
  2. name=nginx repo
    ! D1 L3 P1 W6 l, h/ h
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    - ]* ]7 V4 q( w
  4. gpgcheck=0
    # Q/ Y1 C; \3 W' B) v
  5. enabled=1
銴鋆賭誨蝣

$ K8 V8 K1 e3 P3 c$ p" U* ryum --enablerepo=remi,remi-test install php-fpm+ q& ~3 ~( w, j0 C$ e

( G( I+ E5 G0 {- e
$ u; a' S7 ]. L$ [6 ~# \; b
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
0 U' _0 z1 X6 \$ e; b6 ~

嚗yum remove subversion //貉蝸雿祉svn/ a! {$ ^) t  h- A. A' b" ^" P

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn- O( @& U$ q/ v3 k( x& |

餈# 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]( O  K3 |( z! T% q; k- R+ H
# harry = harryssecret. D2 m! T: T9 d0 P: z: T0 g
# sally = sallyssecret3 N: _, E$ o$ ~3 t, ~1 O
wangning=wangning
4 v* v- A2 Z: V0 Oyanzi=yanzi& K( }. g, ?/ A; S! P

#vim authz  //霈曄蔭

  A$ {. m4 D' Y9 u7 c+ }; C- b

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
' u0 N& _  z  [$ K8 z9 ~+ l# r2 bauth-access = write$ o- u4 @: i9 ?/ A
### The password-db option controls the location of the password
# Q* k2 ]) P5 q( X### database file.  Unless you specify a path starting with a /,: D' }0 i2 l7 @
### the file's location is relative to the directory containing3 X; T+ b) V. Y( z! g/ o
### this configuration file.
! H) u$ B; \& _8 ^' M### If SASL is enabled (see below), this file will NOT be used.3 ^; W7 U7 x8 z/ B
### Uncomment the line below to use the default password file.
8 w, k) e5 d3 A+ D6 L$ Ipassword-db = passwd. B' z# ?0 R$ D
### The authz-db option controls the location of the authorization
8 _6 {1 ?* T5 x3 ]$ Q5 q/ |3 K! S### rules for path-based access control.  Unless you specify a path2 p: N3 K4 F5 l# I' X( R& D+ \
### starting with a /, the file's location is relative to the the
& A. k" e" d" Y! V2 ^### directory containing this file.  If you don't specify an; x) y. u- f! ^: z
### authz-db, no path-based access control is done.
/ \" X4 R5 k/ K' m! L( c$ {. w; g9 b### Uncomment the line below to use the default authorization file." j) b% }5 r7 V* I: m
authz-db = authz
4 _2 E4 g) d4 N### This option specifies the authentication realm of the repository./ \, X4 E; l& y9 u' w2 r* G
### If two repositories have the same authentication realm, they should
) ], c* J3 ~, x### have the same password database, and vice versa.  The default realm
; |% Z* T9 e! s+ o0 e( ~" w### is repository's uuid.
$ ]+ |; g9 Q8 G- ~0 Lrealm = My First Repository: r. b: t; i" c

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn4 c' |6 V' I: K) U* D; h9 O1 }

#killall svnserve    //甇% b  p: w$ q9 z- Z. y

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
' C: y: L' [% i3 s3 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/web0 r: I: t5 h5 J# G# n( A

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

vim post-commit嚗券Z伐

) a% o" D" G1 r8 U0 r3 X

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" :1 k+ t. _3 ]+ o+ t+ M& k1 j  S

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


6 f- v# }% b6 y1 u8 e瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


# r# ^: C2 G! P" x$ f5 p+ E+ e6 _% zvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
! C2 I) e2 i" `3 m$ B

雿輻券

祉蝛閬

撠蝝詨

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-5 23:14 , Processed in 0.065750 second(s), 19 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵