php5.2 memcache,nginx+php5.2.17+memcache+xcache+sign+xcache

openssl-0.9.8j.tar.gz

memcache-2.2.3.tgz

sign.tgz

xcache-1.2.2.tar.gz

php-5.2.17-fpm-0.5.14.diff.gz

php-5.2.17.tar.bz2

[nginx安装包及依赖包]

pcre-7.7.tar.gz

nginx-1.2.0.tar.gz

一、安装openssl

tar -zxvf openssl-0.9.8j.tar.gz

cd openssl-0.9.8j

ls需要的安装包

./config --prefix=/usr/local/openssl-0.9.8j

make && make install

安装完成之后需要测试一下

/usr/local/openssl-0.9.8j/bin/openssl

二、安装php+fastcgi

tar jxvf php-5.2.17.tar.bz2

gzip -cdphp-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1

cd php-5.2.17

创建一个php扩展模块目录,已便配置编译安装的时候讲这些模块加载到PHP中去

mkdir -p ext

cd ..

tar -zxvf memcache-2.2.3.tgz

tar -zxvf xcache-1.2.2.tar.gz

tar -zxvf sign.tgz

接下来这步很重要(将解压好的这些模块目录移动到上面在PHP创建的扩展目录ext中去)

mv memcache-2.2.3 php-5.2.17/ext/memcache

mv xcache-1.2.2 php-5.2.17/ext/xcache

mv sign php-5.2.17/ext/sign

2.接下来正式安装php

cd php-5.2.17

rm -rf configure #这步删除原来的配置命令configure(删除的原因的是由于版本的问题,在配置的时候有可能出现问题,我这里是删除,然后用buidconfig从新生成一个configure)

LQDBY-DB64:/data/software/php-5.2.17# ./buildconf --force

出现下面的情况是没有安装autoconf2.13的问题

Forcing buildconf

buildconf: checking installation...

buildconf: autoconf not found.

You need autoconf version 2.13 or newer installed

to build PHP from CVS.

make: *** [buildmk.stamp] Error 1

安装 autoconf2.13之后在执行

./buildconf --force 就没问题了

LQDBY-DB64:/data/software/php-5.2.17# ./configure  --prefix=/usr/local/php-5.2.17 \

> --with-config-file-path=/usr/local/php-5.2.17/etc \

> --with-zlib-dir --enable-sockets --enable-ftp --with-zlib --with-libxml-dir \

> --enable-xml --disable-debug \

> --enable-discard-path --enable-safe-mode \

> --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization \

> --with-curlwrappers --enable-mbregex --enable-fastcgi \

> --enable-fpm --enable-force-cgi-redirect --enable-mbstring \

> --enable-gd-native-ttf --enable-xcache --enable-memcache \

> --enable-sign --with-openssl=/usr/local/openssl-0.9.8j \

> --with-openssl-dir=/usr/local/openssl-0.9.8j

如果出现这面的对话框说明配置成功

+--------------------------------------------------------------------+

| License:                                                           |

| This software is subject to the PHP License, available in this     |

| distribution in the file LICENSE.  By continuing this installation |

| process, you are bound by the terms of this license agreement.     |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point.                            |

+--------------------------------------------------------------------+

Thank you for using PHP.

开始编译安装 make -j 8 && make install

修改php-fpm.conf配置文件,并开启fastcgi进程

vim /usr/local/php-5.2.17/etc/php-fpm.conf

讲前面的注释去掉,并修改开启fastcgi进程的用户(也可以不修改)修改完的结果如下

1 <?xml version="1.0" ?>

2

3

4         All relative paths in this config are relative to php's install prefix

5

6        

7

8                 Pid file

9                 /usr/local/php-5.2.17/logs/php-fpm.pid

10

11                 Error log file

12                 /usr/local/php-5.2.17/logs/php-fpm.log

13

14                 Log level

15                 notice

16

17                 When this amount of php processes exited with SIGSEGV or SIGBUS ...

18                 10

19

20                 ... in a less than this interval of time, a graceful restart will be initiated.

21                 Useful to work around accidental curruptions in accelerator's shared memory.

22                 1m

23

24                 Time limit on waiting child's reaction on signals from master

"/usr/local/php-5.2.17/etc/php-fpm.conf" 156L, 5188C                                           1,1           Top

1 <?xml version="1.0" ?>

2

3

4         All relative paths in this config are relative to php's install prefix

5

6        

7

8                 Pid file

9                 /usr/local/php-5.2.17/logs/php-fpm.pid

10

11                 Error log file

12                 /usr/local/php-5.2.17/logs/php-fpm.log

13

14                 Log level

15                 notice

18                 10

19

20                 ... in a less than this interval of time, a graceful restart will be initiated.

21                 Useful to work around accidental curruptions in accelerator's shared memory.

22                 1m

23

24                 Time limit on waiting child's reaction on signals from master

25                 5s

26

29

30        

31

32        

33

34                

35

36                         Name of pool. Used in logs and stats.

37                         default

38

39                         Address to accept fastcgi requests on.

40                         Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'

41                         127.0.0.1:9000

42

43                        

44

45                                 Set listen(2) backlog

46                                 -1

47

48                                 Set permissions for unix socket, if one used.

50                                 Many BSD-derrived systems allow connections regardless of permissions.

51                                

52                                

53                                 0666

54                        

55

56                         Additional php.ini defines, specific to this pool of workers.

57                        

58                

60                        

61

62                         Unix user of processes

63                        web

64

65                         Unix group of processes

66                        web

71                                 Sets style of controling worker process count.

72                                 Valid values are 'static' and 'apache-like'

73                                 static

76                                 Equivalent to Apache MaxClients directive.

77                                 Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi

78                                 Used with any pm_style.

79                                 5

80

81                                 Settings group for 'apache-like' pm style

82                                

83

84                                         Sets the number of server processes created on startup.

85                                         Used only when 'apache-like' pm_style is selected

86                                         20

87

88                                         Sets the desired minimum number of idle server processes.

89                                         Used only when 'apache-like' pm_style is selected

90                                         5

91

92                                         Sets the desired maximum number of idle server processes.

93                                         Used only when 'apache-like' pm_style is selected

94                                         35

95

96                                

97

98                        

99

102                         '0s' means 'off'

103                         0s

104

106                         '0s' means 'off'

107                         0s

108

109                         The log file for slow requests

110                         logs/slow.log

111

112                         Set open file desc rlimit

113                         1024

114

115                         Set max core size rlimit

116                         0

117

118                         Chroot to this directory at the start, absolute path

119                        

120

121                         Chdir to this directory at the start, absolute path

122                        

123

124                         Redirect workers' stdout and stderr into main error log.

125                         If not set, they will be redirected to /dev/null, according to FastCGI specs

126                         yes

127

128                         How much requests each process should execute before respawn.

129                         Useful to work around memory leaks in 3rd party libraries.

130                         For endless request processing please specify 0

131                         Equivalent to PHP_FCGI_MAX_REQUESTS

132                         500

133

134                         Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.

135                         Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)

136                         Makes sense only with AF_INET listening socket.

137                         127.0.0.1

138

139                         Pass environment variables like LD_LIBRARY_PATH

140                         All $VARIABLEs are taken from current environment

141                        

142                                 $HOSTNAME

143                                 /usr/local/bin:/usr/bin:/bin

144                                 /tmp

145                                 /tmp

146                                 /tmp

147                                 $OSTYPE

148                                 $MACHTYPE

149                                 2

150                        

151

152                

153

154        

155

156

开启fastcgi进程

/usr/local/php-5.2.17/sbin/php-fpm start

LQDBY-DB64:/data/software/php-5.2.17/ext/mysql# ps -ef |grep php-cgi

root     25745     1  0 16:34 ?        00:00:00 /usr/local/php-5.2.17/bin/php-cgi --fpm --fpm-config /usr/local/php-5.2.17/etc/php-fpm.conf

web      25746 25745  0 16:34 ?        00:00:00 /usr/local/php-5.2.17/bin/php-cgi --fpm --fpm-config /usr/local/php-5.2.17/etc/php-fpm.conf

web      25747 25745  0 16:34 ?        00:00:00 /usr/local/php-5.2.17/bin/php-cgi --fpm --fpm-config /usr/local/php-5.2.17/etc/php-fpm.conf

web      25748 25745  0 16:34 ?        00:00:00 /usr/local/php-5.2.17/bin/php-cgi --fpm --fpm-config /usr/local/php-5.2.17/etc/php-fpm.conf

web      25749 25745  0 16:34 ?        00:00:00 /usr/local/php-5.2.17/bin/php-cgi --fpm --fpm-config /usr/local/php-5.2.17/etc/php-fpm.conf

web      25750 25745  0 16:34 ?        00:00:00 /usr/local/php-5.2.17/bin/php-cgi --fpm --fpm-config /usr/local/php-5.2.17/etc/php-fpm.conf

root     26822 23954  0 17:03 pts/0    00:00:00 grep php-cgi

LQDBY-DB64:/data/software/php-5.2.17# netstat -an |grep 9000

tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN

到这里php+fastcgi基本上安装完成了

三、开始安装nginx

1.由于Nginx安装需要pcre的支持所以先安装pcre

tar -zxvf pcre-7.7.tar.gz

cd pcre-7.7

./configure

make && make install

2.安装nginx程序包

tar -zxvf nginx-1.2.0.tar.gz

cd nginx-1.2.0

./configure --user=web --group=web

--prefix=/usr/local/nginx-1.2.0

-with-http_stub_status_module

make -j 8 && make isntall

3.开启nginx测试

/usr/local/nginx-1.2.0/sbin/nginx

如果出现下面的错误

/usr/local/nginx-1.2.0/sbin/nginx: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory

解决办法:cp /usr/local/lib/libpcre.so.0 /usr/lib/libpcre.so.0

LQDBY-DB64:/data/software/nginx-1.2.0# /usr/local/nginx-1.2.0/sbin/nginx

LQDBY-DB64:/data/software/nginx-1.2.0# ps -ef |grep nginx

root      6746     1  0 11:23 ?        00:00:00 nginx: master process /usr/local/nginx-1.2.0/sbin/nginx

web       6747  6746  0 11:23 ?        00:00:00 nginx: worker process

root      6749 23954  0 11:23 pts/0    00:00:00 grep nginx

4.修改nginx配置文件并开启cgi功能

1

2 #user  nobody;

3 worker_processes  1;

4

5 #error_log  logs/error.log;

6 #error_log  logs/error.log  notice;

7 #error_log  logs/error.log  info;

8

9 #pid        logs/nginx.pid;

10

11

12 events {

13     worker_connections  1024;

14 }

15

16

17 http {

18     include       mime.types;

19     default_type  application/octet-stream;

20

21     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

22     #                  '$status $body_bytes_sent "$http_referer" '

23     #                  '"$http_user_agent" "$http_x_forwarded_for"';

24

25     #access_log  logs/access.log  main;

26

27     sendfile        on;

28     #tcp_nopush     on;

29

30     #keepalive_timeout  0;

31     keepalive_timeout  65;

32

33     #gzip  on;

34

35     server {

36         listen       80;

37         server_name  localhost;

38

39         #charset koi8-r;

40

41         #access_log  logs/host.access.log  main;

42

43         location / {

44            root   html;

45            index  index.html index.htm index.php;

46         }

47

48         #error_page  404              /404.html;

49

50         # redirect server error pages to the static page /50x.html

51         #

52         error_page   500 502 503 504  /50x.html;

53         location = /50x.html {

54             root   html;

55         }

56

57         # proxy the PHP scripts to Apache listening on 127.0.0.1:80

58         #

59         #location ~ \.php$ {

60         #    proxy_pass   http://127.0.0.1;

61         #}

62

63         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

64         #

65       location ~ \.php$ {

66             root           html;

67             fastcgi_pass   127.0.0.1:9000;

68             fastcgi_index  index.php;

69             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

70             include        fastcgi.conf;

71         }

72

73         # deny access to .htaccess files, if Apache's document root

74         # concurs with nginx's one

75         #

76         #location ~ /\.ht {

77         #    deny  all;

78         #}

79     }

80

81

82     # another virtual host using mix of IP-, name-, and port-based configuration

83     #

84     #server {

85     #    listen       8000;

86     #    listen       somename:8080;

87     #    server_name  somename  alias  another.alias;

88

89     #    location / {

90     #        root   html;

91     #        index  index.html index.htm;

92     #    }

93     #}

94

95

96     # HTTPS server

97     #

98     #server {

99     #    listen       443;

100     #    server_name  localhost;

101

102     #    ssl                  on;

103     #    ssl_certificate      cert.pem;

104     #    ssl_certificate_key  cert.key;

105

106     #    ssl_session_timeout  5m;

107

108     #    ssl_protocols  SSLv2 SSLv3 TLSv1;

109     #    ssl_ciphers  HIGH:!aNULL:!MD5;

110     #    ssl_prefer_server_ciphers   on;

111

112     #    location / {

113     #        root   html;

114     #        index  index.html index.htm;

115     #    }

116     #}

117

118 }

5.重启nginx

/usr/local/nginx-1.2.0/sbin/nginx

6.进行测试

在/usr/local/nginx-1.2.0/html/创建一个index.php网页已便测试

cat /usr/local/nginx-1.2.0/html/index.php

phpinfo();

?>

910438dacff758fb1039ea047dd07112.png

074259168cab748e4e8908e29646ed9d.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值