52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659& h4 t; F% g( l$ f9 }- R2 m! x, ?

/ L4 G* [1 ?- C6 ^' q1 S6 ^

格嚗剖遣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! V. }, H. l$ ~$ N5 D1 M  u

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx5 d8 t% n7 u1 E3 K  h" \9 x

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www" @. j1 ^6 [9 S: o" d# J
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx: U( W5 f$ L& R( F3 r& d

, ~) U1 H; X4 Nchkconfig --add nginx
; ]; o$ b5 r! _* ]+ G+ U
+ E8 _6 C9 |5 O0 ~. N6 wchkconfig nginx on
) Z3 w$ g; T6 J/ @

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

#!/bin/bash: B: B4 B4 c+ ?& t* \' V
# nginx Startup script for the Nginx HTTP Server
9 V& e4 @! B0 j5 h# it is v.0.0.2 version.
9 y7 o6 B0 `0 t# chkconfig: - 85 15
/ n/ o) e- A7 V0 W& [# description: Nginx is a high-performance web and proxy server.
" L8 Y+ M9 ]) V3 c% P# It has a lot of features, but it's not for everyone.2 f% X3 B. E; d
# processname: nginx9 q2 F* \8 `; ^) d8 ]
# pidfile: /var/run/nginx.pid
7 j' ?/ n: _) t4 A& q/ Z# config: /usr/local/nginx/conf/nginx.conf
' z  L7 U5 C: u9 P; `7 Cnginxd=/www/nginx/sbin/nginx
! ^% d$ p# l+ u" Anginx_config=/www/nginx/conf/nginx.conf
8 U- q0 \6 i* J( Snginx_pid=/www/nginx/logs/nginx.pid: b) L5 s5 V& D
RETVAL=0
$ v3 b0 D) X0 L0 k; {  v- U& X) wprog="nginx"0 {6 t# k$ q+ L/ T/ S
# Source function library.
9 b6 J* ]. l; r( d8 t' G, N. /etc/rc.d/init.d/functions
# {: r+ ~  B) |: ?" N( N- C3 A/ f# Source networking configuration.
% M% l# ?( W# t- Z* |. /etc/sysconfig/network
" ]6 F4 |8 Z, ]  C: M! L# Check that networking is up.% v# O+ \$ g% E+ [# h- s
[ ${NETWORKING} = "no" ] && exit 0
' E4 i/ o& b5 \0 J; C[ -x $nginxd ] || exit 0! G; E/ B4 p; \% W% B& {
# Start nginx daemons functions.
- L* s) q' T) Y& d9 G: G- O& A8 |start() {7 Z- v( ]1 y: [$ `. }6 s" p' n
if [ -e $nginx_pid ];then+ f& Z/ f! ~9 @5 h) F$ q
echo "nginx already running...."
. S8 j3 I$ e2 |' Q" r, uexit 16 N& W" `$ I5 C: v
fi$ P9 s$ l" P7 m0 t0 l* H) g% a+ u3 R
echo -n $"Starting $prog: "
5 T& Y+ A% E; H% p9 p! H! sdaemon $nginxd -c ${nginx_config}$ \; W. R$ f, K, O" h7 F
RETVAL=$?
1 ~2 m) {1 Z; A& J. h+ Z; A/ M8 Techo
7 g, c1 Q  g5 Q; k[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
8 m2 R8 {1 X6 Sreturn $RETVAL  |/ @( `' t: g8 ?8 n' V
}
% d7 {' L+ z( X) m# Stop nginx daemons functions.
! U  I( g9 l+ T( E( v  \" \stop() {: ~8 O- A3 I3 A9 ^; A
echo -n $"Stopping $prog: "; A. P: o) p4 `* M$ B" L3 x
killproc $nginxd
; b4 D5 z$ U$ dRETVAL=$?
0 i% g4 V5 G9 I9 u  u2 R" }echo, t6 i# W/ }1 v! A1 B
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
7 @+ F& k, e8 e9 z* `5 R, p# T}0 ?' T4 H+ `6 u* Z
reload() {, T9 n0 m" H, G6 v4 f
echo -n $"Reloading $prog: "8 y. [" m* f) _. p3 S0 N2 u  `
#kill -HUP `cat ${nginx_pid}`$ ]5 S! {: q6 `, A  X/ g
killproc $nginxd -HUP$ k/ s& z1 g% K& I! B: R5 W
RETVAL=$?
% v2 W* N/ H, h1 a5 r' I& techo9 N! j0 h( B2 ?; |
}) ]5 s- a8 v( E0 u/ ]4 h
# See how we were called.0 C/ q( p! l& @; K4 j1 o
case "$1" in  l! U9 L  b6 s& D* J
start)
# E% E0 j  J* \$ Xstart
4 w& c0 B5 g* Z; f1 h;;# `0 X1 b+ S0 q2 Z  w
stop)
8 `' R4 {1 W5 [& Z( z5 N3 Z& t- istop
+ b& h; {+ j. i6 \- G+ O;;" `& {1 D9 R  E- x
reload)
  h/ i3 b- {/ V) I) Lreload: g* K( N# }7 X4 A# z5 z
;;
+ u/ H" i3 x# b. A8 ?restart)* N' l& u, M8 t0 L
stop
1 Y$ U/ R- k. b) R- J( [start
' h, [# C7 E5 a% ]  Z;;
; n& P/ m% ?- M& k; b0 ^# {# ^status)8 a, Y: f6 s! c
status $prog7 b& E  d; \( ?# M9 I4 K( D$ a9 T
RETVAL=$?  R" O" w" c- m. e) L8 }
;;
1 r7 P' `+ ]6 ]0 s/ o* o*)
0 x% R& b$ m% K! d* secho $"Usage: $prog {start|stop|restart|reload|status|help}"0 X5 n, J5 q' a8 B+ E  s
exit 1* ?$ _0 R% ^; j* ~
esac" H5 e# y0 P8 u/ r. x5 h. x
exit $RETVAL3 }8 ?* c. Z0 s! `* Z/ ]7 v
9 k; T( l" M0 u8 }4 D

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


+ j2 c1 M: i( Zchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗- O, L. D4 S9 p5 p4 v

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

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

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

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


, K, K. R( ?4 C" A% W+ T       location / {
8 G" |- V7 y" {4 |$ X3 B            root   html;9 K6 ~9 l8 Q, ?3 z- [, A9 g
            index  index.php index.html index.htm;1 Y  d' d& e; _$ c
        }2 z1 p8 |2 X$ R9 V
靽格嫣蛹嚗% M0 d+ I. l$ ?

8 _* ^; c+ L, d* |4 C5 ?/ P

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

/ P2 g3 W" w' n/ O, b( {& X
location ~ \.php$ {
( j: B( J/ V# r0 L            root           html;
4 I, y& p% G, n0 ?( v1 K            fastcgi_pass   127.0.0.1:9000;
7 Q& U' ?' O7 ^+ W6 w8 e. L! n; U            fastcgi_index  index.php;/ X( x0 t( d9 u, v0 |
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;" U' X' S1 N7 g$ B5 m
            include        fastcgi_params;
5 w9 o8 p6 i- ^: Y2 _8 O        }: _* g* m+ u+ S! }
靽格嫣蛹嚗
6 H7 P, O( z' T2 Q
- h0 @3 N+ y  B+ k7 n- T7 v

        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

閫蝻拙僎餈唳桀嚗扯嚗

6 B9 f# _2 S( I* Z- _( h( A

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
' z5 g* D' J* f4 u5 E  b. O! c
1 Q2 L3 w( z9 `& A#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏5 z! {% C; `. l

cat /etc/passwd 亦冽瑕銵) o9 n- n7 N* S2 w/ p
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
/ n0 X& q' [' [1 J* _! L

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql* n: i, \* u& s  H

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql& \6 {5 A# q1 ~1 O( E9 m* q
chkconfig mysql on0 _, X% E& H# b4 V3 c9 n* y
service mysql start  --臬決ySQL
3 e! D* s( w0 K2 L0 f* }

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH# b! N* W* k0 y8 R+ U
export PATH
  j4 s& `" L' U8 ?  A0 T* j# o& _

靽摮source /etc/profile

扯嚗

4 j0 \3 e& _" L; u( F; f
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');: W& D$ P8 \4 }8 Z
" e/ E, w& ?6 E6 f4 \) y" l

霈曄蔭root冽瑞撖銝氳oot

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

' k( t* L4 \: u, m' b

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

5 K1 u# w- e/ H3 n0 J! D! c

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


  R" x& S# n2 ?. Z) Y; v1 k" g

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% _, f6 Y, H3 `: `+ C3 W/ M' f

8 w9 @3 O' [* z5 P2 W0 B' b1 orpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm$ E- E, ]. t3 u; Y) y- E: P
Create /etc/yum.repos.d/php-fpm.repo file and add:% v8 Z7 r  C( x* j; \; q# i
  1. [nginx]
    0 G3 K& n5 B1 z# j* O5 x0 p
  2. name=nginx repo
      d+ u: v: f) A- y
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/+ Y3 K2 Q- W$ [4 {* Y: }, }  \
  4. gpgcheck=0% c: [4 b8 V4 H& w: h% f" D7 S
  5. enabled=1
銴鋆賭誨蝣
% I9 F& X5 [1 S) z3 ^- D3 r
yum --enablerepo=remi,remi-test install php-fpm, D* ?3 |$ m+ \0 J8 d

3 Q' l" K/ M7 C0 l& y/ K4 I

% i9 p7 O7 q. G9 h鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn  B4 A: w9 ~, {  B* \1 P, b

嚗yum remove subversion //貉蝸雿祉svn  v$ I7 y% q# c) g  @# [

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
5 r2 d0 n: W. a7 `2 A4 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]5 t& T& G0 P: @
# harry = harryssecret
4 O% X, X% f: K  |6 ~# sally = sallyssecret
' R' ~, Y% X9 O4 d+ w2 O& W) Ywangning=wangning
6 }  v' ?1 D/ ]) q6 _+ ~4 r6 i$ fyanzi=yanzi
7 `: T2 M$ Y( t( h

#vim authz  //霈曄蔭

0 d2 i  `7 B4 C% i

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
+ X" n  P* m" C6 Sauth-access = write
* r9 y, R' E. F% |! |### The password-db option controls the location of the password
) G( k( D/ \! b: i7 H### database file.  Unless you specify a path starting with a /,- g: h& O- [) T
### the file's location is relative to the directory containing
, ~( Y+ S8 N5 i### this configuration file.
( B' `5 v3 q& w4 U* O### If SASL is enabled (see below), this file will NOT be used.
$ M& k, r  Y* [! M### Uncomment the line below to use the default password file.
7 Z+ e. q4 {; k$ Y( p' W: Rpassword-db = passwd
" o& y8 V6 R4 _### The authz-db option controls the location of the authorization! q( S7 K3 W) t, l) V: T  Z
### rules for path-based access control.  Unless you specify a path" ?# w2 w* ?2 z! N/ Y  F
### starting with a /, the file's location is relative to the the6 Z8 F# D! D( h3 j( |; j; f; e
### directory containing this file.  If you don't specify an' g3 [0 F) V3 j2 r3 b
### authz-db, no path-based access control is done." f! H- D, B2 c0 {2 l
### Uncomment the line below to use the default authorization file.2 V; w1 R- _) Z& B$ ]: W
authz-db = authz
! H0 _! h) k+ m8 j! @### This option specifies the authentication realm of the repository.
, D' X6 l4 P" c) B9 Q8 m### If two repositories have the same authentication realm, they should
0 @+ w, b/ S0 N, H5 u+ F0 X$ K( Q### have the same password database, and vice versa.  The default realm5 B$ Y/ b2 C1 {
### is repository's uuid.  K! {6 ?- E8 Q2 b% q) A/ _$ P
realm = My First Repository
3 s5 ?, \9 _  h3 f/ e( X

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn/ u4 x% [; f5 G6 _

#killall svnserve    //甇$ h1 |7 \/ t; j' |2 u4 }

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx3 B, E4 p+ s: N, @* ]

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" p! g+ h/ B7 {' N- R) X1 k

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

vim post-commit嚗券Z伐


7 f! \" i& x, E1 e3 E: F1 c

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" :# B3 k9 h* C* A8 C

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


  t" e6 J3 d( t5 E8 o瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

3 Y% |7 [! l8 @7 o
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿) k! p, v7 b7 Q  {3 Y7 s2 B

雿輻券

祉蝛閬

BT蝳

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-2-16 20:15 , Processed in 0.077522 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵