52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
6 I, r2 D  Y; `1 f7 U, B' ]  W
# N3 a& L) r4 @

格嚗剖遣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* P6 i* D7 R' L

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx2 C/ }& S9 ^- u9 M6 U: C7 T

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
0 K1 g) f% h* j- b- j% [/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx7 [4 k" K, P- E9 s4 r2 F0 C

$ J7 O) I* ?8 v! |chkconfig --add nginx
4 r! Z: D9 y" z$ Y
+ O+ v* F) e$ N/ F8 f# hchkconfig nginx on( w, g& ?! a0 R1 l4 O% Q1 }

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

#!/bin/bash) }# H& F9 }; P4 {. u
# nginx Startup script for the Nginx HTTP Server- `/ _- p$ |2 I
# it is v.0.0.2 version.
0 T- C! ^: t% S0 l4 F7 f# chkconfig: - 85 15& U; H2 d7 q* D  `  Q6 o+ p( ]
# description: Nginx is a high-performance web and proxy server.
: U& g3 s$ M  h1 s1 q3 C4 L# It has a lot of features, but it's not for everyone.0 Q  f, `* w- A
# processname: nginx
; e: i# [( F7 m3 m3 P! ~# pidfile: /var/run/nginx.pid* j; f% B* v& D, {
# config: /usr/local/nginx/conf/nginx.conf
8 J* u8 E" n) L  b3 ~; fnginxd=/www/nginx/sbin/nginx
- |+ ^4 e* h" i3 u! `6 Znginx_config=/www/nginx/conf/nginx.conf4 k3 w0 [, S" j( T# I
nginx_pid=/www/nginx/logs/nginx.pid+ B$ A5 K) m7 ^! Z+ l
RETVAL=09 D% S2 z- `1 Y$ n9 C
prog="nginx"
* z8 ~; \+ \1 q' _: ^9 s# Source function library.6 D  N& B* e6 k& y0 C. r. b3 R1 p" ?  I
. /etc/rc.d/init.d/functions/ @8 B  t# |; q' r6 c* J9 p# T
# Source networking configuration.
5 |( S: T. p! j2 }6 j' Y! Z* o. /etc/sysconfig/network
! M- ~! S5 H: f; \# O) T. F# Check that networking is up.. s" c" R& x, ^, e" c0 Q
[ ${NETWORKING} = "no" ] && exit 05 L) a' L# ^9 Y1 ~! w  ^5 Z+ S
[ -x $nginxd ] || exit 0! c3 `0 K; U2 Y) ]& C0 P+ g
# Start nginx daemons functions.# B. q) x6 W0 U0 y
start() {; F) u* |- U4 k6 U2 ^, Z
if [ -e $nginx_pid ];then
* d, S# B, g7 h. H5 _/ Decho "nginx already running...."
' N6 k$ L  f1 x7 Nexit 1
) o( f' G" j2 `7 Afi1 n0 q, W, Z* F3 S+ J1 ?4 R# `
echo -n $"Starting $prog: "
+ M+ {2 Q1 }- ydaemon $nginxd -c ${nginx_config}
, |5 h7 C" N. K. _7 |6 r9 oRETVAL=$?/ I* [9 y3 W' E4 Z. y+ {  N' D
echo) W3 Z# k5 j- E" ?# `
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
4 j4 D; v+ |1 @$ S+ wreturn $RETVAL
) G" m/ C3 k) M/ i4 Z) [2 c* r}/ F8 N- s( }1 Y: Q
# Stop nginx daemons functions.0 l- K3 k1 K" Q# r6 K1 m- k" g
stop() {" B, g/ s7 D2 M" [
echo -n $"Stopping $prog: "
  }' l$ Y# J, H. g' Q  nkillproc $nginxd
& B7 h, \+ i/ a3 b8 cRETVAL=$?2 J+ s/ I, P' E" a
echo
. K" e8 c" P. Q4 d* Y[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
. r; y. E2 a4 K# \  F8 Q% c, a}/ ?  Y$ r( O$ o, f+ Y1 K1 `6 e" v! `1 ?
reload() {
" y: R) c8 A. A3 {' ?7 r: k/ Becho -n $"Reloading $prog: "
  H' ?( ?, j. c- ]: _  v) u#kill -HUP `cat ${nginx_pid}`
8 ^1 i& s) g6 i  C0 dkillproc $nginxd -HUP
: @, ]8 O5 [! |RETVAL=$?
3 ?( g0 M- x( x1 v5 R0 Aecho# a3 E+ d4 b" g4 }% V  T; P8 F* q
}
' }4 [8 h7 d3 i  x0 M# See how we were called.
  w/ x- ]! `) \, ^' X( Ccase "$1" in2 _7 T( B& ]6 o% |4 q1 ]' {
start)! d& i3 O1 J* F# i, o' }8 z( `
start
- x5 ]# F. W% ^8 K( p2 o;;) k( k& @* Q  o* i) S
stop)
& K& {( g5 M2 p2 a, Sstop! ^3 G( s. H' B2 |% C: v8 \& F
;;
) l" F6 K, x- y5 s; `& w4 X- W- ireload)% {& _6 r; c' [3 M& Z9 Z
reload& y8 H; J3 J) U/ {- ]
;;
! l) {6 Y* X: k* A$ Xrestart)/ m* c- n: }+ U! Y
stop8 T0 |% A8 Q, i4 `; t
start
4 s' K  m  P9 U! Q;;! a% U: P8 W4 `  I
status)/ L, u# T4 ]; v; l( U
status $prog
$ k% }: z3 D! j7 M7 o3 |4 q' ^RETVAL=$?! v3 p/ x' R2 {
;;
0 e! E, Z3 |4 f% W/ W5 _/ |*)4 Q( ^, C& e8 F, \
echo $"Usage: $prog {start|stop|restart|reload|status|help}") N" c9 d0 {: l! z  }8 K+ o4 I
exit 1$ Y  s  a( S. ?. u
esac
' i  S  Z" h) _exit $RETVAL
0 L; ~( n- N2 v7 K% Q
& P* c0 B/ ^, t( c( ^- y: t  |

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

/ l4 T# ]6 Z0 W
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗/ s  p0 m' t" E3 v& t( [

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

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

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

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


; y% m: o- @- z8 I8 u       location / {# x) N: y4 h+ G: A3 c
            root   html;7 V/ V2 V" D, S! g. Y, c
            index  index.php index.html index.htm;& X' A% j7 q. h$ R
        }0 @& C* b# G& E
靽格嫣蛹嚗# R$ E$ S1 X0 i* R% E
1 Y& s9 X2 E0 Y  n7 C: |

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

, P8 j9 J, b" X* f0 Z% V
location ~ \.php$ {2 d) H  e, O1 Y3 W0 A3 C
            root           html;( h, ]( R& h/ d+ G$ j' Q
            fastcgi_pass   127.0.0.1:9000;& c9 k- L- C7 O: X2 }  d1 m' c
            fastcgi_index  index.php;
; [% l; p7 I! R: p2 J" n            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
) c+ z/ o" K8 Q! g            include        fastcgi_params;
5 S2 y6 V0 |# L# Z8 B# Y        }% V$ I$ p3 j, A+ X
靽格嫣蛹嚗2 X4 N" ]% }$ J& P* u  Z7 e7 o
6 l7 B' C" U: m% T

        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

閫蝻拙僎餈唳桀嚗扯嚗


  G+ f  {( ]0 g) N' Z# 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
; `2 f+ y, j3 m; A4 @. n
- M+ W$ V+ t2 N1 x8 \/ I#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
) @- z6 b4 r7 {4 x

cat /etc/passwd 亦冽瑕銵
) Z  J4 F/ q2 `/ i% f( i, scat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀1 K4 F* {9 A1 s$ N: j% d

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
5 c6 U+ b3 d/ s) B7 s

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql8 @6 G8 ~( r" o" \# Z( c! f
chkconfig mysql on1 e7 A( B# V" i1 e: Q
service mysql start  --臬決ySQL
! E! Z9 k+ \) g' {2 t8 Q

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH3 E; X1 S& {4 F5 P7 a
export PATH
; t$ i. _* W4 n0 ?

靽摮source /etc/profile

扯嚗

  M, r6 `2 p! |
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
+ k( j: J& w' k% }, a8 l

" m2 v2 Y% s' c; z* _1 ?0 z4 z4 s" G

霈曄蔭root冽瑞撖銝氳oot

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


3 E9 R  q7 I* e( ?; H. s

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


; z8 i6 Q' g  K, J" G

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


# b+ B: `4 q& H6 Y

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
$ Z5 h) e! {7 l! K& g; F7 v
* P3 X* v- |6 l$ K. s  e" M$ ^( mrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
+ u: B2 @) c) U" s! b2 K  b& gCreate /etc/yum.repos.d/php-fpm.repo file and add:8 P- h* v: r# j3 j1 {( B) T
  1. [nginx]
    0 W# S& Q- M$ X* x
  2. name=nginx repo
    # V2 W, \$ o0 n6 Z
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    $ w2 F  G9 P$ H! r
  4. gpgcheck=00 p7 V/ i2 F: o( H6 l
  5. enabled=1
銴鋆賭誨蝣
# M* H/ K# f9 ?! Y
yum --enablerepo=remi,remi-test install php-fpm
' n  k4 V! S0 u% \$ n. t
8 P0 C- i( C# W& c! j
1 v. f! W' y: j
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
! Q: I4 k% x2 c# K

嚗yum remove subversion //貉蝸雿祉svn
8 S9 [% G% O: w# T

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
. H) {1 P( s( w4 F2 a4 g

餈# 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]
& i$ k! p& E: ?) R4 ~" F# harry = harryssecret
; i1 D. U& _& ~3 H, i* w" O* K0 x# sally = sallyssecret4 p0 b* u. U7 E
wangning=wangning6 k. V+ P3 f8 f8 Y
yanzi=yanzi. K8 c- W* {9 e+ U- u9 w

#vim authz  //霈曄蔭

6 s- q- x. B- h: D. L# M

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
& l1 q0 W; l+ S# N, I( cauth-access = write: v# o4 ]* u2 @' j
### The password-db option controls the location of the password1 h5 z. Z; {! z5 }
### database file.  Unless you specify a path starting with a /,
4 z1 `9 S# \3 h### the file's location is relative to the directory containing
2 K. R7 ^- J/ r6 s% s9 U& j### this configuration file.3 k" L( Z4 x- _5 k" |7 I- L5 v
### If SASL is enabled (see below), this file will NOT be used.( \* ?& ^) [; I, ?; w
### Uncomment the line below to use the default password file.5 Z8 Q: A5 I+ O7 ?  B" D
password-db = passwd
7 b# [+ h: ]( @. d### The authz-db option controls the location of the authorization
# N8 h1 C$ U7 s+ I$ |### rules for path-based access control.  Unless you specify a path
5 `5 [: I9 _9 Q9 a% B### starting with a /, the file's location is relative to the the5 o/ ~' M+ T9 Z9 e
### directory containing this file.  If you don't specify an  g% R+ l* P2 b. k# }) a% G
### authz-db, no path-based access control is done.
, Z0 C  v2 n" r7 P: o6 j) C### Uncomment the line below to use the default authorization file.
9 n( ]9 K( _0 aauthz-db = authz1 k- L* i3 Z0 G3 c1 ~
### This option specifies the authentication realm of the repository.
. G4 y) ?, G+ K& J### If two repositories have the same authentication realm, they should5 a1 J- n3 K( g8 _$ u- G; w
### have the same password database, and vice versa.  The default realm
0 t& i- i1 A7 j& s0 K, u# T. F### is repository's uuid.
5 D# k% L  C9 d& F5 n; I  s+ Wrealm = My First Repository
5 r! h8 _) S0 ^$ `9 C1 X

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
# @5 ?4 t' m8 W: W, I

#killall svnserve    //甇$ R% _- S1 b% V7 R

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx' I: ]  @% l( j

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/web7 c) `* B$ `  K1 s( H9 j) B/ O3 {" I

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

vim post-commit嚗券Z伐


. G. m0 S, u+ c" K% 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" :' S* x% d( b9 w

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

! |( z- o% @1 E2 g( D
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


3 f$ ]% c3 I. I- J4 p; pvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
* D: v: S, k. ]" m4 p2 q5 K

雿輻券

祉蝛閬

撠蝝詨

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-6 02:08 , Processed in 0.071883 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵