52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659$ ]" r4 B" I0 M- T% r

! B( G0 y) |$ 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
. J- N8 }. E+ E

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx' t/ b' T' H! }) s

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www8 c, N- b/ l' R% H' E6 Y: T* h
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx
2 c) g$ K9 w+ C0 k/ ~
5 D2 z* `$ a4 E2 nchkconfig --add nginx: @- R7 I; F" a# e! d( B3 S0 [* A

. y! q" s% G8 O4 O" ^# ^+ c0 F; Tchkconfig nginx on
# P; u, b6 c0 Q5 Y) o

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

#!/bin/bash% g: C( A+ o* Q& J, a, C
# nginx Startup script for the Nginx HTTP Server
7 I& r5 p! h6 u. F( j% P( B* z# it is v.0.0.2 version.
9 _5 ^% p7 C" E4 X/ N; b# chkconfig: - 85 15
) h6 a- O+ b" x7 R# description: Nginx is a high-performance web and proxy server.0 C: X. _+ w& W$ @9 O2 s
# It has a lot of features, but it's not for everyone.
* R& T& Y9 }7 d6 {% e% @) M; @# processname: nginx
  p" k2 R9 V0 t4 u1 O# pidfile: /var/run/nginx.pid
0 I7 A8 _1 P1 g6 C" b8 Z# config: /usr/local/nginx/conf/nginx.conf
6 p! l1 H. M% z. [nginxd=/www/nginx/sbin/nginx  ?! I6 O6 X# }" X, R
nginx_config=/www/nginx/conf/nginx.conf1 T3 Y5 B* c1 w4 ?  R. Y
nginx_pid=/www/nginx/logs/nginx.pid" x8 g. D7 _, v6 x1 G5 g
RETVAL=0
' J; D/ q$ P# [prog="nginx") B* B3 |1 z: e$ t$ m* Y; U
# Source function library.; P. Y: V; N; @; W9 C) p8 r" d
. /etc/rc.d/init.d/functions, c$ C- D" L' B8 h0 E/ P
# Source networking configuration.
$ y6 a" u5 g9 E! \) I$ \. /etc/sysconfig/network
5 [( S. Y4 j) q8 ^" a  T# Check that networking is up.
4 q1 t. N, l. p8 q[ ${NETWORKING} = "no" ] && exit 0
; t! Y5 ]6 C& e& T# y6 t[ -x $nginxd ] || exit 0
1 G6 u9 ]3 w4 [: w0 Q% H, C4 A" P% e# Start nginx daemons functions.
4 T! c) F& A* V) s) Rstart() {
0 O% N5 m8 S7 e/ p4 lif [ -e $nginx_pid ];then
/ b4 r3 k  a" |" N( o: W! Qecho "nginx already running...."0 a1 {) n0 M! F4 A1 R8 Z
exit 1+ ~! q/ D0 a6 v; Y7 u* z% V% S* g
fi
  G" H$ X1 P" O# }+ Cecho -n $"Starting $prog: "' J; n9 u/ d, |
daemon $nginxd -c ${nginx_config}$ i) i9 }4 S! m' a  V
RETVAL=$?+ ?0 R: M5 q6 l  X; s
echo
$ P2 {" Z1 {0 A, ~[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx- ~3 m3 |3 c, H/ x7 R
return $RETVAL& S! Y0 K; x9 Z* U
}
1 k' b  W; h: G/ y; w, z8 w# Stop nginx daemons functions.
* h- |& j/ T4 A2 G: Bstop() {9 N" l' `0 v! ~7 q" N+ c# V
echo -n $"Stopping $prog: "0 E8 t: Y) G  w0 w' r
killproc $nginxd8 N7 `0 F* `3 q" D
RETVAL=$?* U% _/ O0 U( T3 A+ Z% C0 d
echo1 J' K9 b1 Q) z  M
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid8 C. t  t7 w. b" I8 ]+ t
}
( H- g+ F/ Y4 Q: ]reload() {& k- i' W$ j/ d, Q" \0 F7 \9 W, |
echo -n $"Reloading $prog: "% t7 [: y  j/ o3 }" x: k
#kill -HUP `cat ${nginx_pid}`
/ T, M: |3 Z6 m% m1 X% vkillproc $nginxd -HUP
5 b! b- o3 F- ?; w. _" P3 ORETVAL=$?
: @/ F/ s" }. w1 H) ~. j* Mecho. S0 j) _, {: d* ?( [3 I5 }* F
}1 Z, M7 Z- O7 X# {: l
# See how we were called.
3 d6 L& b$ s5 y+ d7 f4 hcase "$1" in5 o; e- Y* A2 J( u) o0 G) C
start)
+ R. a( S1 {/ M& Ostart
2 f* K. C5 q( V/ W;;8 N. `% H$ ^5 K
stop)
- E8 I) O! o# l: m" T1 Zstop
( l& o' d+ X& O; X$ G* r1 V;;
  ~) P0 o: W/ C! k( A& t0 @reload)) y! |! o/ r( V) }
reload
  w( o5 O9 B0 Q;;! }9 m8 ]7 c! F0 n' F
restart)
) v) A3 V0 _* w2 xstop
' B$ A7 g5 D) x1 i5 Ystart
: ~+ z! Y* U& B' e;;
& k" j" ^9 s: E+ b  ]8 Rstatus)$ s- W1 z" n# W( }
status $prog
% }( _6 E& ?3 `0 |, @& [1 j, z; vRETVAL=$?
$ I- R, \. f( x4 e;;/ m. B! P1 _) g3 s0 I' D
*)
3 x3 K+ A# c. r+ w3 L* Cecho $"Usage: $prog {start|stop|restart|reload|status|help}"
; X0 W$ J0 H9 N" J7 a1 Yexit 1) C5 A" \0 R3 t7 Q: M/ ^
esac
# v  c: k- C8 N/ {) ^8 uexit $RETVAL
. d  P9 I6 r5 X4 I
: O! h! q8 P. U; m% z

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


$ G1 m7 J" V8 J0 z% N3 G4 bchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
# e9 b7 e0 ^' R  F* Q

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

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

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

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


; p& n7 I6 N/ s9 @; B3 G       location / {
: `0 L( ^5 W9 P5 r# P, b( Q, V. M            root   html;
% I2 Z8 e5 l3 [' D+ @! j2 G; S            index  index.php index.html index.htm;% L( W/ t) |1 p0 y  W# [
        }* b' h7 n( ^  U" K1 y3 W
靽格嫣蛹嚗
0 T$ Q+ g; O1 e2 D6 [! f7 [% r, m6 \6 y' D

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


/ h3 x) t! b4 z8 A0 ?; ~location ~ \.php$ {
, Q: ?( V+ U  l* q+ `5 T& @            root           html;
7 Y2 E- l0 n0 J! T6 S/ D            fastcgi_pass   127.0.0.1:9000;, _: t) L4 t: s( O2 `
            fastcgi_index  index.php;- L9 Q1 `; B3 j- g$ q
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
; `! D8 z) s  e6 V) C* |# X1 [9 V- a            include        fastcgi_params;
6 N5 M* @+ @/ \6 d; t        }3 p' ~' o% c% |( L( e( ^- U" G! s( a
靽格嫣蛹嚗, D6 c% q2 Z- Z/ h! a8 }& y5 y5 V
2 `2 ]$ `4 E3 S; J% e! _6 F( U

        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

閫蝻拙僎餈唳桀嚗扯嚗


( _$ C# {4 g4 {

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql6 a; q, y& _; S( u3 w, t
8 R/ a9 Q; ]! ^+ U, \, c- N/ j
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
5 J6 `  x# f* L. x8 o

cat /etc/passwd 亦冽瑕銵" K% o+ t% \3 K/ Q: u
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀$ b; @& K+ A# |0 m6 {* U0 D

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql" j- ?3 P  o5 M7 k

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
  l2 z0 J% C* f2 Q8 e) ^chkconfig mysql on6 `. V) h. w) P5 M2 H9 T" X
service mysql start  --臬決ySQL8 \& ?& w, U+ r  D/ `( P7 p0 x  j

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
- S! S% F# _5 q: {. D( kexport PATH9 {  {2 `# L1 `9 |8 S

靽摮source /etc/profile

扯嚗


8 u  j. a7 x. ?% qmysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
8 |; u( |, _0 c4 W3 V
! A! D2 @( J: A

霈曄蔭root冽瑞撖銝氳oot

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

% d5 r" a. L; c  ?

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


1 k3 |! f! o  l

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


3 K- Q8 M4 R3 \' F

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! E3 S6 g6 K2 _( g) N" C- L6 D! B

2 \8 \1 z6 H* l. [rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
, {9 V/ Y# i$ }; kCreate /etc/yum.repos.d/php-fpm.repo file and add:( I- F. T. X. j8 E3 M3 [! Q
  1. [nginx]
    $ m# W; O3 x$ V, _
  2. name=nginx repo. P# c5 A. i. B" |5 O4 o2 w% m
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/2 T( J$ z$ W- D1 p, t
  4. gpgcheck=03 K( D4 N# _$ r: Y! g& o9 \
  5. enabled=1
銴鋆賭誨蝣
9 _$ O; f& b; U$ v7 e: w
yum --enablerepo=remi,remi-test install php-fpm( ^8 B8 j+ j( G9 T3 u3 I
( @; `' S8 Q/ Z
0 c: ~2 n3 N* ~" @+ y' J6 @
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
4 G( v* T* l7 b! h

嚗yum remove subversion //貉蝸雿祉svn
8 c' d( l' l. h2 v4 N

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn5 N$ j; I, W4 V# F

餈# 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]' ~* u/ V4 _1 h1 a& A- H
# harry = harryssecret" q0 h9 J! h; O; e' f8 h  n9 P0 x
# sally = sallyssecret) o7 {* N3 O7 A, V$ ]
wangning=wangning
5 J. q; S. d& g# J/ Vyanzi=yanzi
) ^  w9 h% q2 r

#vim authz  //霈曄蔭


$ l8 G# X' F* `/ a8 l

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none; H  ^9 y* E7 w2 L( }
auth-access = write4 Z! ~/ ]& t, V
### The password-db option controls the location of the password
" q1 ^0 @8 C" w3 S### database file.  Unless you specify a path starting with a /,
8 _+ M: I6 j# m$ a% G### the file's location is relative to the directory containing
6 O8 q9 R9 A; `* p### this configuration file.0 a; @6 r5 L( a
### If SASL is enabled (see below), this file will NOT be used.4 J! a! `+ u! g
### Uncomment the line below to use the default password file.3 r" w( S" b: c- J0 K5 i
password-db = passwd2 p5 F% z/ h, ^) G
### The authz-db option controls the location of the authorization
. |' g% d  j; O1 T3 d7 ^### rules for path-based access control.  Unless you specify a path5 J! c. U1 Y/ [( Z$ F# a& l3 B
### starting with a /, the file's location is relative to the the
4 q) W5 b- S- W5 I### directory containing this file.  If you don't specify an6 V0 Y, ~3 ]# |7 B/ S4 _& \6 K
### authz-db, no path-based access control is done.9 q3 b+ L; ~1 O2 ]
### Uncomment the line below to use the default authorization file.! u. A' S6 @" O; k
authz-db = authz
) k( f! y2 G9 `8 f* b% [& o& k( ]### This option specifies the authentication realm of the repository.
- _* ~. s) Z; k0 ~# `, G# S8 \' V### If two repositories have the same authentication realm, they should, R+ I! G/ {, w5 w2 ]$ d
### have the same password database, and vice versa.  The default realm0 r5 L# E2 X- O4 [& W% V
### is repository's uuid.# q& Q# d, P1 j1 f, _
realm = My First Repository+ H- `9 \( L: A% P+ v; M5 N

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn8 j$ _' F) s2 S, f' }( M

#killall svnserve    //甇
: q/ V7 e  G" K: P& n7 D% i

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
! V! a5 a+ K$ @- [8 a" y/ {

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) r! O! Y3 J; @4 K8 O$ M

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

vim post-commit嚗券Z伐


( |( _6 C0 g6 O, f9 d& R% K+ }

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" :
! j& l& x+ }0 Y( a

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


9 r4 a# p) x( \. I3 I6 i( M5 b7 ~) \瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

( n9 \4 s; e1 s7 J  x+ @; J+ R5 B
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿1 |* T; n. Y4 |; G% ?

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-29 07:17 , Processed in 0.079713 second(s), 20 queries .

蝯∠.撱

52avtv@gmail.com | QQ:2405733034     since 2015-01

鋆貉憒 敹恍敺 餈銵