Chinaunix首页 | 论坛 | 博客
  • 博客访问: 69690
  • 博文数量: 67
  • 博客积分: 1334
  • 博客等级: 中尉
  • 技术积分: 670
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 10:56
文章分类

全部博文(67)

文章存档

2016年(2)

2015年(2)

2012年(9)

2011年(54)

我的朋友
最近访客
ace

分类: C/C++

2011-10-18 14:51:15

 

2. 把5个辅助包全部解压安装在默认路径
tar xzf ***.tar.gz
cd *****
./configure
make && make install

pcre安装包无需执行make相关,只要解压出来即可

3、安装Mysql
安装参数设置:

./configure --prefix=/usr/local/mysql-5.1 --with-mysqld-user=mysql --with-charset=gbk --with-extra-charsets=all --enable-thread-safe-client --enable-local-infile --with-fast-mutexes --with-low-memory --with-comment --with-embedded-server --without-docs --without-man make && make install 主要参数:
--with-mysqld-user=mysql 指定mysql运行的系统帐号,在安装完mysql以后,需要手工建立相应的帐号,并把mysql安装目录中var目录,继承该用户的所有权限

4、安装PHP
安装参数设置:

./configure --prefix=/usr/local/php-5.3.2 --with-config-file-path=/etc --with-mysql=/usr/local/mysql-5.1 --with-mysqli=/usr/local/mysql-5.1/bin/mysql_config --with-iconv-dir --with-zlib --enable-xml --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --with-fpm --enable-json --with-libevent --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-sockets --enable-zip --without-pear 主要参数说明:
--prefix 该参数基本在所有软件的配置时都是通用的,意思是将该软件包安装在哪个位置,一般根据自己的规范统一使用即可,目前采用/usr/local目录中安装;
--with-mysql 该参数指定当前mysql安装在哪个目录,需要php支持mysql需要该选项
--with-mysqli 该路径指定mysqli的安装位置,即mysql_config位置

安装:

make make test make install

5、安装Nginx

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/root/pcre-8.02 make && make install

Nginx安装过比较简单,主要需要pcre(正则表达式)的支持,所以编译过程中需要指定--with-pcre=/root/pcre-8.02这个目录
主要参数说明:

--user=www --group=www 指定nginx运行时需要用到的系统用户,安装完成后需要手工建立该用户,需要挂载运行的所有网站文件,需要继承该用户权限
--with-http_stub_status_module 可以通过配置,以指定url查看nginx的一些重要运行状态

至此,安装过程全部完成,下面需要对各软件进行设置,并启动。

准备配置文件:

1、PHP
通过编译的PHP默认无需配置,但如果有些特殊的需求,可以在/etc/php.ini中填写,这个文件需要手工创建,下面是在使用的配置文件范例:

date.timezone = Asia/Shanghai #指定时区,防止一些php执行与时间有关的脚本时会出现warning safe_mode = Off #防止某些warning,按需要添加 upload_max_filesize = 8M post_max_size = 10M memory_limit = 20M extension = /usr/local/php-5.3.2/lib/php/extensions/no-debug-non-zts-20090626/mssql.so #支持MS Sql Server 需要另行编译模块支持,另文说明。

2、Mysql
mysql在安装时指定默认配置文件位于/etc/my.cnf,需要手工将该文件复制过来
  1. cp /usr/local/mysql-5.1/share/mysql/my-huge.cnf /etc/my.cnf
    现成的配置文件,无需修改,其中根据内存的大小可以复制不同的配置文件,如my-small.cnf my-medium.cnf my-large.cnf 等

3、Nginx
一般编写Nginx配置文件需要熟悉Nginx的正则表达式,如果不熟悉,可以简单参考附件nginx.conf范例
根据以上安装过程,该配置文件需要放置在/usr/local/nginx/conf/nginx.conf

worker_processes 7; #启用7个系统进程 worker_cpu_affinity 11111110 11111110 11111110 11111110 11111110 11111110 11111110; #相对于8核的CPU,如何分配7个进程 worker_rlimit_nofile 204800; #每个进程允许打开多少个系统文件,如果在高并发的服务器上,这个值太小的话,会出现500错误 events { worker_connections 20480; #对于每个进程,可以允许多少个链接 use epoll; #使用内核epoll功能,是nginx的强势所在,必填 } http { include mime.types; default_type application/octet-stream; gzip on; gzip_proxied any; ssi on; ssi_silent_errors on; ssi_types text/shtml; client_max_body_size 8M; gzip_types text/plain text/css text/xml application/x-javascript application/xml application/atom-xml text/javascript; proxy_next_upstream error; sendfile on; keepalive_timeout 60; upstream phpcgi { server 127.0.0.1:9000; } server { #这一栏主要是禁止泛解析,返回500错误 listen 80 default; return 500; } server { #一个虚拟站点 listen 80; #默认侦听端口 server_name *.qvod.com *.kuaibo.com qvod.com kuaibo.com bbs.qvod.com; #可以接受的主机头 root /where/is/the/web/; #站点的文件根目录 client_max_body_size 8M; access_log off; #关闭日志 location /nstats { #这一项是启用站点的状态监控,可以通过http://域名/nstats 查看web服务器状态 stub_status on; access_log off; } if ($host =bbs.qvod.com){ #一个简单的url重写,对访问bbs.qvod.com的域名,重写为http:///bbs rewrite ^(.*)$ http:///bbs break; } location ~* ^.+.(jpg|jpeg|gif|png|js|css|swf|txt|doc|xls|zip|rar|exe)$ { #对该类扩展名的文件禁用日志 access_log off; } location ~* .(jpg|gif|png|js|css)$ { #对该类文件启用最大过期时间,降低重复请求服务器的次数 if (-f $request_filename) { expires max; break; } } location / { #设置根目录访问方式,只允许静态访问 root /where/is/the/web/; index index.html index.htm; #默认页 #open_file_cache max=306900 inactive=20s; #open_file_cache_min_uses 1; #open_file_cache_valid 30s; } location /styles { #对指定的目录开放脚本解析 if ( $fastcgi_script_name ~ ..*/.*php ) { return 403; } if (-d $request_filename){ rewrite ^/(.*)([^/])$ permanent; } #这两个if是防止nginx某个bug proxy_pass fastcgi_pass 127.0.0.1:9000; #将php扔到9000端口去进行处理 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /bbs { if ( $fastcgi_script_name ~ ..*/.*php ) { return 403; } if (-d $request_filename){ rewrite ^/(.*)([^/])$ permanent; } proxy_pass fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /ucenter { if ( $fastcgi_script_name ~ ..*/.*php ) { return 403; } if (-d $request_filename){ rewrite ^/(.*)([^/])$ permanent; } proxy_pass fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 http://; #指定404错误返回到主页 error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name tmpdl.qvod.com; access_log off; location / { root /home/songhero; index index.html index.htm; } error_page 404 http://; } }


启动各个进程
按服务过程
1、Mysql
/usr/local/mysql-5.1.48/bin/mysqld_safe --user=mysql & #用&符号,以后台进程的方式启动

启动后用netstat -nlpt查看网络端口状态,如启动会出现一条3306的侦听端口

2、PHP
/usr/local/spawn-fcgi-1.6.3/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 8 -f /usr/local/php-5.3.2/bin/php-cgi

启动后用netstat -nlpt查看网络端口状态,如启动会出现一条9000的侦听端口,该端口可以在启动项中指定-p 端口,参数-C 8设定了该服务可以启用8个进程

3、Nginx
在写好配置文件后,通过
/usr/local/nginx/sbin/nginx -t 测试配置文件是否异常,如果没有出现异常,就可以通过
/usr/local/nginx/sbin/nginx 启动服务

启动服务前,需要执行
ulimit -n 102400
设置允许系统同时打开的文件数,该参数需要与nginx配置中的相匹配,否则也会出现500错误

启动后用netstat -nlpt查看网络端口状态,如启动会出现一条80的侦听端口

以下是所有服务正常运行的netstat

Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 7528/php-cgi tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 23029/mysqld tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7267/nginx.conf

如需自动启动,可以将所有启动命令行写在一个shell脚本中,然后编辑/etc/rc.d/rc.local,
添加一行启动项即可完成开机自动启动,下面是两个脚本范例
启动脚本

#! /bin/sh # /root/nginx.rc #NAME=1mysql 2php 3nginx # #/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin ulimit -n 102400 /usr/local/mysql-5.1.48/bin/mysqld_safe --user=mysql & /usr/local/spawn-fcgi-1.6.3/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 8 -f /usr/local/php-5.3.2/bin/php-cgi /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf exit 0

自动启动

#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local /bin/bash /root/nginx.rc #添加此行


 
阅读(993) | 评论(0) | 转发(0) |
0

上一篇:python

下一篇:linux kernel

给主人留下些什么吧!~~