Lnmp 项目搭建(带测试产品)-老男孩
1)源码安装 nginx (在 192.168.4.5 上)
[root@localhost 桌面]# yum -y install gcc gcc-c++
[root@localhost 桌面]# yum -y install openssl-devel openssl zlib zlib-devel pcre pcre-devel
[root@localhost 桌面]# ls
libiconv-1.14.tar.gz mhash-0.9.9.9.tar.gz nginx-1.6.2.tar.gz
libmcrypt-2.5.8.tar.gz mysql-5.1.72.tar.gz php-5.3.27.tar.gz
[root@localhost 桌面]# mkdir /nginx
[root@localhost 桌面]# mv nginx-1.6.2.tar.gz /nginx/
[root@localhost 桌面]# cd /nginx/
[root@localhost nginx]# ls
nginx-1.6.2.tar.gz
[root@localhost nginx]# tar -zxf nginx-1.6.2.tar.gz
[root@localhost nginx]# ls
nginx-1.6.2 nginx-1.6.2.tar.gz
[root@localhost nginx]# cd nginx-1.6.2
[root@localhost nginx-1.6.2]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
[root@localhost nginx-1.6.2]# useradd -s /sbin/nologin -M nginx
[root@localhost nginx-1.6.2]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx
--with-http_stub_status_module --with-http_ssl_module
[root@localhost nginx-1.6.2]# make && make install
[root@localhost nginx-1.6.2]# ls /usr/local/nginx/
conf html logs sbin
[root@localhost nginx-1.6.2]# cd /root/桌面
[root@localhost 桌面]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost 桌面]# /usr/local/nginx/sbin/nginx
[root@localhost 桌面]# /usr/local/nginx/sbin/nginx -s stop
[root@localhost 桌面]# /usr/local/nginx/sbin/nginx
[root@localhost 桌面]# /usr/local/nginx/sbin/nginx -s reload
[root@localhost 桌面]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 5804 root 6u IPv4 28931 0t0 TCP *:http (LISTEN)
nginx 5807 nginx 6u IPv4 28931 0t0 TCP *:http (LISTEN)
[root@localhost 桌面]# vim /usr/local/nginx/conf/nginx.conf
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etiantian.org;
location / {
root www;
index index.html index.htm;
}
}
server {
listen 80;
server_name bbs.etiantian.org;
location / {
root bbs;
index index.html index.htm;
}
}
}
wq
[root@localhost conf]# cd /root/桌面
[root@localhost 桌面]# mkdir /usr/local/nginx/www
[root@localhost 桌面]# mkdir /usr/local/nginx/bbs
[root@localhost 桌面]# echo "www" > /usr/local/nginx/www/index.html
[root@localhost 桌面]# echo "bbs" > /usr/local/nginx/bbs/index.htm
[root@localhost 桌面]# /usr/local/nginx/sbin/nginx -s reload
在 192.168.4.205(客户端) //通过不同域名访问不同网页(虚拟主机)
[root@localhost 桌面]# vim /etc/hosts
192.168.4.5 www.etiantian.org bbs.etiantian.org