52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
+ U1 Z" C# G' w: O, x/ @
3 t# Y7 I4 O. Z, q( U

格嚗剖遣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
1 `& M) A$ f+ d, w

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
. G  C1 Y2 V7 O) g

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
/ E( T/ t  J/ q+ D8 I  g/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx0 H) Y! L8 }% @% X# \0 e/ A

9 I( a  d% y" Y" v4 ychkconfig --add nginx
% Y5 j. N* C% Z$ _( P2 q6 Y, J5 j' n
chkconfig nginx on" Q/ t7 o7 V1 C' _

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

#!/bin/bash
& g  z6 D# I1 B# nginx Startup script for the Nginx HTTP Server: m/ w6 ~& C/ w$ ^
# it is v.0.0.2 version.
# T, G/ ?6 e% M# b) C# chkconfig: - 85 15
0 D4 \1 ?! S0 [# description: Nginx is a high-performance web and proxy server.
  ^# q& ?2 }" z9 O# It has a lot of features, but it's not for everyone.+ x. u% r- @7 {( ]5 I3 b7 T8 ]
# processname: nginx
0 U# r! p8 x9 R. Z  \# pidfile: /var/run/nginx.pid
2 ?( K# @7 c+ f  o6 i# config: /usr/local/nginx/conf/nginx.conf
& o& P. _0 ^: Q& x# n+ `9 @9 Cnginxd=/www/nginx/sbin/nginx
4 N9 r& G6 u, I9 Fnginx_config=/www/nginx/conf/nginx.conf  t# G7 g/ N* K- _/ D' P9 a& I
nginx_pid=/www/nginx/logs/nginx.pid
3 E& C5 w; N. R: F( i6 E" b( ERETVAL=0
4 o: e2 f. r' X9 V. Xprog="nginx"
) E( d) u0 \' l# Source function library.
: D6 N8 v/ |1 l; [! o. /etc/rc.d/init.d/functions( Z/ w" Z  }# M
# Source networking configuration.7 p" v' B; V: s8 F3 x7 Z
. /etc/sysconfig/network
0 v( D6 x9 K* b2 N$ L2 U# Check that networking is up.
( F( D. y# Z# K" b[ ${NETWORKING} = "no" ] && exit 0! P- ]# ~) O2 b, E0 n! T3 E
[ -x $nginxd ] || exit 0) t2 z/ h! f" U! d
# Start nginx daemons functions.4 n' L& D" ]: b$ T
start() {' b0 M! ]* `& V& e
if [ -e $nginx_pid ];then" ]0 ~% w  F" v8 K
echo "nginx already running...."; C9 d! K4 J' ]2 f( b& ]1 P* |$ @
exit 1
! m1 A, y: w8 ~' A% \% f5 Yfi
" [& Z# S" n# b! c; Xecho -n $"Starting $prog: "
  [% E! c! a; _" m) Adaemon $nginxd -c ${nginx_config}1 f$ |8 a9 A- H3 \
RETVAL=$?, E7 _: @- ]( {( m" L' c
echo
4 y! q" H$ i0 V5 ][ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
( p. J0 d3 E. U6 e6 X. areturn $RETVAL/ E" S# B" k$ y
}
! P% W6 c) I# {* [# Stop nginx daemons functions.
, l: y6 f  Y4 T; _. z6 H) cstop() {0 i& r& P( l& l! g% d0 v) F6 K
echo -n $"Stopping $prog: "3 Y7 c# y7 D  C5 K4 J; @9 C
killproc $nginxd3 s$ r) {! w8 p- r) I7 v
RETVAL=$?
# `/ V" R' @$ d" R6 V# jecho9 c/ l" H( k8 D' D
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid, o9 ]' u* |. a! D- G
}# b5 q* h4 j$ B! b: v# ~5 }
reload() {; C* W. Q3 b. e
echo -n $"Reloading $prog: "
' T4 M) K: H: W' ]7 ]' T9 b5 S/ v# o#kill -HUP `cat ${nginx_pid}`
6 R- E* e- V8 _" x% G9 p5 C" Vkillproc $nginxd -HUP& a5 Z9 i2 d9 c) ]' g9 C
RETVAL=$?
9 u3 o# X' v; {3 _( secho
* a, X1 u$ ?% \2 _( f$ W5 s}3 F  F+ @: F9 B% o) Y: E
# See how we were called.
* D% j3 |, K% F7 z) @* ucase "$1" in
( F1 R* U$ l1 `2 }/ r+ G- K0 H) Kstart): j9 j( O: p; b- G' m" c8 E
start
% ?( N' J( b2 x) @& _;;2 U, C4 F& D, p9 v4 @
stop)8 A8 z8 C1 e! ?' N; Q9 y
stop! Z2 T( {* P! Z. |6 }! V
;;
5 c) K$ L* i& t9 |3 {. [reload)
1 M5 ^; k7 m8 t% z2 Lreload
) x6 T1 D; _( L+ a, Y& ]# q% h;;0 X) I" y8 t( H+ A" R$ p
restart)
$ j' c, M! p9 {1 F9 g7 v1 L. m1 gstop
3 q4 \! H; x& H- S9 ystart
- I$ N/ T2 ]" G! {4 d;;  `/ @' i! S/ q5 V: w# o6 P
status)
. y7 l  y* @7 W1 Q: w1 I5 xstatus $prog
& G4 p5 t! T- a0 a! F7 wRETVAL=$?
, m& g; M  {0 R2 O/ B$ \4 v& L) _;;
8 _) D6 U+ J3 W. O5 f7 r*)( ^3 T; k4 r. O/ ?6 M/ k# m
echo $"Usage: $prog {start|stop|restart|reload|status|help}"' \* W# U5 B' ]6 d' R6 D1 D7 O& c
exit 1
/ e* C8 x  ]1 A5 P, B0 E2 n6 Sesac
- ]: x9 e- v: R$ @exit $RETVAL* U+ `. Q# W9 K! t/ `! S3 o9 h! ^

% \/ j9 E4 x5 j/ R. E% G

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


! P' a8 {, f' r* ]; dchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
8 h  X, y. x' W5 o/ f

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

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

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

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

& c6 e, f; s& I) F$ ]/ n; U
       location / {0 Q' P, P, `, }  t  r7 \3 r
            root   html;
$ G4 f# Y7 [! q8 c/ A            index  index.php index.html index.htm;$ m" x# W9 y: y3 a1 R( l- p
        }  B* S* M% L# W! n( P# I$ Y
靽格嫣蛹嚗. G& y! S2 V- W  D, m
1 W; X9 Z' D0 S7 X& N/ V0 ^

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

3 \% y! N) `# T% y1 h0 g/ T
location ~ \.php$ {
, Q/ r5 S6 `+ w" G, j            root           html;
4 V& n8 a/ K7 v: Z* b            fastcgi_pass   127.0.0.1:9000;
$ e+ E: s: v' i            fastcgi_index  index.php;
8 [9 t0 d* y3 t* i# M8 a- a            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  }: j. a7 {+ s( w0 P! g7 E            include        fastcgi_params;
9 x' e% O5 X% K1 |        }
, r9 t, U  M1 Q; O& V* a0 @靽格嫣蛹嚗
1 I2 ]+ f$ S! t' |" \3 m( _6 \5 S- m% N9 \  t) d

        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

閫蝻拙僎餈唳桀嚗扯嚗

8 W: j: F. x/ ]

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql' Q$ Y- M( V4 [1 J$ B! b

; d$ O0 K/ E6 E" e#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏, x" ?/ f6 e; O1 ^( B$ _. d

cat /etc/passwd 亦冽瑕銵% S# P% w4 S8 I+ l
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀& ~  P+ u& K2 ?

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
8 N! c. t0 F1 u

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql. d# l- l( m+ J/ Y, ~
chkconfig mysql on  i) g' P/ ~# r9 m1 w1 z2 T4 |
service mysql start  --臬決ySQL
. d, M$ P! L% _3 v+ ]2 U

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
0 C" N) W7 B3 }. y/ W! I- \- V5 pexport PATH9 Y; P6 p) t5 E; g

靽摮source /etc/profile

扯嚗


3 u" }6 w: e7 c( bmysql -uroot  mysql> SET PASSWORD = PASSWORD('root');1 S+ C% v. y3 j$ P

/ v( }: M2 k7 r4 j8 P1 X) k5 I/ f( v7 R

霈曄蔭root冽瑞撖銝氳oot

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


- q; z( a8 {. e' U5 o

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

0 l8 F$ l7 Y# ]6 i- T+ z  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嚗


7 R: `4 \+ I7 O. i: g$ k* `2 \# ]

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' N3 L# U+ l2 c" k* f+ F
7 G: h7 I7 q9 `, i
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
/ \: n! ]9 ~  {7 C5 `6 V( C$ ?4 w( YCreate /etc/yum.repos.d/php-fpm.repo file and add:8 a7 L7 U+ X  i, M4 p. R
  1. [nginx]6 w1 j( P% m3 X" M
  2. name=nginx repo# n& j3 p$ \# T" c9 [
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    4 L7 ^1 E9 L( H5 V
  4. gpgcheck=0
    " \+ h, D9 ]$ n2 n, W- w) n
  5. enabled=1
銴鋆賭誨蝣

3 A  A2 ?. X& ]2 fyum --enablerepo=remi,remi-test install php-fpm
7 j& n* B, R9 Q5 X$ V$ i; q& K: k7 V+ u' `- ^$ T

2 v6 G6 X8 @$ D& ?  b鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
# q1 h3 }* i+ ]) t. I. U4 p: u

嚗yum remove subversion //貉蝸雿祉svn
: f4 p; a% u: h2 [2 H

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
, g, M' l: L* B: v: F+ {: L7 H7 B

餈# 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]
5 ]. U$ P  w& {2 _6 Z* A1 e# harry = harryssecret; Y$ k1 {3 P5 L0 W  H
# sally = sallyssecret. N) P) }. W" }
wangning=wangning) N- y0 i& [. y% B
yanzi=yanzi
0 c8 E4 G; c9 S& [; y

#vim authz  //霈曄蔭


6 |. a  D7 ^, E! `; s

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none+ w' w. u* `! [( t/ M+ r
auth-access = write/ X; Y) u$ m5 C* q! Q! s
### The password-db option controls the location of the password
* I" t# Y1 F$ i4 Z( K8 H  d( p6 ?8 @### database file.  Unless you specify a path starting with a /,
9 d' F! z/ c" s7 m! j  y1 r( o### the file's location is relative to the directory containing+ e- J& L1 w4 W. Y, i8 {" w) N& U
### this configuration file.
$ c# r: z, A8 L% ^7 ~6 W, n### If SASL is enabled (see below), this file will NOT be used.
1 M4 n& _* u0 o### Uncomment the line below to use the default password file.* p' F9 ?* |! ~, O6 D2 L
password-db = passwd# B% o& I' W! n* }, c# Q
### The authz-db option controls the location of the authorization3 [! r* n. Y; A2 U. E
### rules for path-based access control.  Unless you specify a path
6 `) E* _& L* ]( f### starting with a /, the file's location is relative to the the- {, R& K& D( e2 |8 P, q. t
### directory containing this file.  If you don't specify an; I/ S: `: P% B& u- |
### authz-db, no path-based access control is done.
8 z# e/ }! ^+ S( _9 n### Uncomment the line below to use the default authorization file.
: a) W# Z, g% U# j# jauthz-db = authz3 z1 `. ^+ A% N# K
### This option specifies the authentication realm of the repository.
' ?; K3 I- g2 P: E4 T/ m! V' N### If two repositories have the same authentication realm, they should9 e2 ?6 u  x2 A6 G! `; P0 K
### have the same password database, and vice versa.  The default realm
% u. k* Z' S7 I% C$ [8 W) B! ^### is repository's uuid.
+ o5 {0 G$ N% e; [+ Irealm = My First Repository7 G5 E; w, l! c% n' ~, P

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
: x0 r; ^5 K6 X! d. t3 J

#killall svnserve    //甇
7 R% E" [9 o+ m: V- `3 x

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx  ], L, n* y( T9 v% J# 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" I. P' U7 S1 I. M: l

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

vim post-commit嚗券Z伐


- X' |- g6 G. F6 Z- S% 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" :
$ ~6 M! p2 ?2 x* T$ b9 B$ h. `8 N7 c

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


% O7 g5 _2 q/ U: P瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

8 h& ~3 `; P2 @2 k2 E0 w8 k: w$ o
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿' I5 o0 X9 {3 L8 W

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-20 03:27 , Processed in 0.074400 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵