52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |甇摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
" \1 n# t( S8 i- E, x3 h8 g
5 {0 u) l1 y" H4 x

格嚗剖遣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
5 N  l1 N$ y5 M5 t) R, {1 ~

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
0 F2 Z( }+ A8 C, ~1 r& [2 U

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www: h) A- v; N* h9 {
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx
9 Z7 K# t) F0 b( Q# ]6 d* \8 a! \4 X" N' g( C( \! O2 o7 R
chkconfig --add nginx
: _: F. c  f  A$ a# T1 [* ]) M; g& q
chkconfig nginx on
6 o3 ~& j8 e9 I4 O7 W7 m2 G/ R

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

#!/bin/bash
6 W( _2 ?0 @; ^# nginx Startup script for the Nginx HTTP Server
3 ~# t( z+ V. K: o7 a/ o5 s# it is v.0.0.2 version.
5 |1 |+ J( a3 t; _9 f% J# chkconfig: - 85 15
" K7 o: i2 l/ h  [5 i0 N# l# description: Nginx is a high-performance web and proxy server.# P- }( S7 O. Z' L( v
# It has a lot of features, but it's not for everyone.
, b% t  n8 y9 I5 b+ u- n, h# processname: nginx
) \- a9 j2 D& e# pidfile: /var/run/nginx.pid
, N8 ]" ^$ j" L" K- J/ S# config: /usr/local/nginx/conf/nginx.conf/ `+ c: }- o* X0 _* \
nginxd=/www/nginx/sbin/nginx
% |) r2 C8 I/ H5 Z% enginx_config=/www/nginx/conf/nginx.conf
/ c- D5 @3 h  y3 U$ r: d6 [7 i) b9 Nnginx_pid=/www/nginx/logs/nginx.pid! f" Y7 F; Z2 @: y" ^
RETVAL=06 V( G/ X% x; z/ N+ s
prog="nginx"
4 Q/ z) j" I0 b/ h* d2 a# Source function library.
: q0 R! H* B0 r; H. /etc/rc.d/init.d/functions
) j7 ?. |& i; I7 Y# Z+ h( {# Source networking configuration.8 {1 n. e6 l2 O1 k7 Z# D
. /etc/sysconfig/network8 ?& {' h3 z9 S6 o( k5 e6 N* P/ Q
# Check that networking is up.
6 Z5 Q$ p  D) N/ _) {( V[ ${NETWORKING} = "no" ] && exit 0; J' F7 K  @" z  h; Z0 O
[ -x $nginxd ] || exit 0% d$ G3 {0 j" {9 ?; M9 c4 c
# Start nginx daemons functions.( q; _- c  H: f8 u+ f) w! i  J
start() {+ Z9 Q/ ]- `9 e3 W# Y/ O+ @, D
if [ -e $nginx_pid ];then; t0 I1 H% w# x  l
echo "nginx already running...."
0 n: [8 h. r4 E, M2 R& ?; V# hexit 1
5 Y% C$ C& X! r+ ffi
: m; E* m- }; t+ Vecho -n $"Starting $prog: "
! a$ _6 m9 y2 {, s0 }6 Q; c$ zdaemon $nginxd -c ${nginx_config}0 @0 ^! u+ ^0 f6 a1 \
RETVAL=$?
! n1 J8 B* ?8 f* vecho8 s2 r$ }/ J& V" G
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
2 [  d! K, @2 j7 V; G8 k: j# h6 Wreturn $RETVAL2 O& Q; p6 R9 O( T3 w/ W# X
}2 }' A& e# f! Y) z
# Stop nginx daemons functions.
' e, m" A. \/ S3 `" a- S5 N5 nstop() {9 r1 ]0 |$ q: U) _* e
echo -n $"Stopping $prog: "
% g# M: v9 @: O& @! C+ Lkillproc $nginxd
; H. U" V; o, P$ i2 wRETVAL=$?; Q- M9 g2 m5 L& |8 ~
echo
  \! v* _& {  M[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
& r7 s5 |, \; S}* G0 U; g9 p* x5 F* b& H
reload() {
4 ^+ }! a( C/ X0 H, Pecho -n $"Reloading $prog: "
5 b+ G. N' Q7 j: d3 z- H#kill -HUP `cat ${nginx_pid}`  \, P% B& f6 I5 V5 t9 a5 U
killproc $nginxd -HUP
* ]1 z6 k+ R4 w' Y( c' vRETVAL=$?
% ^( ~$ q& S) J1 K  techo; \7 j5 Z+ I# ?
}
: _3 {8 F6 [) l9 U$ u8 C$ e" H7 E! O# See how we were called.
$ J* N  ?/ i# X- M. Jcase "$1" in
; m" `$ f2 X$ K) Ustart); O* L' v! P* t; I8 \  B. {4 b
start- N  D" f  }( I1 [- k8 Q# s
;;( k3 y! n- i) Z  \, r
stop)
3 \, A7 K" H: T& w$ w5 X% Gstop
  H! s8 }9 D  W2 ~2 U;;/ F( M) P3 D% r
reload)
% m. c- B/ x. O+ l" ~4 a! |9 Creload
7 t" Q( s" w/ Z8 W;;# \4 d" y$ C  ~: U' x4 u0 b1 ~8 Y
restart)
# r1 ]+ `; w" ~stop
/ a5 C7 ]- e: S% hstart
8 [) W5 E" u# C- M, Z5 v;;
7 r: i( s' t+ t" ?# Fstatus). U7 l! H% E. v! a% n. A+ S: C
status $prog. d# ?/ j0 P6 i8 q- g( z5 d: f: P1 \
RETVAL=$?% x! P9 w" c% Q6 }& e% m# d
;;  h& L+ I. W% w
*)
6 J+ a1 M5 t; t' }echo $"Usage: $prog {start|stop|restart|reload|status|help}"
0 H& {5 }) ?1 U! k! [4 _' c+ n' lexit 1
# P0 w9 P6 _6 U7 d6 fesac, Y$ ^7 [7 |* W3 d/ b  H" p& V
exit $RETVAL7 }1 I( k5 j" j7 n6 I. O
/ j- c$ D: W9 ]) @5 L5 ^

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


1 S; u0 A1 o5 V, U5 Gchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗+ s+ g# l3 h0 {4 R/ M5 z5 H

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

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

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

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


- }5 r' i6 j  u. N( v' t       location / {+ Q* w# [; h6 `" f
            root   html;
$ V! m- v$ G- O* ^) e            index  index.php index.html index.htm;9 g0 i+ z& O) v2 ^
        }. j! \2 r, s* F; O+ S
靽格嫣蛹嚗6 ~( H4 v6 f. G5 R+ W- ~

, K8 t; p* e* l" F

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


4 D/ r$ _* ~0 Klocation ~ \.php$ {8 O% N# k  v" G0 R/ X5 B
            root           html;
+ ^, l. G: z* T# l+ Y" [            fastcgi_pass   127.0.0.1:9000;2 P+ `1 G4 d- e! D! P& `" s
            fastcgi_index  index.php;" T; P% b+ W- \+ E7 H% r
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
8 I$ i' C& A/ m. k1 ?4 S            include        fastcgi_params;3 |4 E" j& H$ c0 _% ?- p( e
        }% ~# _+ \2 K+ v0 x2 i; }
靽格嫣蛹嚗
' _0 s8 v7 V! ]* {3 R9 x) q: m) w9 F9 q2 d! u. N/ z

        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

閫蝻拙僎餈唳桀嚗扯嚗


' z% \  I$ ?7 m8 g

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql* S  }2 h+ p" c9 A/ ]- X3 s) R
' ^. ?! K& X/ W1 I1 H
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏' G' C% o2 D5 u+ p

cat /etc/passwd 亦冽瑕銵5 ^: d2 m( r. Y, y  ]
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
2 ]& Z7 t- R6 E! L" G( {

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql2 F  S) u4 u5 t4 c* j

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql4 n2 s/ j, L: L& F8 i8 R- g6 Q' k
chkconfig mysql on5 w$ P6 ]( n3 @9 k
service mysql start  --臬決ySQL" Z4 c: |) o4 P' K' V# Y

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH/ J: N! ?! z, `. X6 R$ L5 L; d% T; p
export PATH
9 z* f. Y" ]- g

靽摮source /etc/profile

扯嚗


  `4 P9 M# h3 H# F; Imysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
0 u7 V+ R3 A4 R  C$ V. R# i

6 _, K5 j) C0 y8 W6 |; E

霈曄蔭root冽瑞撖銝氳oot

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

& ]( C3 w4 _# A5 W: D  Q+ c

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

8 x  Z8 N6 B( N" R5 ~- k

#./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% [  J! J4 Q( N  w

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
' q- U7 T: f: o9 P* h: J/ I7 @) D/ h# d* d, ]/ u8 U+ }" e4 \+ H
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm( e0 @* S7 f: i& W6 w9 k3 V* Q' x
Create /etc/yum.repos.d/php-fpm.repo file and add:: A% L4 N0 L/ d% |4 g
  1. [nginx]
    7 L' R6 W4 C9 s% Z1 f
  2. name=nginx repo
    3 E4 E# Q* W3 J
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/- j7 T. K% F0 L- ]+ ?, T
  4. gpgcheck=0
    + d" M- M+ h/ q" E& P
  5. enabled=1
銴鋆賭誨蝣
0 j% o5 U0 W. |/ b3 j3 b
yum --enablerepo=remi,remi-test install php-fpm
1 t4 r/ U  C, a7 n2 D: c. w. M6 m5 c
# ~" u; P' z# D& y( ~+ a$ B& @
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn$ P6 z( Z) v# i' [* I

嚗yum remove subversion //貉蝸雿祉svn
& y3 I+ _, X$ R; b. G) f" k

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
: T2 Q( b5 z# z5 L9 @& o) e

餈# 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]/ u( }8 w' `) x3 X
# harry = harryssecret2 v( ^' `# E, Y9 B' v4 x
# sally = sallyssecret
1 \* S1 M/ x, m% l& p. z+ |1 twangning=wangning2 d5 s" C; h2 y/ a3 w: C
yanzi=yanzi+ Q! ?3 X3 u5 ]) \% c

#vim authz  //霈曄蔭


# `1 d4 a( q* X$ h; M# H8 k

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
3 v5 G# O6 y7 O# |$ P& g! Kauth-access = write) H6 T! U6 L+ [6 m- B
### The password-db option controls the location of the password$ U0 j* f$ c2 L0 p
### database file.  Unless you specify a path starting with a /,+ r8 g( ]- Y5 b8 V
### the file's location is relative to the directory containing" z1 C4 G# b8 J) ^9 ]- N  i
### this configuration file.
6 S7 H- Z  y  o1 }' D( k### If SASL is enabled (see below), this file will NOT be used.
8 C$ g/ N6 ^# j) c" p### Uncomment the line below to use the default password file.4 D, M0 `& L$ y
password-db = passwd
  J! X: X; J  }! J6 G) `### The authz-db option controls the location of the authorization2 I9 [- e9 q7 D, z! p* v( ^) C9 m
### rules for path-based access control.  Unless you specify a path; G% E6 |9 o- C
### starting with a /, the file's location is relative to the the
, s+ q7 K* z  @+ T: O  |9 n( B### directory containing this file.  If you don't specify an
; j; s. D1 q- U### authz-db, no path-based access control is done.
( N3 z( ~5 V" w; l8 p% `0 q# j### Uncomment the line below to use the default authorization file.
& N# T& e: c% xauthz-db = authz4 X" Z+ p0 |5 C7 i* ^8 M
### This option specifies the authentication realm of the repository.' g1 e" m! q8 S3 u/ T
### If two repositories have the same authentication realm, they should( I1 K( m6 [. ~" \' L% s4 J5 R: m
### have the same password database, and vice versa.  The default realm5 r% W/ J# U% m$ o0 x9 @
### is repository's uuid.! c3 W7 X5 |( ^% ]: X
realm = My First Repository
8 P+ m1 Q7 ~8 @- B+ z

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
5 J8 W; D' [% D* i+ y5 L0 x( L

#killall svnserve    //甇
7 r  t: C2 i6 t8 v

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx2 b- I% X) W& ]% D# t" x

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
+ |2 ]# ?: ]' W7 `  g5 V

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

vim post-commit嚗券Z伐


1 B, A! k) J0 {

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" :
' C/ o, L  L( a  h! k9 {

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


; H/ t8 u4 Z  ]( Z' ?! X: N瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

- L. S, y* O0 P
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
5 }2 D( {7 v3 j7 g

雿輻券

祉蝛閬

BT蝳

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

QQ|撠暺撅||52AV璈A

GMT+8, 2024-11-24 12:17 , Processed in 0.081741 second(s), 19 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵