52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/491236591 x. m% I, n, w) f2 m
. w: Q+ Q8 a8 w3 D+ k* n

格嚗剖遣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 cmake4 {* h4 K" g9 J- N

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx& s' e, P4 D3 y1 U# s' Z, q! _" `

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
' k5 u* A4 o0 m! r/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx  M( ?8 v& U; `$ C$ h( v
# g1 M; |( x1 v8 |( F+ R" W7 f
chkconfig --add nginx
, k' s3 Q$ N& y% t3 z/ H, U
4 r+ |+ S- |+ Hchkconfig nginx on/ }4 {6 J! j8 E, T* E

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

#!/bin/bash$ e" |3 m8 F# p$ s! M
# nginx Startup script for the Nginx HTTP Server
& |) x  Z1 {6 X* E% Z! M# it is v.0.0.2 version.
1 h2 k+ e. _2 Q9 ]# chkconfig: - 85 15# Q0 O; `0 W0 B
# description: Nginx is a high-performance web and proxy server.
- b! ~6 q/ F( X: `- k# It has a lot of features, but it's not for everyone.3 n5 u- P6 U$ p8 G! {
# processname: nginx* Z4 d7 ^1 |- ^% F' j; s5 V
# pidfile: /var/run/nginx.pid3 X1 Q1 S" T* b+ Z: f% L9 T
# config: /usr/local/nginx/conf/nginx.conf; o4 o8 w7 l: ?4 s. n5 n5 l0 \
nginxd=/www/nginx/sbin/nginx8 d. }7 i' W3 |4 ~- W
nginx_config=/www/nginx/conf/nginx.conf& T4 G& g" p  D" p( C9 y
nginx_pid=/www/nginx/logs/nginx.pid$ ^5 P/ Q/ _3 I+ ^# d$ {  j
RETVAL=0
: r: r7 g) f2 z! o6 \0 dprog="nginx"; K3 o; R( N2 Y! `5 a
# Source function library.
4 G+ W' M( ]6 n+ c- T. /etc/rc.d/init.d/functions1 H  u( }4 n; J! t; S3 h0 B
# Source networking configuration.) t7 K1 B! u4 I
. /etc/sysconfig/network" j: l3 R% i' ~  N7 D+ B
# Check that networking is up.1 d* B' e) [0 {8 [/ P7 Z$ A
[ ${NETWORKING} = "no" ] && exit 0% w( w3 Z! s9 \' V* v( }
[ -x $nginxd ] || exit 0  b) T( D7 k: f! V& I) c. R
# Start nginx daemons functions.
4 O: J7 h8 c% f" B4 _& ?start() {
. `: P( T5 U1 a+ r4 N# n9 Y1 Sif [ -e $nginx_pid ];then
8 z7 W1 n% {- K* e; M3 z# M# Wecho "nginx already running...."
/ D5 ~" Q; j9 [exit 1$ s* s' E( g' W4 v, r" p
fi: G2 ?! x& \- M' C5 g
echo -n $"Starting $prog: "
$ ~/ T$ r4 f* \: wdaemon $nginxd -c ${nginx_config}
, V. F2 q  ]: N$ @RETVAL=$?
9 L* Q) S0 {& z' F8 k# kecho/ Y" ?+ b) Z  L5 R5 q2 t: F/ D
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx1 ?2 ~% c  l8 u. r4 }( U3 T0 M
return $RETVAL; J3 p8 T1 {1 o
}4 N3 n7 C7 |& l# w+ q7 z; M  m
# Stop nginx daemons functions.
' o2 t/ X* a: xstop() {& i" f1 u! |5 n: n$ s  A# \1 q; ]
echo -n $"Stopping $prog: "
8 U8 X% }' @) c2 [: ykillproc $nginxd
) M0 U, w/ {4 z3 ^RETVAL=$?0 A" ^! f& d& Z# y. \
echo0 I! h$ U7 i3 K$ |
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
& z! _8 v; o6 J}: N  e) w2 ?4 F/ s" _. g5 L2 ?( X! M) X
reload() {
4 @8 Y% r( q5 ~, x" n# oecho -n $"Reloading $prog: "
: P" q3 k& y& o0 q#kill -HUP `cat ${nginx_pid}`. N; A' S- x7 J+ F! h& E
killproc $nginxd -HUP. \; F& ^9 L: R7 ?# w0 P6 c0 F; K- ^
RETVAL=$?
; ^/ y- o# g" X: J# W" Jecho
$ }! w/ N$ B- P3 m}
1 Q* H, [5 T. E1 a# See how we were called.
( N% D+ Y- r5 t9 pcase "$1" in
0 U5 U8 T0 n% Y3 l8 W2 }! l) Estart)
. _: d; {. R' O7 k/ S- Hstart6 |8 l# ~( c' |5 y
;;  b6 L+ ]" d# a9 V
stop)
: D* R2 B8 K6 u. @3 ?stop& F8 [2 N$ p/ O3 c8 B
;;- q7 u  g* w1 q0 G
reload)
! y  u* L3 t# ~5 U" H& J4 `* s" Zreload( m% q& A# N8 b, }! V
;;3 Z! L% O1 M' ^% I
restart)
* n* g, f8 ~( {stop0 c* x1 a$ B/ T0 j
start2 [4 A+ o1 v* ~% ]5 j& q
;;
% }" g2 h% J$ r  wstatus)
, H1 [9 ]! {2 }) ~; b  C/ Lstatus $prog( C, R8 s$ o" @4 X9 e. E0 Z
RETVAL=$?% u. E/ Z/ H' a( @
;;
$ r, Z& r- r4 ]$ Z7 h, N, h% i*)" l% E* I  C3 j/ ^6 x: x
echo $"Usage: $prog {start|stop|restart|reload|status|help}"& }2 }/ v8 G6 L; c, q( ^
exit 1' Z; u% }6 F. W
esac9 D( W. q3 Q2 @
exit $RETVAL' j8 J6 y$ `% o: T. i. Y
6 h. F5 j8 T4 O  ~1 c- R

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

! W  O& p& T( R) i& @
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗( S+ E. j" b& \' @: m

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

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

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

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


9 c, m- D2 P) X# q7 u       location / {
; {( k1 U$ P: K9 T  v            root   html;; ^+ h; a" a* @, o9 E. P
            index  index.php index.html index.htm;
6 d7 E- Y+ v, }. B  A4 |6 N        }
5 v. c' A# l" X4 u; _靽格嫣蛹嚗' Y4 b5 {# f' d4 V! F- v
1 k% E- [4 P% A0 d8 U( F8 I: |. W% `

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

# Q* d) ^/ ^. u; h- d0 z" [
location ~ \.php$ {
) p" }2 i- l6 U$ ?$ _! L: E5 `            root           html;$ m2 c1 C5 Z9 L0 F2 T) w9 @1 z
            fastcgi_pass   127.0.0.1:9000;
9 q5 ^  d( K* n            fastcgi_index  index.php;6 u* l% w8 I' K* X
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
) u5 ^, {- f; {8 e            include        fastcgi_params;( a& p# a5 _" L3 R6 y1 Z+ j2 ~# B
        }6 e% Q/ m" ^7 G0 o+ n
靽格嫣蛹嚗5 N& b: z8 }$ N. I3 ]  r: |* V

4 n* g) z$ U9 B2 n9 |

        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

閫蝻拙僎餈唳桀嚗扯嚗


! h# ^& |2 k6 C* g6 W

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
( G' `" Y6 |& V
- d& P& |/ K, p4 |#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
8 K  h- \) o4 u/ r6 M

cat /etc/passwd 亦冽瑕銵4 b* M, Y9 C) o6 @2 Y$ L6 |# P
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀9 J+ U& V) ~7 c6 s

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql8 O" q7 s* W* x$ q4 A  y: y

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
& v6 x% T9 e6 z! t. [7 @! D, Y6 jchkconfig mysql on" {9 M5 O) L7 B& |+ V* y9 t0 F* ^
service mysql start  --臬決ySQL
! G9 w8 r: w( W5 n7 n& Q" `  o

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
. l7 d) {2 Q0 ^$ ~; uexport PATH0 O+ A, Y6 F( C' g

靽摮source /etc/profile

扯嚗

  z) c) [! [; G7 @* @, `: J5 f" n
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
2 F. K2 U" @" R  F7 w% V0 b4 i
) V& f4 ]9 l% u! ^6 r( I7 x. g

霈曄蔭root冽瑞撖銝氳oot

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

& u$ Q7 i. F3 i1 z& `/ I

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

2 ^# }9 f( u: ^" m+ ~! p" t

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

3 Y0 P3 Y- K% \9 O5 ~* A/ k

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$ J0 i2 e' W# _; P1 z

7 V+ v% |, m' ]) Yrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm2 ]7 a) ]5 c& @# Q) I: h) u
Create /etc/yum.repos.d/php-fpm.repo file and add:
+ D9 f$ E* S& j! f; h  v
  1. [nginx]2 h+ J5 l: g* J3 w4 J2 Z. K
  2. name=nginx repo
      E  D+ N; H* [, f  G
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    - Q9 Z! l4 y& E  U- R7 V
  4. gpgcheck=0
    " S$ i2 ]; v6 ^; c: z3 b
  5. enabled=1
銴鋆賭誨蝣

0 t7 l5 \7 L) J; z( ]* ryum --enablerepo=remi,remi-test install php-fpm
3 @5 i2 ?# ~# m8 v  d7 I$ a3 n+ I3 o3 K4 }" o+ y

8 N+ u5 B8 p% f; P鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
. _; Z- K  z$ U; t* p

嚗yum remove subversion //貉蝸雿祉svn. G4 k; ?4 u: r! c! o

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
& f: k7 O0 m6 E& 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]) F% ^$ x4 I( t! _
# harry = harryssecret( p; k" N" t. @# H. c" E# a6 Q, H
# sally = sallyssecret) w: P1 v* T2 C$ y5 U- _, W
wangning=wangning
$ C' x) ^" a) I6 D% c) `4 }$ Q2 }& Fyanzi=yanzi: L. c/ N1 G- j3 ]) O3 }  i" O

#vim authz  //霈曄蔭

$ I; k# \$ Q8 h* c- s

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none8 l; S: p# y. Z5 ~
auth-access = write8 j7 v# p% e9 Q. @3 a8 E
### The password-db option controls the location of the password+ e( N( D7 @: u1 e
### database file.  Unless you specify a path starting with a /,
3 a0 l8 d" g! v### the file's location is relative to the directory containing1 Q1 K$ m# P" e" E# j) R2 Q7 I
### this configuration file.
; F4 D- f  w7 I1 a3 Q### If SASL is enabled (see below), this file will NOT be used.9 ?9 h4 r6 g  V$ E0 E
### Uncomment the line below to use the default password file.4 o) b0 S% v% _1 o) X
password-db = passwd' S" c- v+ }  \: Q, s& a" Q
### The authz-db option controls the location of the authorization
9 [8 g; j( I: L### rules for path-based access control.  Unless you specify a path3 w" o7 B5 y4 {
### starting with a /, the file's location is relative to the the, _" Y$ u/ o/ ^0 C
### directory containing this file.  If you don't specify an! t2 o/ u. h5 H% t1 `. Q: b6 S* g
### authz-db, no path-based access control is done.! q' X0 N9 \$ |! k  O
### Uncomment the line below to use the default authorization file.
( t$ |8 d! B' F- Qauthz-db = authz
- T, p  ^7 k7 x$ ], t### This option specifies the authentication realm of the repository., ?* V" l% g6 t9 a2 {2 c2 R/ b0 y
### If two repositories have the same authentication realm, they should; c6 D* S: g4 r& j( {: A
### have the same password database, and vice versa.  The default realm
# e( X2 S; y1 g6 D3 m/ Q### is repository's uuid.
8 i7 W2 e" g- f" l$ mrealm = My First Repository' J. @( `5 B7 @. e1 W, w

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn4 q$ ]7 J) a& }$ v# x

#killall svnserve    //甇4 `. q/ t; G# L" ?0 d/ Q

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
8 X2 @! l4 `7 o% P

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$ w7 D7 c7 w  f

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

vim post-commit嚗券Z伐

* O* K. l4 q, x2 H) y2 t: {

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" :7 }- v1 Z+ ?, O: M4 D

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

( o/ q& U3 @( n6 N
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


" m! t' q) F" X6 S% u+ ~1 Wvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿' d( l8 g$ S- Q8 x4 Z( W# ~* q

雿輻券

祉蝛閬

BT蝳

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

QQ|撠暺撅||52AV璈A

GMT+8, 2024-11-22 11:34 , Processed in 0.086635 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵