52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659* N# B; k1 D# w0 y

7 ~8 ], _  n; C( ?9 j9 D& 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
$ z2 N# ?1 Y4 K$ T" u' ~- H6 W- ]

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx8 T8 N5 O: J- Y) C

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
1 @4 S; O3 X/ P& U# 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
9 W; D; h& Y" C4 h% x4 o9 l$ `3 w' p/ |, M6 u& ^0 ^% F4 c" y
chkconfig --add nginx3 g! @6 q; D% H( S; O
/ F" l4 G8 B; v4 u3 t0 ~, N0 E, l
chkconfig nginx on+ O) J1 d+ e6 s2 b

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

#!/bin/bash
4 S/ w! d3 E  n0 ?4 E# nginx Startup script for the Nginx HTTP Server
: H+ [5 p6 b, f' M; o( N1 i! }# it is v.0.0.2 version.9 g- F+ _% v3 z" J+ @
# chkconfig: - 85 15
8 m6 _: @$ w) d& m+ M# description: Nginx is a high-performance web and proxy server.
" e' ]# X0 V- b# It has a lot of features, but it's not for everyone.. p5 v% d. t3 l, }
# processname: nginx
/ d# O7 x9 `- e+ V" a# pidfile: /var/run/nginx.pid
3 g- h2 t( a, p8 E! n+ _# config: /usr/local/nginx/conf/nginx.conf
5 D8 I9 Z' j) f! e4 R3 j! Inginxd=/www/nginx/sbin/nginx' }: T* f/ P+ z# x; K2 ^7 G" @- v
nginx_config=/www/nginx/conf/nginx.conf
1 F) c- n7 }( x% Snginx_pid=/www/nginx/logs/nginx.pid9 Y9 H% C7 _/ h- k. [, X' m
RETVAL=0' O; _' l3 z- m: V; ^4 g- o
prog="nginx"
9 Y* W- E& z) H* x; S# Source function library.
, J: o& \' O2 j; \* H0 i. /etc/rc.d/init.d/functions
2 K0 {/ l9 \; n4 \7 k2 V5 n& Q# Source networking configuration.
$ Y0 [1 l# s: u/ r. /etc/sysconfig/network
9 V: r/ I! p, Z$ x: P# Check that networking is up.$ g. K1 S" ~9 E5 `# ?  e
[ ${NETWORKING} = "no" ] && exit 0+ N* s$ M5 a8 P9 }/ E: i
[ -x $nginxd ] || exit 0
& @. z0 h% \# W- o# `4 c* R# Start nginx daemons functions.
2 S% C. W1 k9 K- d% K  `start() {# b; i4 ^; g- \  i8 l! p' g1 l
if [ -e $nginx_pid ];then  M& W# h1 E# t
echo "nginx already running...."
, ?, \" X" H$ n1 E7 x: Nexit 1
- `+ p% X5 S+ Ofi8 Q1 B% J# H! \! x
echo -n $"Starting $prog: "
8 K+ a9 V: ^' C0 Y: \daemon $nginxd -c ${nginx_config}+ o, P6 D% {6 u6 Q  F
RETVAL=$?5 R  ~% u1 D) V" C& \  [7 B
echo0 {( ~. [4 S2 \
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
- U" J# N# ?/ x* K% q8 M$ F; f# ]return $RETVAL8 D/ b  ~% o, a: F9 u: y
}
; }) q3 V/ F+ X& b# Stop nginx daemons functions.9 L2 [8 u3 ]% x1 w( f
stop() {: h, W( h& h! P/ p
echo -n $"Stopping $prog: "
- o$ y( [0 D2 g! ^+ e9 k( G5 W/ ]1 |killproc $nginxd
4 D, u: O$ n$ M  d5 H( [* P" c+ @0 TRETVAL=$?
/ F0 N& h/ ~' j' Cecho
: i! j, I2 ]& ], G[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
+ a5 Q, J/ z9 \+ K) {" t}
$ ?( u  D! v; F9 o4 e- ], ^: h3 U3 p0 Lreload() {# i) c. b) H  u/ E1 Z* L5 i
echo -n $"Reloading $prog: ". v4 w# g) L5 S7 a! Y8 d7 r
#kill -HUP `cat ${nginx_pid}`# D$ k4 ~: `4 g
killproc $nginxd -HUP
1 T' x+ Z3 j- \2 u( `6 V4 f2 CRETVAL=$?
0 ?% ?+ t1 U, {0 Wecho6 k; h$ U& `4 g: G; @
}9 f6 F3 R; h! A. X! T9 I! @& ^
# See how we were called.0 s$ |3 j5 [9 g
case "$1" in
1 ]$ N% w6 N" @- w, c8 J: \4 ~start)  j- f! L2 H! B( G9 w& l0 E0 N5 S
start
9 ]* v5 [9 t/ L& v  Y1 j;;
6 [9 o8 M' [, u8 ystop)
* |% g6 x- b4 ?$ L; Q6 w  a" nstop% I6 g# t0 G: }) b
;;
$ ^! ^2 W; Q0 C1 Q3 g+ T8 @reload)
" X: i6 N. T6 r5 U; ^8 U. Greload/ j8 ]+ {; c6 }" a
;;" B3 }! f, V. R5 t& a; s, v! F
restart)
4 p9 K# f' J8 j* {& q" bstop
' o! Q9 I0 A1 ~( b  Hstart; e, [4 ^" y7 \; N" i, x' \
;;/ A$ t, c* r& t5 P. w9 @7 X
status)
/ }+ u! U/ ?3 m, q, m. jstatus $prog
& U2 p0 N& r" V2 d4 ]RETVAL=$?+ ~" G( g- c8 M  v
;;8 O1 m: G% Q: N/ V
*)7 @3 o" s! ?1 z# e
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
- o0 T9 \1 s) Y0 e8 o! b2 g3 gexit 1
: G! k; I. M& e  ^, [$ \( B" Sesac
8 I& e2 [% g9 q9 K7 Z* uexit $RETVAL$ }- C7 ]( a( }' G/ G6 Z

3 W0 }5 H( H& ?% U4 p4 D

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


$ X; _. @8 |% {+ T5 T* J1 _chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗. S; Z) I$ Z0 u- {) A7 [

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

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

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

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


4 w; b" A5 Y, E2 ?       location / {% U) m5 _+ \- e( \6 a4 l
            root   html;2 v' V4 i2 d* M2 {$ n8 E; i( ]
            index  index.php index.html index.htm;
# c/ I+ g! {9 K        }
. r* t1 y7 Z7 Z; Y! ]靽格嫣蛹嚗
$ F7 p- @6 ^7 ^+ z6 o) G" E% _2 D/ ^8 }$ |5 s2 F

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


9 j8 p9 S. [0 U- o' l9 Elocation ~ \.php$ {
/ W! {/ R9 F$ W. k6 d7 b            root           html;
" ]& k5 U) m! U            fastcgi_pass   127.0.0.1:9000;) }0 W: I' n) A# M* o
            fastcgi_index  index.php;9 t$ L3 `7 T/ k3 L; R
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
, M- U$ t: p! v3 M' h            include        fastcgi_params;
, R# Q& S) `$ w! O/ h) E6 }; C1 b7 J        }
. J8 q# `3 r6 G7 F/ O7 D靽格嫣蛹嚗. n' k2 A4 B6 t' `2 X8 N. [  f; a
7 t0 w4 j% n  w& N1 e

        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

閫蝻拙僎餈唳桀嚗扯嚗

3 O/ O, ?3 k2 p' |& A1 w

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
, K6 |% u2 l5 W8 |' f& e7 v  G4 F0 @$ ^2 @: y+ `5 I
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏  F; X5 W7 f  v5 E* ^* ?, _

cat /etc/passwd 亦冽瑕銵6 ^  h- d7 g. L: r1 c! E2 w
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀% B5 H& O0 r" f$ q9 h; R

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql- @2 G; }: P) m" D8 _& W0 g

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
/ Q1 H4 Y$ p4 x: p) `0 x, w" Nchkconfig mysql on
, N. B) M# D' a8 Y6 u: Lservice mysql start  --臬決ySQL
4 i$ m0 d" w" e* C# j, L0 H

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH. Y9 T/ M: m( w# ~$ F
export PATH
/ k' |3 O! J; Q5 c, n

靽摮source /etc/profile

扯嚗

. X' _& S" R0 }3 b/ N
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');2 l+ o2 I) L% h# h/ s
! ?& o, t) K2 q( a- y

霈曄蔭root冽瑞撖銝氳oot

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


8 N# l* G$ n0 Q3 ^; W

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

* Y3 s/ z7 ]1 W% O3 V. T) c* ^& Q) A& 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嚗

4 |& y8 E  H: |

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
( e. }1 ~* d( l2 Y7 A
4 E$ O9 U! ]1 K0 q0 ?# orpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
3 i/ D  R- k- Q1 v; E& E6 Y1 [Create /etc/yum.repos.d/php-fpm.repo file and add:
" T5 {, x0 m1 {7 [! ~
  1. [nginx]
    % |# B; m& }" J, D- v! k
  2. name=nginx repo
      {2 N, x, W, }- r! O2 o
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/; t# i9 V( {) C$ r1 o; d$ o* o+ a- U
  4. gpgcheck=0
    , a. D4 b. b5 Z1 T
  5. enabled=1
銴鋆賭誨蝣

$ Z! l4 H4 i+ j2 e# ?4 T: tyum --enablerepo=remi,remi-test install php-fpm
  L5 ?- w+ m# S! O" F: q. z2 M- @- F6 h1 i, H3 A/ L

% o# l% s$ h. o% M5 t鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn9 w2 m9 [- q& x+ I

嚗yum remove subversion //貉蝸雿祉svn
, ~. t, l9 \" z  [# x/ S

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn1 l* l. g% A- }& C3 ?1 s# T

餈# 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]
! E$ A* q$ k& K$ v" I9 F# harry = harryssecret5 J, c( V/ f5 b9 m- M  D/ J
# sally = sallyssecret$ S  _3 y, i' A/ k* C' @6 c
wangning=wangning+ l6 k+ l1 Y' `+ T0 |  ~$ Y4 t( ~
yanzi=yanzi& ?  }, Q: Z6 K2 L% A

#vim authz  //霈曄蔭


! z4 H" K& l* o+ \$ K% {

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none; o/ b" Q+ W- s* W, m
auth-access = write* u) q, l" }3 k
### The password-db option controls the location of the password- V. l: i' p0 y
### database file.  Unless you specify a path starting with a /,/ u' s" Z" [# W  t+ e$ T6 h
### the file's location is relative to the directory containing
! U% k6 }0 ~9 }* r2 T+ J. @### this configuration file.% Q3 p3 g. V7 C, y5 {
### If SASL is enabled (see below), this file will NOT be used.% q% C# A& E; A# I7 a0 K
### Uncomment the line below to use the default password file.
- p9 J( }4 k: P3 F0 H/ Xpassword-db = passwd
$ [0 R. h% i% X3 h; a### The authz-db option controls the location of the authorization9 Z; }+ ]% l1 e. ?8 L9 d1 w
### rules for path-based access control.  Unless you specify a path8 {, H$ o, e" g1 Y3 d" }
### starting with a /, the file's location is relative to the the% ?1 }. G+ v3 ~' p) p
### directory containing this file.  If you don't specify an
6 c& x! n7 F! a+ Q( q### authz-db, no path-based access control is done.
7 B9 D* R7 }& s9 V% @+ X& N### Uncomment the line below to use the default authorization file.2 _0 a. Y' w$ ?. Z& ~! Z+ ~
authz-db = authz
( G4 ~6 |- p/ q- @: y, C### This option specifies the authentication realm of the repository.
. w* I# q. W6 e* m4 }### If two repositories have the same authentication realm, they should
; J$ Y: M  G# Z- S' \### have the same password database, and vice versa.  The default realm  b) C" ?+ v. g% Q, }
### is repository's uuid.$ j& g9 d$ K/ Y1 @, ]  b+ b8 i
realm = My First Repository
" {( {" x7 o! u

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
+ h6 b3 s( _2 B! Q5 n, O4 X

#killall svnserve    //甇
0 y' q# U. h5 _; t7 f! W6 I8 U

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
9 ?: K- r9 I# f9 G3 [8 s, i' W

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
* b; `+ s- B) m% u% E

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

vim post-commit嚗券Z伐

& ^4 }" u" `$ h5 s0 }+ A* e

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" :5 X7 a+ T7 U- }

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


/ p3 ~, d& T, i- w. \瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

8 Q( i, @5 q1 i! ~& T# X
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿+ W/ F% J' t2 |5 m8 }! P- w2 D

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-13 14:12 , Processed in 0.081174 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵