linux nginx php 安装完整步骤
nginx使用fastcgi方式连接php,在linux下面编译安装时要编译php支持fastcgi方式,其他的一些东西,照着原来的方式装就可以了。
分为以下步骤:
1. tar xzvf zlib-x.x.x.tar.gz 2. cd zlib-x.x.x 3. ./configure 4. make make install
A2、安装freetype
# tar xzvf freetype-x.x.x.tar.gz # cd freetype-x.x.x # ./configure --prefix=/usr/local/modules/freetype # make # make install
1. tar xzvf libpng-x.x.x.tar.gz 2. cd libpng-x.x.x 3. cp scripts/makefile.std makefile 4. make test 5. make install
1. tar xzvf jpegsrc.v8b.tar.gz 2. cd jpeg-6b 3. ./configure --prefix=/usr/local/modules/jpeg8 --enable-shared --enable-static 4. make && make install
1. tar xzvf gd-x.x.xx.tar.gz 2. cd gd-x.x.xx 3. ./configure --prefix=/usr/local/modules/gd --with-jpeg=/usr/local/modules/jpeg8 --with-png --with-zlib --with-freetype=/usr/local/modules/freetype 4. make && make install
# tar -zxvf pcre-x.x.tar.gz # cd pcre-x.x # ./configure # make && make install
tar -zxvf libiconv-1.13.1.tar.gzcd libiconv-1.13.1./configure --prefix=/usr/local/libiconvmakemake install
1. tar -zxvf nginx-x.x.xx.tar.gz 2. cd nginx-x.x.xx 3. ./configure --prefix=/usr/local/nginx 4. make && make install
1. rpm -ivh MySQL-server-4.0.14-0.i386.rpm
1. tar -jxvf php-x.x.x.tar.bz2 2. gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1 3 cd php-x.x.x 4. ./configure --prefix=/usr/local/php --with-gd --with-jpeg-dir=/usr/local/modules/jpeg8 --with-zlib --with-png --with-freetype --enable-magic-quotes --enable-fastcgi --with-mysql=/local/server/mysql/ --enable-track-vars --enable-ftp --with-config-file-path=/usr/local/php/etc --with-zip --enable-force-cgi-redirect --with-iconv=/usr/local/libiconv --enable-fpm 5. make && make install 6. cp php.ini-recommended /usr/local/php/etc/php.ini
1. /usr/local/nginx/sbin/nginx
1. kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`
1. kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
1. echo "/usr/local/nginx/sbin/nginx">>/etc/rc.local
1. /data/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/local/php/bin/php-cgi -C 20
1. chmod +x /data/nginx/sbin/spawn-fcgi
#fastcgi-params fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; #end
server { include port.conf; server_name www.sudone.com sudone.com;location / { index index.html index.php; root /data/sudone/php/; } location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/sudone/php$fastcgi_script_name; include fastcgi_params; } }
1、server_name2、location /里面的root3、location ~ .php$里面的fastcgi_param SCRIPT_FILENAME