52AV璈A|52AV.ONE

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

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

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

# n! T6 t1 |. d' A) [

格嚗剖遣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
) Q$ L' k4 N$ w9 X* R/ t+ r) Q

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
  R" b! a# v4 R

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www. n! q1 H- }2 j/ `/ n7 \
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx5 i8 O9 n1 q2 ~) l
& p5 T0 r( b; h* n: E+ q0 m4 m
chkconfig --add nginx
1 Q! a5 u( M& k# g$ K' ]- N' T
3 c9 `+ L2 {+ ?) \$ T, Echkconfig nginx on# E$ M' b7 Q# ], Z* I# O

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

#!/bin/bash
5 z7 o( l, b) A# f: p- P# nginx Startup script for the Nginx HTTP Server
, e. a6 {1 H* ?" d$ U( l4 n# it is v.0.0.2 version.3 |% i6 N0 d* t# s" l6 {
# chkconfig: - 85 153 C" ]6 z% v) y4 L, P% ]; k6 |  V# A
# description: Nginx is a high-performance web and proxy server.
1 M3 y* L. H( I( l8 v" ^6 D# It has a lot of features, but it's not for everyone.
9 x, O5 x) Z, X0 ~. Z. x9 o3 A6 g. f# processname: nginx
- V2 ^8 G5 u6 E2 P6 s: A9 ^5 s* t# pidfile: /var/run/nginx.pid
( u( j) j6 T! L$ i2 \: N/ E, N# config: /usr/local/nginx/conf/nginx.conf
$ _7 `0 w2 Z  s! N7 @nginxd=/www/nginx/sbin/nginx' D' X0 [$ J$ l
nginx_config=/www/nginx/conf/nginx.conf6 m' h9 s1 v( w$ h: s% F8 g
nginx_pid=/www/nginx/logs/nginx.pid# q7 Y3 u  O* _
RETVAL=0; W3 n" n' p) ^+ I+ ?) n
prog="nginx"  ~7 g: J; u, `8 Q" c9 w
# Source function library.
3 C8 ~6 R; X4 Q' }. /etc/rc.d/init.d/functions
) A3 k  O2 E. |7 ]# Source networking configuration." P- d2 H. K3 z4 S
. /etc/sysconfig/network0 h4 B' B; {  ]3 H$ j  T- b2 P+ f
# Check that networking is up.
! G' Y# ]; S5 K! j[ ${NETWORKING} = "no" ] && exit 0- S: i; H6 A& P6 K/ k
[ -x $nginxd ] || exit 08 V, M( S6 v8 u" y/ |7 e
# Start nginx daemons functions.) q( B( z% t% @, K5 S, O
start() {
  S- ^+ [5 ^$ J( f# hif [ -e $nginx_pid ];then9 m! |  g  Q; ~: S, A# G% u0 f! J
echo "nginx already running...."* c' L+ ]' h9 {' v7 \* R, |' G
exit 1' l* P! y4 _$ F3 v& r$ L) b
fi
: ?7 s3 ]0 S) H, i' decho -n $"Starting $prog: ". A' L$ [5 A# j+ I+ e
daemon $nginxd -c ${nginx_config}, o& T6 e# a3 Q9 S: X
RETVAL=$?! m' f& r/ e: J! t- v
echo" w# F  o7 W, x1 r, E7 h3 r
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
7 \# j* F/ Z5 e+ J7 M7 E0 E8 u% breturn $RETVAL
8 I( T6 p7 }0 W6 Q4 Y% j5 o}
5 Q) l% `1 S9 I) g3 E; n' }2 @" Y# Stop nginx daemons functions.
5 O: m6 C. E. W9 b6 ystop() {
: p7 L1 I# F3 p7 p2 j) `echo -n $"Stopping $prog: "# K& E/ f( Q8 n- u( r1 B4 R
killproc $nginxd9 U$ J* f+ W5 T
RETVAL=$?
: W# V7 k# B$ S+ N& {1 Becho
6 n& A% t- C9 J[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
& c# {) C9 d- F$ j; v5 M. ]}! Z, E- ?( [5 p; h9 F7 c$ {; S, s
reload() {
' N) e! j. _6 h# L/ f5 hecho -n $"Reloading $prog: "6 ]8 ^" h: n$ O9 x5 W
#kill -HUP `cat ${nginx_pid}`. @- \; t$ a. z/ f( }4 e/ P2 Y
killproc $nginxd -HUP
& \6 j! ]4 D; eRETVAL=$?% F7 m+ G9 E! l$ |9 y. Q6 K
echo/ O. [( }: @# y
}7 Y/ q$ }( n; o$ L6 z* m) y
# See how we were called.
/ a( E/ T1 j! m! ^case "$1" in9 f- S' F, h/ W/ ]- h
start)5 C/ W0 t3 t. X- E8 T4 p7 q
start. l& I' X+ @. y% C! |( h
;;$ w9 L% m9 o4 P8 v$ r
stop). m1 G7 E- a' v/ p, Q; p
stop0 g, Z! K0 J5 @, b  b7 _: T) Y
;;
3 D7 @, J. ]. }- @7 T2 Ireload)
; W" s* C8 K5 M4 y$ K) yreload
* s$ C; V4 D( U: W1 x;;
% J3 x- F6 a+ _. rrestart)/ L4 k+ q6 w  H8 q
stop
' ~. N, A( Q! Ostart: E/ `% X3 @% |& q7 e# |. y
;;1 i; y3 B. W1 m4 f) z$ y" M
status)& z1 b2 \1 P7 C" u+ T
status $prog9 e/ y" B+ e5 `0 E2 D; l
RETVAL=$?; t! @2 g$ h6 i  O5 D: E; p
;;
0 b. _8 A2 b: u/ g*)+ x4 x8 a. Q/ W4 w
echo $"Usage: $prog {start|stop|restart|reload|status|help}"* p5 c+ ], @& }8 r7 a" x3 @0 V5 `2 B
exit 1
( _% Z6 m; h) Z# r7 l+ n$ F+ Oesac
8 o7 |4 a9 _2 E0 [exit $RETVAL
6 J- a' x/ o- G- r7 {# N1 c3 n9 ^: P$ N; b

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

5 j" G! ^0 J1 n+ F
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗& t0 G2 S1 y/ k. c6 ~' E5 e

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

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

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

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


4 w0 b+ v) r4 S9 B       location / {: y* h9 M5 ]' [, D4 G
            root   html;
1 t& y" `3 r6 s$ P            index  index.php index.html index.htm;
; U; j, b* t& r3 U        }! h2 }7 t( N: v
靽格嫣蛹嚗. [8 e6 ]1 m; G

) N( G( a& f0 J& X

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

- z- ^4 c* r- [' ~& r
location ~ \.php$ {
# q+ o, t: p2 u. Z            root           html;
$ {% w% q, ]8 r) W: ?& C- j! _* T# |            fastcgi_pass   127.0.0.1:9000;
; A4 t6 b2 L. n0 y5 P  k% d            fastcgi_index  index.php;& _) x5 }3 x5 x2 U* K
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;* S1 x2 ^; R; B7 ~' t' e
            include        fastcgi_params;
4 _$ K8 |6 U& V        }# u4 A9 b4 H1 g5 c8 y% ~1 H& V
靽格嫣蛹嚗9 u% M+ N1 y6 m- c9 v

) }( x2 K' b, x3 S1 {! F3 s3 \

        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

閫蝻拙僎餈唳桀嚗扯嚗


1 F  S1 v, \- R6 p

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql4 S! f! c8 M: v# O& @
4 Y6 [$ g% ]4 c1 G7 b9 O
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏* a" E0 L0 E" A0 R/ }2 P4 m8 G

cat /etc/passwd 亦冽瑕銵" {* J/ P9 m: \0 S6 p6 a; x8 v
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
) Q8 x6 c* T" r8 j3 n  |

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql3 o' [" e- X1 d: X1 [

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
4 L6 n  ]; g' ], L' Y/ Xchkconfig mysql on9 @  s2 O( K. W9 Q' A, v. B' p
service mysql start  --臬決ySQL8 G: N$ C; I: \, Z( ~

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
' F1 t! K* k' C3 mexport PATH
2 g* U" g' X  Q1 r

靽摮source /etc/profile

扯嚗

# A) D2 o9 [1 f
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');  o' F* ]) j& ]* W( e

% V, T6 l) F9 T* l

霈曄蔭root冽瑞撖銝氳oot

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

8 ^* U; o* w" N; T; v+ G

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


- e! v; Z4 w4 ^  H; t  B: J. n

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

; t. @9 T, }8 c# ?7 M. p

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# _) {% W( }, ?1 _* h

/ e/ W( x8 P1 _6 N, Wrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm2 ^' s' o8 O2 W: u7 e+ n  K
Create /etc/yum.repos.d/php-fpm.repo file and add:
4 o- u7 T7 L4 z* o  i% Q; i; x
  1. [nginx], A' t7 V0 W5 `! C
  2. name=nginx repo
    9 b2 S1 _, f7 E8 W  u
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/; X2 W5 J1 Q3 m  \0 \3 [8 ]
  4. gpgcheck=0
    6 {+ O# Z2 N2 E" U. _( ^
  5. enabled=1
銴鋆賭誨蝣

$ m3 h: W2 z" f( O/ e- _yum --enablerepo=remi,remi-test install php-fpm3 C8 R" a: ~( _

( d0 D* Z, L4 K
, ~2 J/ y6 ]" i+ z) c. E- P
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn( q: R1 n" {0 q9 z( U  q) j

嚗yum remove subversion //貉蝸雿祉svn
1 m5 J! R. u/ \$ U4 q, N8 J' {) F

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
  [- P2 R7 `  i4 S1 S" L8 {2 C

餈# 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]; B0 I' \" Y4 b8 u$ L8 S
# harry = harryssecret
0 p6 B( S! {# k5 h. U+ I# sally = sallyssecret' E, _( q7 s& X
wangning=wangning
) D5 p  H$ {8 {5 L: k1 Uyanzi=yanzi& B# H4 X  P/ ~

#vim authz  //霈曄蔭


) G! V9 H+ `- c9 X1 L/ H+ Z- u

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
6 G. G8 B2 C# ]+ R/ l: Cauth-access = write" o% L* d6 y7 U! ~2 Q- z
### The password-db option controls the location of the password
3 Z; z+ D0 j6 [& L3 W### database file.  Unless you specify a path starting with a /,
! d$ T3 d, U3 |### the file's location is relative to the directory containing
$ e% z( h" I3 \5 ^9 @### this configuration file.7 O  j9 E, B0 `/ V! ^6 p2 K+ N
### If SASL is enabled (see below), this file will NOT be used.
- ^7 Q' p" z, ^% S; C### Uncomment the line below to use the default password file.! W/ U1 x' R1 K' w5 q$ a- }
password-db = passwd
& X% p' |# a- F" w' D### The authz-db option controls the location of the authorization% Q% u, z. h  {# i- A/ d. G
### rules for path-based access control.  Unless you specify a path: Z% V( g+ K& _
### starting with a /, the file's location is relative to the the
0 G$ E' Y, l8 p+ J! V### directory containing this file.  If you don't specify an1 Y  P) x9 J! e" @+ F, }1 X' h
### authz-db, no path-based access control is done.' G* N! Z/ W' ]
### Uncomment the line below to use the default authorization file.
8 \: r; E0 P2 T$ J0 Lauthz-db = authz$ g4 b0 C  U, s) h
### This option specifies the authentication realm of the repository.$ V% h( l6 `' H9 n4 D4 m( F/ k
### If two repositories have the same authentication realm, they should
! E0 G0 X' R* f/ k# q# f: ^7 Z7 ?### have the same password database, and vice versa.  The default realm* i2 u, U8 p# T
### is repository's uuid.
0 J4 y6 N/ Z5 S7 ?7 Vrealm = My First Repository
) ^; _5 M( Q$ k4 i8 }9 ]5 w! K0 ~

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
/ S1 I! a9 p& z2 P% ]1 |

#killall svnserve    //甇
% u. E5 G2 E/ I. C3 J- Q3 e

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx+ A0 o- C& U; }% ~2 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/web: ~/ @1 l! T$ V: _6 ]( H

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

vim post-commit嚗券Z伐


# b  H' G( w; g5 t' U

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" :
: ~8 t! I, g6 Y( e

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


& L7 m, ]& q. d6 J* S; k瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

  i1 J/ P5 J# v; E
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
) d% \/ j; i' h

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-1-26 04:22 , Processed in 0.083635 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵