Installing Pcre
TAR-XVF pcre-8.32.tar.gzcd pcre-8.32./configuremake;make Install Nginx first create an Nginx user to run Nginxuseradd with Nginx user NGINXTAR-XVF nginx-1.2.7.tar.gzcd nginx-1.2.7./configure--user=nginx--group=nginx--prefix=/usr/local/nginx/-- With-http_stub_status_module--with-http_ssl_modulemake;make Install start Nginx prompt: Error while loading shared libraries: Libpcre.so.1:cannot open Shared object file:no such file or directory Workaround: 32-bit system [[email protected] lib]# ln-s/usr/lo Cal/lib/libpcre.so.1/lib64 bit system [[email protected] lib]# ln-s/usr/local/lib/libpcre.so.1/lib64 start prompt: Nginx: [Emerg] Get Pwnam ("Nginx--group=nginx") failed Workaround: Change the user in the Nginx configuration file to the one specified at compile time 1. Configure a host-name-based virtual host vi/etc/hosts192.168.183.138www.test.com192.168.183.138www.a.orgecho "www.test.com" >/web/test/index.htmlecho "www.a.org" >/web/test/index.html modify nginx configuration file, add two segment host configurationserver { Listen 80; server_name www.test.com; LOC ation/{ root /web/test/; index index.html index.htm; }} server { &N Bsp Listen 80; server_name www.a.org; location/{ & nbsp root /web/a/; Index index.html index.htm; }}root to specify Web root profile detection [[email protected] ~]#/usr/local/ Nginx/sbin/nginx-tnginx:the configuration file/usr/local/nginx//conf/nginx.conf syntax is oknginx:configuration file /usr/local/nginx//conf/nginx.conf test is successful start nginx/usr/local/nginx/sbin/nginx-s reopen if error: Nginx: [ ERROR] Open () "/usr/local/nginx/logs/nginx.pid "Failed Workaround: Execute /usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf 2. Port-based virtual host configuration Modify Nginx Profile server { Listen 9090; location/{ &nbs P root /web/test/; &N Bsp Index index.html index.htm; }} server { Listen 8080;&nbs P location/{ root /web/a/; index index.html index.htm; }} configuration piece detection [[email protected] ~]#/usr/local/nginx/sbin/nginx-tnginx:the configuration file/usr/local/nginx//conf/ nginx.conf syntax is oknginx:configuration file/usr/local/nginx//conf/nginx.conf test is successful restart nginx/usr/local/ Nginx/sbin/nginx-s reload 3. Configure the IP address-based virtual host ifconfig eth0:0 192.168.183.139/24 here my native IP address is 192.168.183.138 Modify profile server { Listen 192.168.183.138:80; server_name www.test.com; location/{ & nbsp Root /web/test/; INDEX IND ex.html index.htm; }} server { Listen 192.168.183.139:80;  ; server_name www.a.org; location/{ &NBSP ; Root /web/a/; index index.html in dex.htm; }} profile detection [[email protected] ~]#/usr/local/nginx/sbin/nginx-tnginx:the Configuration file/usr/local/nginx//conf/nginx.conf syntax is oknginx:configuration file/usr/local/nginx//conf/ Nginx. conf test is successful start Nginx/usr/local/nginx/sbin/nginx
Nginx-based virtual host configuration