LNMP2

Nginx安裝

cd /usr/local/srcphp

wget http://nginx.org/download/nginx-1.12.1.tar.gzhtml

tar zxf nginx-1.12.1.tar.gzlinux

cd nginx-1.12.1/nginx

./configure --prefix=/usr/local/nginxgit

make && make installapache

vim /etc/init.d/nginxvim

參考https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D15Z/etc_init.d_nginxcurl

chmod 755 /etc/init.d/nginxurl

chkconfig --add nginxspa

chkconfig nginx on

vim nginx.conf

參考https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D15Z/nginx.conf

/usr/local/nginx/sbin/nginx -t

/etc/init.d/nginx  start

netstat -lntp |grep 80

curl localhost

vim /usr/local/nginx/html/1.php

curl localhost/1.php


默認虛擬主機

vim /usr/local/nginx/conf/nginx.conf

mkdir /usr/local/nginx/conf/vhost

mkdir -p /data/wwwroot/default/

vim /usr/local/nginx/conf/vhost/aaa.conf

mkdir -p /data/wwwroot/default/

echo 「This is a default site.」>/data/wwwroot/default/index.html

/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx -s reload

curl localhost

curl -x127.0.0.1:80 123.com


Nginx用戶認證

vim /usr/local/nginx/conf/vhost/test.com.conf

/usr/local/apache2.4/bin/htpasswd -c /usr/local/nginx/conf/htpasswd aming

/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx -s reload

mkdir /data/wwwroot/test.com

echo 「test.com」>/data/wwwroot/test.com/index.html

curl -uaming:6811327 -x127.0.0.1:80 test.com -I

vim test.conf

/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx -s reload

curl -x127.0.0.1:80 test.com -I

curl -x127.0.0.1:80 test.com/admin/ -I

 

 

 

 

 

 

 

 

 

 

 

 


Nginx域名重定向

vim test.conf

/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx -s reload

curl -x127.0.0.1:80 test2.com/admin -I

curl -x127.0.0.1:80 test3.com/admin -I

curl -x127.0.0.1:80 test4.com/admin -I

相關文章
相關標籤/搜索