52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
) s* n0 L3 m" ~( f" F6 P. a
7 z. D2 r; E* m2 _5 a0 f

格嚗剖遣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 cmake2 p7 c9 B" B+ l; i, y7 G; x

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx7 _4 Y# ]- K$ @: I) M! ~4 m  _

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
2 c# I/ K0 G1 p/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx) H3 D- i. `; u- w
: g' c3 C; r/ ^6 g( m. m
chkconfig --add nginx( X* L2 X9 s! I4 W
7 @& k# X/ Q" S! |; W# h3 L
chkconfig nginx on
8 N' S! R3 \* R" p/ O

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

#!/bin/bash
* Y# Y# e3 G$ Z# nginx Startup script for the Nginx HTTP Server- B& X7 O" Q' [  z: _. Q2 {
# it is v.0.0.2 version.
; O3 K/ H4 w, \" F! p# chkconfig: - 85 15
% ~: A) j" t6 Y0 I% Q: }# description: Nginx is a high-performance web and proxy server.5 V3 [! N& m1 C" d" E$ s
# It has a lot of features, but it's not for everyone.  b0 v- y, }6 |
# processname: nginx
' B# n9 e$ N/ B, s# pidfile: /var/run/nginx.pid
6 l5 ^! F! X0 q: w6 W) S# config: /usr/local/nginx/conf/nginx.conf
' p1 P+ ]+ W: A9 B% ^6 c, ~nginxd=/www/nginx/sbin/nginx
& x' O; r  [+ R: m& q) @nginx_config=/www/nginx/conf/nginx.conf
5 `5 y4 z: T+ ynginx_pid=/www/nginx/logs/nginx.pid' E. |8 a0 p. T$ ~* S$ Y. Q7 ^
RETVAL=0
6 J1 b' Z5 L3 k. a+ M" A8 Y+ E  Rprog="nginx"$ Z% U6 o# z6 k" b* p* p* G
# Source function library.' g$ z% w1 v6 V- @: I
. /etc/rc.d/init.d/functions
9 X7 B7 L% [& X4 z  d) b) w$ n# Source networking configuration.& k2 Q- t0 e" r
. /etc/sysconfig/network( X# D7 s- ]6 o& o  @5 C! l' \
# Check that networking is up.
0 h; i  l- B/ H2 [  W$ {# R[ ${NETWORKING} = "no" ] && exit 0
. p9 ~- ^+ D6 K[ -x $nginxd ] || exit 04 B! j, D- g+ \
# Start nginx daemons functions.2 Y1 R- G1 c9 I) ]4 n7 @) v
start() {
& w* \+ ]2 S  {/ n' Q- Wif [ -e $nginx_pid ];then
8 j$ |8 i1 t5 r: |/ x1 y* K- s! pecho "nginx already running...."% X6 f+ J4 A! @1 N! h- p% R0 H, E
exit 1
! l; f3 g% {6 z: T+ V+ J% S5 I6 Kfi- U2 c0 S9 T/ D. Z- ^3 Z
echo -n $"Starting $prog: "
0 H/ w2 R: ^( m# v8 E- q& N5 zdaemon $nginxd -c ${nginx_config}
( k$ S7 k. @0 RRETVAL=$?
# r3 I( M# G  U& Xecho& j0 f* R: D6 P7 O$ l% d
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
0 D1 z7 P, z9 }, P! [( h$ kreturn $RETVAL
7 M9 f% ^3 m( n% ^$ _( _}1 h& y: q9 U4 p8 D7 [
# Stop nginx daemons functions.
+ ?( R3 @. `! Y( D6 V% n4 G* e* [5 V+ wstop() {
- Y$ B7 B/ x8 a0 aecho -n $"Stopping $prog: "1 n2 D6 V& K1 U+ D. u. o9 ]9 S
killproc $nginxd, ^  \0 e; I3 y+ k" Y6 C: P0 ?1 o  q
RETVAL=$?. M5 _! l/ y" U/ M2 y4 R8 t$ N$ N
echo. K* c* k0 Z4 p0 ?! t& m, }+ I
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
5 i; E3 v7 K1 b2 @9 l6 ?# q* V( p}
, N+ D6 F$ W3 q' g8 L6 Y1 Ereload() {
* C$ C8 b+ _4 becho -n $"Reloading $prog: "
; J9 ?  Q4 Y4 _6 Y6 a#kill -HUP `cat ${nginx_pid}`7 R( n0 d, `: e! I9 x1 v
killproc $nginxd -HUP
# s" F4 K- b' @; s4 fRETVAL=$?
% x, ~3 B2 n. j6 Lecho
% n% E1 w! {# `1 v) @}
$ W9 ^9 [+ `$ m1 P" O# See how we were called.4 g2 x$ s) o. g  @
case "$1" in! O/ W$ x. [& b4 l* B; B" O
start)
. M9 I" t( U5 [2 {start/ `% [% F: J* t
;;
) q0 H# L0 {. ]" K" xstop)( u1 f6 C# _9 A2 o. W( ^* K) w! o
stop
: v6 f$ j. X6 [3 @;;
0 x' L+ \' |( H( h. b/ a3 [7 k2 H6 areload)$ k4 r0 y; u6 z  N& n( o
reload
6 R2 R/ X8 {1 I9 i9 n;;+ Z) ^2 A) @6 Z
restart)
; s$ k7 I: s6 u1 fstop
  F% x$ S; k$ U. ]0 }start6 \  U8 V# q( x5 N8 E! Q
;;
7 C  G" V6 Z4 [/ P! f! F9 F) rstatus)
2 b; \1 u3 C5 @1 W3 j4 k7 Ystatus $prog5 e! n/ W& i- q" U1 a
RETVAL=$?
/ G( A; C7 W1 f4 j1 ?;;
7 n: F3 _4 T. R/ `) Y*)
- \4 m! }( V! D; }; w: E, wecho $"Usage: $prog {start|stop|restart|reload|status|help}"8 t5 \% v3 c* q6 p
exit 1+ l3 j* z5 y4 e: b9 r8 I! u8 o8 b
esac$ r  n5 C6 e' i" {& _
exit $RETVAL' ]1 `- z. @; T
& s1 `! j. ^1 S  F% `5 Q6 T

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


4 G- c& i! ~2 V0 r5 R( ]- H" Nchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
5 w. y; b! {+ U! X# T% y& I/ m

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

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

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

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

3 a9 @% I$ S. p
       location / {& x( l! ~* {7 E* c
            root   html;
! m4 |* I+ c! d. A+ o+ f5 P            index  index.php index.html index.htm;9 q4 ?. O5 V  {- w  k, Q4 a
        }5 H  d5 n( v( _# G, J  L
靽格嫣蛹嚗
" n) u* O" {6 O7 M9 f- B. v
  f1 s! N1 m6 h

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

3 s+ _6 T; y: `6 D% Y, q  _
location ~ \.php$ {
5 b5 c- c0 ^$ \& O8 D% ^            root           html;
: |* F- g- A. H* N' v7 j            fastcgi_pass   127.0.0.1:9000;
/ c' w7 s$ A) F: {" l" M1 X            fastcgi_index  index.php;" |- i, m  F1 x# K% m
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;) L3 ], `1 k- u
            include        fastcgi_params;1 @1 b1 _, A* T& u; P( w( C9 k
        }% Z/ K: J$ H! \, j" p6 i" Q2 y
靽格嫣蛹嚗7 w$ \( j' l3 k' Q
* ]4 M" g/ G' {7 s

        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 C) [( j7 t4 d& L

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql& D; ~4 i) D- k8 Q# A

7 R/ S; [& F" `0 |, B#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏7 l7 E1 ]) E# f  x2 `6 v

cat /etc/passwd 亦冽瑕銵" C6 P0 y* X. k
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀7 [0 z; a5 W2 y! X1 O3 \: ~8 j8 y

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
! ]# F9 M' c2 l2 y3 @" z- Q

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
2 _+ Z6 s$ M$ q3 W& v* @! vchkconfig mysql on0 i7 v: T5 ~; ^5 ]
service mysql start  --臬決ySQL+ }$ ~1 C$ X: r; z- ^; @

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH6 G, E  L! a$ {. R
export PATH3 |; N0 p: Z$ S  t6 g2 Q

靽摮source /etc/profile

扯嚗


7 p, f: D% s0 ^6 G* |# h; D2 Zmysql -uroot  mysql> SET PASSWORD = PASSWORD('root');7 d# c, q; w+ q! r+ L4 C2 U
" X" v) t5 `& I% \4 [

霈曄蔭root冽瑞撖銝氳oot

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


: P+ S* g  N8 W

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


6 [/ c+ Z4 k) W; o+ {

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

* |- z; F$ o) l8 P; v7 ?6 [

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
' z; u7 P/ L5 w# o( P0 g! A1 `- G4 M
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
/ W- z6 c* L- ?% ]" O' x& f3 _+ [Create /etc/yum.repos.d/php-fpm.repo file and add:
. B' [5 ]  K1 [6 {9 Z
  1. [nginx]
    + J& ^3 M% s. p+ i, R+ k
  2. name=nginx repo* W2 w" J) d2 t! e2 A
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/6 r) t0 K$ m+ b& u
  4. gpgcheck=0% X+ [7 y7 a1 c
  5. enabled=1
銴鋆賭誨蝣

0 S( s& ?& U6 V1 a. G6 Uyum --enablerepo=remi,remi-test install php-fpm# G8 c& B3 S- |6 X+ t

, p2 Z; E, O( ?! X3 x) w, Q
6 W/ b! t! n7 t
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn/ ~% d8 ~$ v: ~/ U: Q6 t1 l. m

嚗yum remove subversion //貉蝸雿祉svn% I1 }+ B% ^; ?" O* i( e# k

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
+ }$ f7 M$ h0 n# ~, Z* ?' L# U

餈# 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]) P& B  A# L, J; E3 g7 |+ S1 u
# harry = harryssecret
+ P) u' t. w; M3 a* G( R( m# sally = sallyssecret
! N9 I3 J! @2 ~3 f. X; qwangning=wangning
+ M/ s9 A, `) A. |9 wyanzi=yanzi
6 V/ ?  I, j& n! a$ k- P

#vim authz  //霈曄蔭


: H- o4 Z8 {( i$ B# V" i! v2 E

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none. D% H; G" d0 O0 P+ R( t, ~8 q
auth-access = write+ D% r4 c, x/ B2 W
### The password-db option controls the location of the password! w& S: _& x. s6 a9 B+ A: ~
### database file.  Unless you specify a path starting with a /,1 u2 U8 Y7 L! i* U
### the file's location is relative to the directory containing
) k! l& H5 k; {. e5 O### this configuration file.6 t& H1 X9 Y/ z0 Z) u
### If SASL is enabled (see below), this file will NOT be used.0 I/ }. G/ X; I( |; V
### Uncomment the line below to use the default password file.
) b& L5 F5 u& j, l' qpassword-db = passwd
3 ?0 o& _7 D1 j  b- P) y$ h### The authz-db option controls the location of the authorization
$ E0 n. a5 `. t+ S+ {' x4 j### rules for path-based access control.  Unless you specify a path
5 m. k" w$ V2 n7 L7 h5 w4 H/ [### starting with a /, the file's location is relative to the the8 ~! t# V, n; [5 y
### directory containing this file.  If you don't specify an
; E( k+ y- k  {0 Y, y### authz-db, no path-based access control is done.. v5 I% H/ ~+ @3 U; `
### Uncomment the line below to use the default authorization file." O$ R( a. {( N' Q& d
authz-db = authz
9 G1 V0 v) y2 n0 R3 a' U### This option specifies the authentication realm of the repository.
8 u' g! i4 J/ T" I! W2 C/ q### If two repositories have the same authentication realm, they should
8 q" U/ p- T) B, r1 N5 E8 Q### have the same password database, and vice versa.  The default realm! `7 s" p+ r8 ]) Q
### is repository's uuid.
) i$ J3 _! b) r* o5 G& G3 v  Orealm = My First Repository# `, K% p8 P6 p! Z9 |% ?( S1 F

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn- a' T6 [5 O) O/ g/ G. f% j

#killall svnserve    //甇
9 h$ B2 w4 [! z. r

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx% ]# }! x$ @+ h) m

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
/ a1 L( ?! v4 O2 q. J+ P

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

vim post-commit嚗券Z伐


. ^8 D. v/ _, x( 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" :  r2 o" F4 Z6 y2 O, g

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

  Q2 m  A* Z8 k5 I& U8 s
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


( x+ n; q1 \4 q. ivi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿% g/ E) z; F- T4 x

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-8 00:59 , Processed in 0.070081 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵