如何写论文?写好论文?免费论文网提供各类免费论文写作素材!
当前位置:免费论文网 > 范文百科 > lnmp的分离安装

lnmp的分离安装

来源:免费论文网 | 时间:2016-12-20 07:24:25 | 移动端:lnmp的分离安装

篇一:搭建完全分离式LNMP平台的简单案例

搭建完全分离式LNMP平台的简单案例

案例拓扑图

安装配置nginx服务器

编译安装nginx时,需要事先安装 开发包组"Development Tools"和"Server Platform Development",同时还需专门安装pcre-devel包。

1. # yum -y groupinstall "Development Tools"

2. # yum -y groupinstall "Server Platform Development"

3. # yum -y install pcre-devel

首先添加nginx用户组和nginx用户

1. # groupadd -r nginx

2. # useradd -g nginx -r nginx

创建编译安装是所需要的目录

1. # mkdir -pv /var/tmp/nginx/client

编译安装nginx

1. # tar xf nginx-1.4.7.tar.gz

2. # cd nginx-1.4.7

3. # ./configure \

4.--prefix=/usr/local/nginx \

5.--sbin-path=/usr/local/nginx/sbin/nginx \

6.--conf-path=/etc/nginx/nginx.conf \

7.--error-log-path=/var/log/nginx/error.log \

8.--http-log-path=/var/log/nginx/access.log \

9.--pid-path=/var/run/nginx/nginx.pid \

10.--lock-path=/var/lock/nginx.lock \

11.--user=nginx \

12.--group=nginx \

13.--with-http_ssl_module \

14.--with-http_flv_module \

15.--with-http_stub_status_module \

16.--with-http_gzip_static_module \ 17.--http-client-body-temp-path=/var/tmp/nginx/client/ \

18.--http-proxy-temp-path=/var/tmp/nginx/proxy/ \

19.--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \

20.--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \

21.--http-scgi-temp-path=/var/tmp/nginx/scgi \

22.--with-pcre

23. # make && make install

为nginx提供SysVinit脚本

1. # vim /etc/rc.d/init.d/nginx

1. #!/bin/sh

2. #

3. # nginx - this script starts and stops the nginx daemon

4. #

5. # chkconfig:- 85 15

6. # description: Nginx is an HTTP(S) server, HTTP(S) reverse \

7. #proxy and IMAP/POP3 proxy server

8. # processname: nginx

9. # config:/etc/nginx/nginx.conf

10. # config:/etc/sysconfig/nginx

11. # pidfile: /var/run/nginx.pid

12.

13. # Source function library.

14. . /etc/rc.d/init.d/functions

15.

16. # Source networking configuration.

17. . /etc/sysconfig/network

18.

19. # Check that networking is up.

20. [ "$NETWORKING" = "no" ] && exit 0

21.

22. nginx="/usr/local/nginx/sbin/nginx"

23. prog=$(basename $nginx)

24.

25. NGINX_CONF_FILE="/etc/nginx/nginx.conf"

26. 27. [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

28.

29. lockfile=/var/lock/subsys/nginx

30.

31. make_dirs() {

32. # make required directories

33. user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--

user=\([^ ]*\).*/\1/g' -`

34. options=`$nginx -V 2>&1 | grep 'configure arguments:'`

35. for opt in $options; do

36. if [ `echo $opt | grep '.*-temp-path'` ]; then

37.value=`echo $opt | cut -d "=" -f 2`

38.if [ ! -d "$value" ]; then

39. # echo "creating" $value

40. mkdir -p $value && chown -R $user $value

41.fi

42. fi

43. done

44. }

45.

46. start() {

47. [ -x $nginx ] || exit 5

48. [ -f $NGINX_CONF_FILE ] || exit 6

49. make_dirs

50. echo -n $"Starting $prog: "

51. daemon $nginx -c $NGINX_CONF_FILE

52. retval=$?

53. echo

54. [ $retval -eq 0 ] && touch $lockfile

55. return $retval

56. }

57.

58. stop() {

59. echo -n $"Stopping $prog: "

60. killproc $prog -QUIT

61. retval=$?

62. echo

63. [ $retval -eq 0 ] && rm -f $lockfile

64. return $retval

65. }

66.

67. restart() {

68. configtest || return $?

69. stop

70. sleep 1

71. start

72. }

73.

74. reload() {

75. configtest || return $?

76. echo -n $"Reloading $prog: "

77. killproc $nginx -HUP

78. RETVAL=$?

79. echo

80. }

81.

82. force_reload() {

83. restart

84. }

85.

86. configtest() {

87.$nginx -t -c $NGINX_CONF_FILE

88. }

89.

90. rh_status() {

91. status $prog

92. }

93.

94. rh_status_q() {

95. rh_status >/dev/null 2>&1

96. }

97.

98. case "$1" in

99. start)

100.rh_status_q && exit 0

101.$1

102.;;

103. stop)

104.rh_status_q || exit 0

105.$1

106.;;

107. restart|configtest)

108.$1

109.;;

110. reload)

111.rh_status_q || exit 7

112.$1

113.;;

114. force-reload)

115.force_reload

116.;;

117. status)

118.rh_status

119.;;

120. condrestart|try-restart)

121.rh_status_q || exit 0

122. ;;

123. *) 124.echo $"Usage: $0 {start|stop|status|restart|condrestart|try-

restart|reload|force-reload|configtest}"

125.exit 2

126. esac

为此脚本赋予执行权限

1. # chmod +x /etc/rc.d/init.d/nginx

将nginx服务添加至服务管理列表,并让其开机自动启动

1. # chkconfig --add nginx

2. # chkconfig nginx on

编辑配置文件/etc/nginx/nginx.conf,在server段内添加如下内容

1. location ~ \.php$ {

2. fastcgi_pass10.170.2.90:9000;

3. fastcgi_index index.php;

4. fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name

;

5. include fastcgi_params;

6. }

启动nginx服务

1. # vim /etc/init.d/nginx start

测试nginx是否工作起来,在浏览器中键入10.170.2.80,可以得到如下页面

篇二:LNMP 架构——实现动静分离

LNMP 架构——实现动静分离

=============

fastcgi

=============

LNMP 架构:

2台机器

============

动静分离

============

CentOS:

下载软件包:

1 nginx静态页面 php 动态页面 webnginxCentOS 192.168.7.205 php redhat 192.168.7.253 index.html index.php

# wget http://192.168.7.253:8080/docs/lnmp/nginx--x.tar.gz

[root@tc nginx]# ls

eaccelerator-0.9.6.1.tar.bz2 mhash-0.9.9.9.tar.gz

ImageMagick.tar.gzmysql-5.5.3-m3.tar.gz imagick-2.3.0.tgz nginx-0.8.46.tar.gz

libiconv-1.13.1.tar.gz pcre-8.10.tar.gz

libmcrypt-2.5.8.tar.gz PDO_MYSQL-1.0.2.tgz

mcrypt-2.6.8.tar.gz php-5.2.14-fpm-0.5.14.diff.gz memcache-2.2.5.tgzphp-5.2.14.tar.gz

开始安装:

配置yum:

1、安装 PHP 所需的库文件:

(1)

[root@tc nginx]# ls libiconv-1.13.1.tar.gz

libiconv-1.13.1.tar.gz

2 yum install -y gcc gcc*

[root@tc nginx]# tar zxvf libiconv-1.13.1.tar.gz -C /usr/local/src/

[root@tc nginx]# cd /usr/local/src/libiconv-1.13.1/

[root@tc libiconv-1.13.1]# ./configure --prefix=/usr/local/

[root@tc libiconv-1.13.1]# make && make install

(2)

[root@tc nginx]# ls libmcrypt-2.5.8.tar.gz

libmcrypt-2.5.8.tar.gz

[root@tc nginx]# cd /usr/local/src/libmcrypt-2.5.8/

[root@tc libmcrypt-2.5.8]# ./configure

[root@tc libmcrypt-2.5.8]# make

[root@tc libmcrypt-2.5.8]# make install

[root@tc libmcrypt-2.5.8]# /sbin/ldconfig

//ldconfig是一个动态链接库管理命令,通常在系统启动时运行;而当用户安装了一个新的动态链接库时,就需要手工运行这个命令

3

[root@tc libmcrypt-2.5.8]# cd libltdl

[root@tc libltdl]# ./configure --enable-ltdl-install

[root@tc libltdl]# make

[root@tc libltdl]# make install

(3)

[root@tc nginx]# ls mhash-0.9.9.9.tar.gz

mhash-0.9.9.9.tar.gz

[root@tc nginx]# tar xvzf mhash-0.9.9.9.tar.gz /usr/local/src

[root@tc nginx]# cd /usr/local/src/mhash-0.9.9.9

[root@tc mhash-0.9.9.9]# ./configure

[root@tc mhash-0.9.9.9]# make

[root@tc mhash-0.9.9.9]# make install

(4)

[root@tc nginx]# ls mcrypt-2.6.8.tar.gz

mcrypt-2.6.8.tar.gz

[root@tc nginx]# tar zxvf mcrypt-2.6.8.tar.gz /usr/local/src/

4 -C -C

[root@tc nginx]# cd /usr/local/src/mcrypt-2.6.8/

[root@tc mcrypt-2.6.8]

[root@tc mcrypt-2.6.8]# vim /etc/ld.so.conf

添加

/usr/local/lib

[root@tc mcrypt-2.6.8]# /sbin/ldconfig

[root@tc mcrypt-2.6.8]# ./configure

[root@tc mcrypt-2.6.8]# make && make install

2、安装mysql

# yum install -y ncurses-devel

# useradd -s /sbin/nologin -M mysql

[root@tc nginx]# tar zxvf mysql-5.5.3-m3.tar.gz -C /usr/local/src/

[root@tc nginx]# cd ../mysql-5.5.3-m3/

[root@tc

mysql-5.5.3-m3]# 5 ./configure

篇三:LNMP安装与配置

LNMP安装与配置

时间:2012.8.3

Nginx与apache、lighttp性能综合对比,如下图

:

1.准备php函数的rpm包

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype

freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

2.准备lnmp其他的源代码包

wget

wget

wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gz wget

wget

wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz

wget

wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz wget

wget

wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2 wget

wget

wget

3.安装php-5.2.14源代码包所需要的函数支持包

tar zxvf libiconv-1.13.1.tar.gz

cd libiconv-1.13.1/

./configure --prefix=/usr/local

make

make install

cd ../

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8/

./configure

make

make install

cd libltdl/

./configure --enable-ltdl-install

make

make install

cd ../../

tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9/

./configure

make

make install

cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8

ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a

ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la

ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so

ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

./configure

make

make install

cd ../

4. 编译安装MySQL 5.5.3-m3

groupadd mysql

useradd -g mysql mysql

tar zxvf mysql-5.5.3-m3.tar.gz

cd mysql-5.5.3-m3

./configure --prefix=/usr/local/mysql --without-debug --enable-thread-safe-client --with-pthread --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static

--with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all

--with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=/tmp/mysql.sock

Make

#编译

Make install

#安装

Cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf

#准备mysql配置文件

Vi /etc/my.cnf

[client]

default-character-set=utf8

#修改客户端和连接字符集

[mysqld]

character-set-server=utf8

#修改服务器和数据库字符集

collation-server = utf8_general_ci

#修改服务器校验字符集

Setfacl -m u:mysql:rwx -R /usr/local/mysql

Setfacl -m d:u:mysql:rwx -R /usr/local/mysql

#设置权限

/usr/local/mysql/bin/mysql_install_db --user=mysql

#安装mysql和test数据库

/usr/local/mysql/bin/mysqld_safe --user=mysql &

#启动mysql服务

/usr/local/mysql/bin/mysqladmin -uroot password 123

#修改mysql登录密码为123

/usr/local/mysql/bin/mysql -uroot -p123

#用mysql登录

5. 编译安装PHP(FastCGI模式。使用fastCGI管理php,加快php解析速度) tar zxvf php-5.2.14.tar.gz

gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1

#解压并打补丁,让php支持fpm来方便管理php-cgi进程(使用php-fpm管理fastCGI) # gzip-c 保留源文件-d 解压

cd php-5.2.14/

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc

--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config

--with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib

--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap

make ZEND_EXTRA_LIBS='-liconv'

#编译过程设定变量(编译过程需要)

make install

cp php.ini-dist /usr/local/php/etc/php.ini

cd ../ 登陆mysql后可以\s查看字符集

6.准备编译安装PHP5扩展模块

tar zxvf memcache-2.2.5.tgz

cd memcache-2.2.5/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

cd ../

tar jxvf eaccelerator-0.9.6.1.tar.bz2

cd eaccelerator-0.9.6.1/

/usr/local/php/bin/phpize

./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config make

make install

cd ../

tar zxvf PDO_MYSQL-1.0.2.tgz

cd PDO_MYSQL-1.0.2/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql make

make install

cd ../

tar zxvf ImageMagick.tar.gz

cd ImageMagick-6.5.1-2/

./configure

make

make install

cd ../

tar zxvf imagick-2.3.0.tgz

cd imagick-2.3.0/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

cd ../

7. 修改php.ini文件,让php模块生效

cp /lnmp/php-5.2.14/php.ini-dist /usr/local/php/etc/php.ini

vi /usr/local/php/etc/php.ini

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"

手工添加

extension = "memcache.so"

extension = "pdo_mysql.so"

extension = "imagick.so"

再查找output_buffering = Off

修改为output_buffering = On

再查找; cgi.fix_pathinfo=0

修改为cgi.fix_pathinfo=0,防止Nginx文件类型错误解析漏洞

8. 在php.ini中配置eAccelerator加速

PHP

mkdir -p /usr/local/eaccelerator_cache

#准备eaccelerator缓存目录

vi /usr/local/php/etc/php.ini

[eaccelerator]

zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so" eaccelerator.shm_size="64"

eaccelerator.cache_dir="/usr/local/eaccelerator_cache"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.check_mtime="1"

eaccelerator.debug="0"

eaccelerator.filter=""

eaccelerator.shm_max="0"

eaccelerator.shm_ttl="3600"

eaccelerator.shm_prune_period="3600"

eaccelerator.shm_only="0"

eaccelerator.compress="1"

eaccelerator.compress_level="9"

9.准备php-cgi和nginx进程执行者用户

Useradd nginx

10. 创建php-fpm配置文件- php-fpm.conf

vi /usr/local/php/etc/php-fpm.conf

<value name="display_errors">0</value>

#0改成1,页面上会输出错误日志

Unix user of processes

<value name="user">nginx</value>

Unix group of processes

<value name="group">nginx</value>

<value name="max_children">128</value>

#最大子进程数128,如果内存小于2G,则64个最佳


lnmp的分离安装》由:免费论文网互联网用户整理提供;
链接地址:http://www.csmayi.cn/show/125769.html
转载请保留,谢谢!
相关文章