一、安装nginx:
1. 安装pcre库,nginx的rewrite模板需用到pcre库:
- mkdir -p /works
- cd /works
- wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.20.tar.gz
- tar -zxvf pcre-8.20.tar.gz
- ./configure
- make && make install
- cd ..
2. 安装nginx:
- wget http://nginx.org/download/nginx-1.0.10.tar.gz
- tar -zxvf nginx-1.0.10.tar.gz
- cd nginx-1.0.10
- ./configure
- make && make install
- cd ..
3. 新建用户和组:
- groupadd www
- useradd -r -g www www
二、安装PHP5
1. 安装依赖包:
- libcurl:
- wget http://curl.haxx.se/download/curl-7.23.1.tar.gz
- tar -zxvf curl-7.23.1.tar.gz
- cd curl-7.23.1/
- ./configure
- make && make install
- cd ..
libxml2:
- wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz
- tar -zxvf libxml2-2.7.6.tar.gz
- cd libxml2-2.7.6
- ./configure
- make && make install
- cd ..
libxslt:
- wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
- tar -zxvf libxslt-1.1.24.tar.gz
- cd libxslt-1.1.24
- ./configure make && make install
- cd ..
freetype:
- wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.gz
- tar -zxvf freetype-2.4.6.tar.gz
- cd freetype-2.4.6 ./configure
- make && make install
- cd ..
libpng:
- wget "http://prdownloads.sourceforge.net/libpng/libpng-1.5.6.tar.gz?download"
- tar -zxvf libpng-1.5.6.tar.gz
- cd libpng-1.5.6 ./configure
- make && make install
- cd ..
libjpeg:
- wget http://ijg.org/files/jpegsrc.v8c.tar.gz
- tar -zxvf jpegsrc.v8c.tar.gz
- cd jpeg-8c/
- ./configure
- make && make install
- cd ..
2. 安装php5和php-fpm:
- wget http://museum.php.net/php5/php-5.2.16.tar.gz
- wget http://php-fpm.org/downloads/php-5.2.16-fpm-0.5.14.diff.gz
- tar -zxvf php-5.2.16.tar.gz
- gunzip php-5.2.16-fpm-0.5.14.diff.gz
- cd php-5.2.16/
- patch -p1 < ../php-5.2.16-fpm-0.5.14.diff
- ./configure \
- --with-curl \
- --enable-calendar \
- --with-xsl \
- --with-libxml-dir \
- --enable-ftp \
- --with-gd \
- --with-freetype-dir \
- --with-jpeg-dir \
- --with-png-dir \
- --enable-mbstring \
- --with-zlib \
- --enable-shared \
- --with-mysql \
- --enable-fastcgi \
- --enable-fpm
- ./configure && make && make install
修改php-fpm的配置文件/usr/local/etc/php-fpm.conf,设置执行php-fpm的用户和组名:
大约在第62行:
- Unix user of processes
- <!--<value name="user">nobody</value>-->
- Unix group of processes
- <!--<value name="group">nobody</value>-->
修改为:
- Unix user of processes
- <value name="user">www</value>
- Unix group of processes
- <value name="group">www</value>
启动php-fpm:
- /usr/local/sbin/php-fpm start
- lsof -i:9000
- netstat -ant|grep 9000
- #9000为php-fpm的默认端口,可以在/usr/local/etc/php-fpm.conf中修改。
修改nginx配置文件/usr/local/nginx/conf/nginx.conf,我的nginx配置文件如下:
- worker_processes 10;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- sendfile on;
- keepalive_timeout 65;
- gzip on;
- server {
- listen 80;
- server_name ead;
- root /data/faceshow/www;
- location / {
- root html;
- index index.php index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- #此段代码为关键
- location ~ \.php$ {
- fastcgi_pass 127.0.0.1:9000; #对应php-fmp的端口
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /data/faceshow/www/$fastcgi_script_name;
- #php文件的物理路径
- include fastcgi_params;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
- {
- expires 30d;
- }
- location ~ .*\.(js|css)?$
- {
- expires 1h;
- }
- }
- }
启动nginx:
- /usr/local/nginx/bin/nginx
- /usr/local/nginx/bin/nginx -s reload
三、常见问题:
问题: nginx ./configure时报如下错误
- ./configure: error: the HTTP rewrite module requires the PCRE library.
- You can either disable the module by using --without-http_rewrite_module
- option, or install the PCRE library into the system, or build the PCRE library
- statically from the source with nginx by using --with-pcre=<path> option.
解决:这是由于未PCRE库,请安装PCRE库在运行./configure。也可以使用带--without-http_rewrite_module参数进行./configure,但是这将导致nginx不支持rewrite功能!
四、相关文件下载地址:
libcurl: http://curl.haxx.se/download.html
libxml2: ftp://xmlsoft.org/libxml2/
libxslt: ftp://xmlsoft.org/libxml2/
libpng: http://www.libpng.org/pub/png/libpng.html
libjpeg: http://ijg.org/files/
freetype:http://download.savannah.gnu.org/releases/freetype/
pcre:http://www.pcre.org/
nginx:http://nginx.org/en/download.html
php-fpm:http://php-fpm.org/
php5:http://www.php.net/releases/
MySQL:http://www.mysql.com/downloads/mirror.php?id=404683#mirrors
一、安装MYSQL
下载页面:http://www.mysql.com/downloads/mirror.php?id=404683#mirrors
1. 添加用户帐号和安装依赖包
- groupadd mysql
- useradd -r -g mysql mysql
- yum install gcc gcc-c++ libtool autoconf automake imake libxml2-devel expat-devel ncurses-devel cmake bison
2. 下载、解压源码包
- mkdir -p /data/temp
- cd /data/temp
- wget ftp://ftp.fi.muni.cz/pub/mysql/Downloads/MySQL-5.5/mysql-5.5.18.tar.gz
- tar -zxvf mysql-5.5.18.tar.gz
- cd mysql-5.5.18
3. cmake进行编译
- cmake . \
- -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
- -DDEFAULT_CHARSET=utf8 \
- -DEXTRA_CHARSETS=all \
- -DDEFAULT_COLLATION=utf8_general_ci \
- -DMYSQL_USER=mysql
- make
- make install
- cd /usr/local/mysql
- chown -R mysql .
- chgrp -R mysql .
- scripts/mysql_install_db --user=mysql
- chown -R root .
- chown -R mysql data
- cp support-files/my-medium.cnf /etc/my.cnf
- bin/mysqld_safe --user=mysql &
- cp support-files/mysql.server /etc/init.d/mysqld
- cd /usr/local/bin
- ln -fs /usr/local/mysql/bin/mysql mysql
4. 把mysql 添加为系统启动服务
- cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
- cd /etc/rc.d/init.d
- chkconfig --add mysqld
- service mysqld start/stop
二、安装Apache
下载页面:http://www.apache.org/dist/httpd/
1. 安装apache:
- wget http://www.apache.org/dist/httpd/httpd-2.2.21.tar.gz
- tar -zxvf httpd-2.2.21.tar.gz
- cd httpd-2.2.21
- ./configure --enable-modules=so --enable-rewrite
- make && make install
2. 安装扩展:
- cd srclib/apr
- make
- make install
- cd ../apr-util/
- ./configure --with-apr=../apr
- make
- make install
二、安装PHP5
1. 安装依赖包:
libcurl:
- wget http://curl.haxx.se/download/curl-7.23.1.tar.gz
- tar -zxvf curl-7.23.1.tar.gz
- cd curl-7.23.1/
- ./configure
- make && make install
- cd ..
libxml2:
- wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz
- tar -zxvf libxml2-2.7.6.tar.gz
- cd libxml2-2.7.6
- ./configure
- make && make install
- cd ..
libxslt:
- wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
- tar -zxvf libxslt-1.1.24.tar.gz
- cd libxslt-1.1.24
- ./configure
- make && make install
- cd ..
freetype:
- http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.gz
- tar -zxvf freetype-2.4.6.tar.gz
- cd freetype-2.4.6
- ./configure
- make && make install
- cd ..
libpng:
- wget "http://prdownloads.sourceforge.net/libpng/libpng-1.5.6.tar.gz?download"
- tar -zxvf libpng-1.5.6.tar.gz
- cd libpng-1.5.6
- ./configure
- make && make install
- cd ..
libjpeg:
- wget http://ijg.org/files/jpegsrc.v8c.tar.gz
- tar -zxvf jpegsrc.v8c.tar.gz
- cd jpeg-8c/
- ./configure
- make && make install
- cd ..
2. 安装PHP:
- wget http://cn2.php.net/get/php-5.2.17.tar.bz2/from/hk.php.net/mirror
- cat php-5.2.17.tar.bz2 |bunzip2 | tar xvf -
- cd php-5.2.17
- ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
- --with-curl \
- --enable-calendar \
- --with-xsl \
- --with-libxml-dir \
- --enable-ftp \
- --with-gd \
- --with-freetype-dir \
- --with-jpeg-dir \
- --with-png-dir \
- --enable-mbstring \
- --with-zlib \
- --enable-shared \
- --with-mysql
- make && make install
- cd ..
3. 让apache加载php模块:
- vim /usr/local/apache2/conf/httpd.conf
- #确保下面三行在httpd.conf配置文件中存在
- LoadModule php5_module modules/libphp5.so
- AddType application/x-httpd-php .php
- AddType application/x-httpd-php-source .phps
4. 启动HTTP服务及测试
- /usr/local/apache2/bin/httpd -k restart
- echo "<?php phpinfo(); ?>" > /usr/local/apache2/htdocs/index.php
- #使用浏览器打开URL:http://ip/index.php
常见错误:
1. 现象:make install时报"dlname not found in /usr/local/apache2/modules/libphp5.la."
解答:这是由于apache与php的libtool版本不一致引起的。
- /usr/local/apache2/build/libtool --version
- ltmain.sh (GNU libtool) 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)
- ./libtool --version
- ltmain.sh (GNU libtool) 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)
解决方法:使php安装目录下的libtool与apache的libtool版本一致,再重新安装,操作如下:
- cd /data/temp/
- cp /usr/local/apache2/build/libtool .
- make clean
- make install
相关文件下载地址:依赖包下载地址:
libcurl: http://curl.haxx.se/download.html
libxml2: ftp://xmlsoft.org/libxml2/
libxslt: ftp://xmlsoft.org/libxml2/
libpng: http://www.libpng.org/pub/png/libpng.html
libjpeg: http://ijg.org/files/
freetype:http://download.savannah.gnu.org/releases/freetype/
apache:http://www.apache.org/dist/httpd/
PHP:http://www.php.net/downloads.php
MySQL:http://www.mysql.com/downloads/mirror.php?id=404683#mirrors
下面是本站收集的国家公务员考试历届试题及答案,以供网友下载:
2008国家公务员考试行政能力测试真题及答案.doc
2009_中央、国家公务员考试试题及答案详解.doc
2010国家公务员考试试题及答案解析.doc
2011国家公务员考试试题及答案.doc
<a href='http://www.tunedairchaussures.com'> TN NIKE PAS CHE
<a href="http://www.tnstocker.com" target="_blank">TN NIKE P
<a href='http://www.maniketn.com'> TN NIKE PAS CHER </a> <a
greats piosts
I dont know what to say. This blog is fantastic
This is a good article, with its own style and characteristi
so what in that we think we're so proud of you.you have a go
© Copy 2010 Aiezu.Com. All rights reserved. Powered by Aiezu.com.