52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
8 P( V/ ?4 w- S6 E; l9 A& [7 r# K) b! M% d* 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" i+ s1 C/ y5 s  j

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx, h- {" n6 N! j8 x9 `' l( `

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
. u. r8 d( d; C, z+ \) B/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx' T' I2 ^/ h9 }/ U

- m5 J, z( }+ Z' c0 T: b( dchkconfig --add nginx; q9 K  M1 D& O4 q* \

1 L8 r# X) i- u  m5 echkconfig nginx on+ U  Y! b4 V. [+ U+ ]' R) \2 v

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

#!/bin/bash
9 w6 E5 _+ f  b% H- Z# nginx Startup script for the Nginx HTTP Server
2 \: Z. W+ T9 T' Q2 A$ V# it is v.0.0.2 version.
; u, N) v5 h; N: ~) |# chkconfig: - 85 15
, @9 b6 L% T, @9 G: c. h: ^" X- z# description: Nginx is a high-performance web and proxy server.
6 \- Q8 c* \3 T7 _# It has a lot of features, but it's not for everyone.+ i; w5 _) D; y' I
# processname: nginx' M8 B5 L& U. A2 D
# pidfile: /var/run/nginx.pid8 L, L5 N# q7 M4 [2 u
# config: /usr/local/nginx/conf/nginx.conf! X2 v9 ^0 P/ F1 Z
nginxd=/www/nginx/sbin/nginx
( g2 B. [2 u& V  H( _6 }, F8 tnginx_config=/www/nginx/conf/nginx.conf6 A' X+ ?% a) ^) ^
nginx_pid=/www/nginx/logs/nginx.pid
+ z% O) }0 p  }3 gRETVAL=0
. p1 o9 J( n8 Q$ ]& Uprog="nginx"
# N# L: [6 Z& ]- r9 q# Source function library.
1 m8 k3 H3 Y5 b9 z. /etc/rc.d/init.d/functions
8 _! S( C, ^% h7 t* P# Source networking configuration.* |5 m( R& s' i; u
. /etc/sysconfig/network
/ S4 o: I1 ~/ L8 H- W# Check that networking is up.; R" x' u+ _, {9 Z
[ ${NETWORKING} = "no" ] && exit 0
& x  Q* @1 f: d+ p& r[ -x $nginxd ] || exit 0* [  M0 v% c: u
# Start nginx daemons functions.9 W, }" x- J* ], B3 [; w3 c
start() {
2 y0 ~8 q" E' I6 o8 ?0 h; _if [ -e $nginx_pid ];then! @3 K' J6 L/ L* `* F7 E# p3 M
echo "nginx already running...."
/ T- Y# N) ~5 ]2 Aexit 12 o$ }$ G  K) G1 @& }' p
fi( ^9 \4 W2 o0 ?/ C# ^% w( o7 T
echo -n $"Starting $prog: "
1 Q+ e' o2 @" ?0 a$ `' P- ydaemon $nginxd -c ${nginx_config}
, y+ n6 O' v- c. \' @RETVAL=$?
4 c0 k4 W# l4 e- ?" E0 h) K6 recho
5 b. _4 ^5 E1 `$ @0 V! _) \2 Z[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx3 n1 `8 r- ?  |
return $RETVAL; B+ t+ ]2 \+ m
}
' R9 I1 g; i' f# Stop nginx daemons functions.
4 \5 V) {8 `) I0 ]stop() {
% v' F* {$ W4 F! m7 Lecho -n $"Stopping $prog: "
: t! N- w/ d5 bkillproc $nginxd
7 d$ E. |4 Y' A( V( Y6 nRETVAL=$?' S/ g2 e6 O5 l2 i: e
echo5 b4 U- h( N* U2 Q4 `1 \& x7 B2 [
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
5 C  h2 w- \, G0 H% O; J, Q* z* L}
/ ?7 H* i" x7 v4 b! ]& xreload() {. I5 ?1 I1 R4 K6 Y
echo -n $"Reloading $prog: "8 ~) L4 J% y: g
#kill -HUP `cat ${nginx_pid}`
  F. i% d7 M/ Z; m+ u% v7 K: rkillproc $nginxd -HUP3 P4 ^; G( j; e0 B. [1 L: ?
RETVAL=$?+ V; z2 P6 F2 m* X7 b. ?
echo
! N6 M4 ^! m/ I* Q9 z& z. |1 h( v}
0 @8 g2 H" Q% g( I- n+ v# See how we were called.
0 _5 Q9 G6 C0 X/ U; Gcase "$1" in
2 S/ ~$ ^( ]1 y4 m1 i' i" Kstart)5 O$ [; b+ M- o2 y% C6 i
start5 b: y9 n& Q# P0 O/ l, x7 O2 }
;;
5 s% i6 r; @" c3 D7 C( zstop)& w. p" N0 Q9 F
stop$ q# o9 S. h8 Z. o% M: R( {( s9 z2 D
;;4 _+ ~9 G2 D9 {$ G" a% o( I/ e
reload). X" B2 W5 f2 I* F7 W5 u. G: w: B/ U
reload( q, c' S: E' D" A
;;+ A! F2 ~; b7 H$ m7 S
restart); w0 ~" Q  ~. m9 n  {
stop1 A9 _: d% I1 ^0 s
start
' k" f6 x. s# x$ p) n4 F9 Q;;; b5 D5 y; j% Z6 P( A
status)" c, Y: L) g# W# t4 U
status $prog1 p% I- m( k+ p5 X6 |3 ]7 w# ^
RETVAL=$?
3 K" e% Z: }* s" p4 Q+ Z+ E;;
  S- y% ]. Z! E# k; e*)! k  V6 ?/ l8 f0 S8 e# |0 `  p. F
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
# n# U& {& `9 rexit 1. ?- g  c' ^' R, {
esac
$ q' A" U- B6 Yexit $RETVAL3 M$ D8 {: v! I4 p# O- g5 l! V: b
5 u( {5 X3 I! L1 ]

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


5 R% |( E9 U7 p7 f- h! Q5 mchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
; Y8 {4 G6 g; k' W7 `

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

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

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

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


6 q1 i2 _. T# `9 r# l0 ~( g2 P       location / {
4 ^' _- ?+ N- f, |; X2 q            root   html;
, a7 O8 |' P. Y. L, B            index  index.php index.html index.htm;
' @5 H( |  S$ @  S6 T( t9 v1 v        }) |" B, a0 T4 Y5 r- w
靽格嫣蛹嚗
6 f! T5 g. y  p; M# j
" u+ `; s1 v, @' W8 j6 i. p. r

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

% I4 w8 ]2 @7 f2 k
location ~ \.php$ {
4 K5 a8 j  ^/ f9 ^5 y( X, a) l            root           html;
; U2 X' E* x( }6 S- K) _8 q# f/ W            fastcgi_pass   127.0.0.1:9000;
3 _5 o! ~) ^. E: e            fastcgi_index  index.php;
/ G: `5 C; P7 g& O6 @8 Y  ~8 _            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;. A  a. }# T) R" e+ M9 J- c
            include        fastcgi_params;$ c1 I. s3 b/ ~. p
        }+ Q  x- @! B# z7 \1 @5 ]
靽格嫣蛹嚗
+ t9 Q+ O* F: `* U* _0 i8 p
- L  p# N% E/ S) D' O5 G6 {# 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

閫蝻拙僎餈唳桀嚗扯嚗

. I" N& G6 {2 ?2 ~

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
6 u4 ?! F. m  ?( \% |
" k/ e8 I" g8 W+ C' N( A# Y( p#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏* B% _* Q; u; A- F

cat /etc/passwd 亦冽瑕銵
$ l! W7 f4 q5 _6 i% T$ B* J$ w8 ycat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀3 p5 [- Q- k$ w  ?: J

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql' i5 X4 k6 R/ Q8 D

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql7 L7 O3 p0 \; B* S
chkconfig mysql on# o# W% a! n+ y7 R+ {
service mysql start  --臬決ySQL+ ]( w; ~7 N7 b3 E+ H* R" m+ c( K

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
9 M# N% \" _  a. k# I! ~export PATH
' G4 ]( D8 [8 Q/ V. u

靽摮source /etc/profile

扯嚗

. Y. }1 q  z: S( `* L
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');* _) n4 d$ n+ L1 H) L6 W+ [

& k9 p# p5 Q  q

霈曄蔭root冽瑞撖銝氳oot

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

* M$ d) k# t! `: t

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

3 c0 W$ X' W* B2 D0 X

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


) Y( y9 f! P: Z8 r

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& I3 D9 V) G. ?

3 T! K! b; H- K) u3 A. hrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
. M( z: _% H0 r% JCreate /etc/yum.repos.d/php-fpm.repo file and add:
6 u8 _0 v( k9 L5 `( s& s
  1. [nginx]
    5 i. a7 \1 n2 ~/ k* Y4 b( s4 h0 n
  2. name=nginx repo& ^9 G: t3 \2 c/ [2 O: n% d4 W
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    , f" s* u. n) e3 H0 }: A
  4. gpgcheck=06 g3 [) ]6 g1 P2 g. g  @( J
  5. enabled=1
銴鋆賭誨蝣
2 x' E1 o* f  d
yum --enablerepo=remi,remi-test install php-fpm
/ E) n& K8 |6 n0 i2 O! r7 D: q) m  x& F& D' w! W, b4 U2 B* |

2 r9 g( x2 \+ L0 i鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn3 k# U) p/ ]2 ]" M; A% Q" e7 a0 Q

嚗yum remove subversion //貉蝸雿祉svn
" s# ]( h; r; I, J+ [

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
) |- A( t) O+ u+ i* X. {9 U: D$ d

餈# 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 c6 i$ N6 i3 U9 Z, v# harry = harryssecret  f5 O) n# `( c
# sally = sallyssecret
  m! O# `" r6 B4 X: D( \5 Qwangning=wangning
. w# i9 z# Z! _7 k9 c. o. s8 q( y+ ayanzi=yanzi
: p# |4 R8 P2 ^  C* r; \

#vim authz  //霈曄蔭

+ {8 z9 H5 E1 N6 m! L. t) T

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
! W, }4 N3 x6 O* Q1 W3 L0 M2 Vauth-access = write
& a0 h8 z8 V/ U# s5 g7 ^### The password-db option controls the location of the password" P1 p" F; e4 }+ X" ]4 M5 A
### database file.  Unless you specify a path starting with a /,
7 g# U" K; L7 B  C( e1 v### the file's location is relative to the directory containing1 C! r: h" K- R
### this configuration file.$ p* R+ U2 ~5 @7 K
### If SASL is enabled (see below), this file will NOT be used.# k/ @! d6 k$ p8 H% u" M* k/ ~
### Uncomment the line below to use the default password file.
5 h% v- z4 n& N( ^* G, A/ rpassword-db = passwd% u' `3 V3 l. `. G  Z
### The authz-db option controls the location of the authorization7 o3 t5 A' X# [8 l/ M) Z3 O/ T7 r( O
### rules for path-based access control.  Unless you specify a path
8 `6 L: u! U) d* I) y### starting with a /, the file's location is relative to the the0 m$ w" J' q% _8 U% c6 r
### directory containing this file.  If you don't specify an
  m. S: \. U4 p- D) i; n7 m0 M### authz-db, no path-based access control is done.
: E" U1 `& [) p' @9 p. S+ F### Uncomment the line below to use the default authorization file.  O% k8 E2 C1 F) q. P* A/ {
authz-db = authz5 b# w, f) E" A  |; U
### This option specifies the authentication realm of the repository.! L% E8 ~, w0 M3 Q' T* O) t0 D
### If two repositories have the same authentication realm, they should
& A* J( m" x4 x8 F### have the same password database, and vice versa.  The default realm
5 \3 A) _$ Z' `7 G) f### is repository's uuid.& a+ K1 d2 l# G9 _' @
realm = My First Repository
# ]2 t& X6 N* w1 P3 q3 l; D9 r

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
/ s( x; [4 ^+ X( P" r: l

#killall svnserve    //甇
% Y# `$ `( o. h, c% B6 \  Y

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
. k0 U8 \+ C) E- |, h

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$ [5 |& |3 [3 ~: i/ O+ [( Q

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

vim post-commit嚗券Z伐


" J5 \8 |+ n6 N; 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" :- |9 J/ C6 k' H1 _8 I" X

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

7 j& c9 h7 U% R
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


  Q" S; F. Z/ N& O' w/ _; p/ v  g3 xvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿& r; R( Y+ H$ ]4 y+ C& I# s

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-1-27 06:50 , Processed in 0.086316 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵