sudo groupadd nginx
sudo useradd -g nginx -M nginx
- pcre
sudo apt-get install libpcre3 libpcre3-dev
- zlib
sudo apt-get install zlib1g zlib1g-dev
- openssl
sudo apt-get install openssl libssl-dev
sudo apt-get install libgeoip
sudo apt-get install libgd
sudo apt-get install libxml2 libxslt
tar zxvf nginx.tar .gz //下载的对应nginx版本
cd nginx
. /configure -- user= bee -- group = bee -- with -http_ssl_module -- with -http_realip_module -- with -http_addition_module -- with -http_xslt_module -- with -http_image_filter_module -- with -http_geoip_module -- with -http_sub_module -- with -http_dav_module -- with -http_flv_module -- with -http_gzip_static_module -- with -http_random_index_module -- with -http_secure_link_module -- with -http_stub_status_module
sudo make && make install
sudo vim /usr/local/nginx/conf/nginx.conf
server {
listen 8000 ;
server_name yaf.com;
root /home/app/yaf/demo/yafApp;
index index.php index.html;
location / {
try_files $uri $uri / /index.php$is_args $args ;
}
location ~ \.php$ {
try_files $uri =404 ;
include fastcgi.conf;
fastcgi_pass 127.0 .0 .1 :9000 ;
}
}
user nginx nginx;
worker_processes 4 ;
worker_priority 0 ;
error_log logs/error.log;
events {
worker_connections 1024 ;
accept_mutex on;
accept_mutex_delay 500 ms;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65 ;
server {
listen 8000 ;
server_name yaf.com;
root /home/app/yaf/demo/yafApp;
index index.php index.html;
location / {
try_files $uri $uri / /index.php$is_args $args ;
}
location ~ \.php$ {
try_files $uri =404 ;
include fastcgi.conf;
fastcgi_pass 127.0 .0 .1 :9000 ;
}
}
}
sudo /etc/init. d/php-fpm start
sudo /usr/local /nginx/sbin/nginx
sudo vim /etc/hosts
127.0 .0 .1 yaf. com
/usr/local /nginx/sbin/nginx
nginx -s stop 立即停止
nginx -s quit 温和停止守护进程
nginx -s reopen 重新打开日志文件
nginx -s reload 重新载入配置文件
killall nginx
nginx -t 检测配置文件
参考链接: link1 | link2 | link3 | link4