編譯安裝nginx

安裝nginx,出錯最多就是須要安裝pcre擴展來支持url的重寫。php

首先下載並解壓pcrehtml

cd /home/yan
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
tar xf pcre-8.35.tar.gz

下載並安裝nginx,在根目錄建立/Nginx,把nginx安裝到指定的目錄便於管理,同時指定pcre擴展的源碼位置。nginx

mkdir /Nginx
cd /home/yan
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar xf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure --prefix=/Nginx --with-pcre=/home/yan/pcre-8.35
make
make install

若是沒有出錯信息,說明安裝成功,若是有錯誤提示,可自行解決。php-fpm

啓動及管理nginxurl

/Nginx/sbin/nginx    
/Nginx/sbin/nginx -s reload 
/Nginx/sbin/nginx -s stop
/Nginx/sbin/nginx -s reopen

若是你的nginx是以php-fpm方式運行,修改/Nginx/conf/nginx.conf ,其餘配置可根據須要調整。spa

location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
相關文章
相關標籤/搜索