52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659* B8 F# ]* ?* d9 k- E' M

) r$ N  f7 y% T; G# y9 t9 V8 Z

格嚗剖遣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 cmake0 {$ s$ o5 N  d5 D4 {; d

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx# \! }3 T0 S' Z" _3 [3 S

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
7 q( ^) d4 m* {/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx$ ~5 o. ]+ K1 ]9 d  F  R

0 F" S  W* d1 r' bchkconfig --add nginx
" ^( V4 E' E, U: \9 F' @  M( E4 s2 R2 \# @
chkconfig nginx on
/ S8 [7 X0 g5 K0 M, }8 {. C

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

#!/bin/bash& h8 U! E6 c1 }  {
# nginx Startup script for the Nginx HTTP Server: O) `# f! V' O7 W8 `+ ^8 A6 D; p
# it is v.0.0.2 version., u; f- P% A5 c8 Y, S5 U# N3 u
# chkconfig: - 85 150 ^/ M8 v) k& @1 A+ s
# description: Nginx is a high-performance web and proxy server.
( Q3 x. _4 M8 V7 A5 V& {) z# E# It has a lot of features, but it's not for everyone.+ ]4 S/ O, L9 X; j" ?* b
# processname: nginx+ _7 @! h, n& p2 |
# pidfile: /var/run/nginx.pid
+ }$ }, N" A! n( t( i8 L) @/ j1 {# config: /usr/local/nginx/conf/nginx.conf' e% r) O" u( s7 N0 d
nginxd=/www/nginx/sbin/nginx
: L+ ^$ j$ |- d0 [nginx_config=/www/nginx/conf/nginx.conf
6 |: A/ A) Q9 [nginx_pid=/www/nginx/logs/nginx.pid
$ s, q7 F# e0 r, u4 MRETVAL=0
  ^/ n: u0 i5 S! |2 B4 `7 _8 }6 pprog="nginx"7 s' F, B9 j( o  n0 |6 Q2 k
# Source function library.0 b% C+ e, v& ~9 k1 D0 {
. /etc/rc.d/init.d/functions9 ^) ~4 j: l2 y
# Source networking configuration.# L& N; k2 q% o6 c6 s& P4 E3 k  i
. /etc/sysconfig/network
  f; }$ j+ B, R/ N& }# Check that networking is up.0 b5 W' C0 @/ I
[ ${NETWORKING} = "no" ] && exit 0
, z% }8 B  l: K& E  ^[ -x $nginxd ] || exit 0
. K8 l2 t2 `6 D- U% K; S# Start nginx daemons functions.
8 T+ p1 s4 B/ S8 U' u$ hstart() {
! ]$ M, ?; O- vif [ -e $nginx_pid ];then/ i& K6 j0 j2 P" T' k# C1 m) u
echo "nginx already running...."
5 K6 T6 W. W# y9 hexit 1* I3 B" p7 o$ b6 ?
fi$ f# O  K; A+ F' O( ], N/ K$ {8 b7 W. k
echo -n $"Starting $prog: "
' j  b6 X. g; _9 s8 U! Y9 Ydaemon $nginxd -c ${nginx_config}7 p6 g+ F$ ?  y' z4 N6 y2 ]" n
RETVAL=$?
+ U) t1 W( C* w6 aecho6 ^+ p0 M0 c* P1 d4 S
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx! X9 m3 C; V( Z
return $RETVAL4 v. L* B# k/ d6 r
}
8 C/ ^& n; c1 H0 W  Y5 d$ R9 N# Stop nginx daemons functions.7 `) I0 D1 J* w7 q1 ?; s! T* W
stop() {# C1 O7 w6 D6 q  R+ c
echo -n $"Stopping $prog: "
4 j& A" b/ l$ lkillproc $nginxd
# [  S/ [: u4 r' ^' PRETVAL=$?
; f+ j4 V: R5 S( |echo
& Q9 ]$ B+ V! {* g% H" k[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid' O1 g: t) P) ~
}& G) `# t4 `/ A+ @' y" p# ^8 q
reload() {
: E2 _' i! }+ d7 B; aecho -n $"Reloading $prog: "
( P$ W- X4 f  [5 s- h#kill -HUP `cat ${nginx_pid}`
, W; w3 Y$ |0 }  K3 B: M  ^killproc $nginxd -HUP( v* ^) {  T: x. }
RETVAL=$?
+ c) j  E* f: u. Z% `3 W  Zecho
7 b" A, ?( E. y" E7 g; |& w}5 {/ Q+ H4 H, s( ]) D, r
# See how we were called.% y, m4 l5 J! H$ x9 A$ x. h
case "$1" in
, C* A' D' g& [start)
1 k7 ~% c5 @! t; estart( P$ i; T- b) \; U+ E
;;9 F! I7 ?' g: Z+ l8 w# r! ?& W/ L: u
stop)
1 @/ [. c" r6 ?1 ^  Istop4 x8 {+ b4 w# S# _: v9 {3 P$ u
;;  h( S  i- ^* }; C
reload)
% l1 M$ C% ]3 }" M  Preload1 t# y: O" Y# \: r' ?9 @5 a& `  e  j
;;
5 L9 k* L3 i  I/ E  V! j; P" Mrestart)( x7 c6 O6 D1 e6 `0 @0 a
stop9 Q+ q3 D4 A3 M$ e4 s/ Y
start2 i# i1 S! C) H. L: Z
;;
' @! |9 A1 C9 T0 i" b! wstatus)
5 E# ?, l8 ~" W# a9 cstatus $prog
, z& Q, A% Y; eRETVAL=$?  Z9 L9 Y  B3 m' Y6 s; E
;;
- ^% C2 m4 z: |*)
& |! z& Q9 }& g* I4 S! v/ z0 l" }echo $"Usage: $prog {start|stop|restart|reload|status|help}"
3 P7 r" L: k1 ~6 h2 Uexit 1# `9 i# E: f( ]  C6 ]4 @9 A$ E: A: T0 T2 ?
esac! _" V$ X8 Z0 n2 y2 u$ H8 L. `( A4 v
exit $RETVAL$ v& A( Q+ M$ f8 D

- j' m. T3 R7 ?* y# _; O5 S

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

3 x( }4 g0 U+ V0 k) ~/ \4 N- c
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗* x  X/ _& S1 s8 q# K

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

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

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

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


" O, v  n' T/ ~4 w       location / {
3 m: b" F+ }; \' K# c            root   html;
" A6 E# Q+ w* @- @! S            index  index.php index.html index.htm;( B/ b* D# A) X3 q  J4 p
        }7 ^5 ^, _7 W6 \& n
靽格嫣蛹嚗4 G' d% J, V" T6 P# |

. E; B$ y! o3 C* F* ^0 A# z

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


6 P. ^: l: V3 e5 H! Wlocation ~ \.php$ {# u$ E5 X5 y  w  X
            root           html;
$ O9 t+ W5 h; v, s/ N            fastcgi_pass   127.0.0.1:9000;
5 q: h+ _5 j" P- u* g/ }            fastcgi_index  index.php;% t' s& x% o1 y) o5 N) Z* ?: q
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  {+ x( T: K, k% n" J; t            include        fastcgi_params;
# c* @, w1 V$ Z        }* _7 F; \) T- J& N/ h& M" u
靽格嫣蛹嚗
3 a1 b1 C2 s! l; W' i, {: S& J8 f$ Q3 d5 S' e  X2 l; e& H/ t$ 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

閫蝻拙僎餈唳桀嚗扯嚗

7 @" k9 L  K3 [

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql- A0 Q' ^8 u+ Q

* D  _! o7 Z. z, q# W$ y#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏8 Z9 P  n  C5 W* n; o

cat /etc/passwd 亦冽瑕銵; j" J' F/ D" Y; S( _, A
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
+ P" r, Q3 D" _* S' [$ g. T

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
& r- ]# a8 S; T" w9 U

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql  G# P6 L% N) C( x: @  e
chkconfig mysql on
) A% i9 f3 K# J: r/ F4 sservice mysql start  --臬決ySQL* I& ^: M. x! g, _

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH* y+ c4 b4 [- G8 l
export PATH' v. p7 m" t8 n! u6 u; X" n

靽摮source /etc/profile

扯嚗


* A9 |: M, V' T  Q  D; a( I7 ]2 Omysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
3 S* u/ O# l% c# t4 Q5 g  X

: j& X3 q; f1 f; D9 Y9 F0 H

霈曄蔭root冽瑞撖銝氳oot

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

4 J2 B+ p& }2 ~5 S- |7 w- U

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


& o& a& M1 {/ j4 v( m$ Q' h

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

; ^2 S/ V1 P, B  V

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$ T; N" p1 D1 u" h/ @$ o7 g/ {

& u7 r4 ?4 u6 j4 ^% X# `rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm$ b3 v$ s& y* @7 l5 M. d8 t+ V6 S
Create /etc/yum.repos.d/php-fpm.repo file and add:
" B7 l$ P( h8 f
  1. [nginx]
    $ _7 O2 F+ M. F- Q% c
  2. name=nginx repo
    2 Q+ r  K! Y( ?4 G$ s
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/& z; t4 h; U. c2 |1 D( x
  4. gpgcheck=0& c( G. e$ U- U0 h
  5. enabled=1
銴鋆賭誨蝣
" o. s1 }2 M  k% t! }& X
yum --enablerepo=remi,remi-test install php-fpm3 n9 t; f$ i5 Z1 Y! J# J
! e: Z0 ]. [: C2 ]2 w4 }

6 A% P  B0 N4 G( O- ^鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn4 u  b0 N! u% P9 o9 k$ r2 R7 I

嚗yum remove subversion //貉蝸雿祉svn4 {  a: b; |6 {* Q% i1 g8 N

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
$ ]2 W9 m) m; N- c3 T  ]

餈# 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]. c( R/ S$ E" i
# harry = harryssecret
+ |  c9 s. O- F, c# sally = sallyssecret
+ {3 b+ f  R0 |9 T4 Hwangning=wangning0 r. S: x, O$ M. K9 d- o; y  n
yanzi=yanzi' T; P( D0 O2 G/ I9 H

#vim authz  //霈曄蔭


2 _) r$ y( R) ?- b4 J7 Y& E9 o

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
! p6 B6 \$ `. M2 i& s1 Q5 Gauth-access = write  I3 ?+ I5 e2 `, y5 C7 }
### The password-db option controls the location of the password) C+ Y. F7 K8 J& T; Y9 |
### database file.  Unless you specify a path starting with a /,/ I: u. X# c; ^- F. `$ j
### the file's location is relative to the directory containing
- _4 M7 h3 R# y4 j" q0 @5 k### this configuration file.
" G" ?4 U. y% N6 r$ m### If SASL is enabled (see below), this file will NOT be used.5 R; C/ ~: t$ G1 }7 R( r& W
### Uncomment the line below to use the default password file.! E* Y: F! x; `5 A4 K- h6 c
password-db = passwd+ S( d/ l* h( O  r5 O$ W6 ~7 G* ~3 u% d
### The authz-db option controls the location of the authorization
: \9 E; o8 r( O$ Q9 d! K### rules for path-based access control.  Unless you specify a path, f2 J6 `( n$ ~
### starting with a /, the file's location is relative to the the, D  H; K/ r- s
### directory containing this file.  If you don't specify an
" F! Z# V( F) j+ Z3 W. z### authz-db, no path-based access control is done.. g/ S+ c/ T0 I, Z0 y
### Uncomment the line below to use the default authorization file.
, D' o7 \# a# K. d/ G3 uauthz-db = authz
! ]* K# a+ e* g! }4 h8 A# G9 m### This option specifies the authentication realm of the repository.
& P' q  a* h" H9 X' p. ?6 l; u' e### If two repositories have the same authentication realm, they should1 h9 A4 m3 Z. a
### have the same password database, and vice versa.  The default realm" U( P7 p( V' x" k) Y! A0 v
### is repository's uuid.
" i! d/ U* I& f- a  ~realm = My First Repository- `( C& A& L4 N2 J  \- d

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn' X% F; r) n. ?

#killall svnserve    //甇
$ `$ Y$ d' P2 ?' N- y( ?( O

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx# Y, [/ \: Z& f* x* 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# K& R* W7 L- F* }5 E- Z

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

vim post-commit嚗券Z伐

$ b: \6 S+ V) ]# |

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" :# x: Q! r  t/ F4 g% n) c

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

, u6 d! z: x. l3 M& R; r  G; ]
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


9 V8 c4 h, N1 ~. F4 zvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿# j+ B2 c- v- _- b7 v$ C1 E; M

雿輻券

祉蝛閬

BT蝳

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

QQ|撠暺撅||52AV璈A

GMT+8, 2024-5-21 16:08 , Processed in 0.082815 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵