1.安裝依賴:nginx
yum install -y pcre-develc++
yum install gcc-c++centos
yum install zlib zlib-develapi
yum install openssl openssl-devel瀏覽器
[root@xupan001 nginx]# find -name nginx
./sbin/nginxtcp
2.進入nginx_home目錄
[root@xupan001 nginx-1.8.0]# pwd
/usr/local/devtools/nginx/nginx-1.8.0fetch
執行: ./configure
執行: make
執行: make installui
3.安裝到了
[root@xupan001 nginx]# whereis nginx
nginx: /usr/local/nginx線程
./sbin/nginx【默認會加載conf下的nginx.conf】 或者 ./sbin/nginx -c conf/nginx.conf
cd /usr/local/nginx
[root@xupan001 nginx]# ./sbin/nginx
[root@xupan001 nginx]# ps -ef | grep nginx3d
查看80端口是否有監聽:
[root@xupan001 ~]# netstat -tulnp | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2574/nginx
瀏覽器:http://192.168.48.11/
配置:
centos機器信息,nginx官網建議有多少個cpu核就開多少個線程
[root@xupan001 nginx]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 94
model name : Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
stepping : 3
cpu MHz : 2711.746
cache size : 8192 KB
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ida arat epb xsaveopt pln pts dts fsgsbase bmi1 hle avx2 smep bmi2 invpcid rtm
bogomips : 5423.49
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:
# 查看物理CPU個數 cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l # 查看每一個物理CPU中core的個數(即核數) cat /proc/cpuinfo| grep "cpu cores"| uniq # 查看邏輯CPU的個數 cat /proc/cpuinfo| grep "processor"| wc -l
worker_processes 2;#nginx官網建議有多少個cpu核就開多少個線程,配置爲2從新加載配置nginx: worker process爲2 [root@xupan001 nginx]# sbin/nginx -s reload [root@xupan001 nginx]# ps -ef | grep nginx root 3376 1 0 11:19 ? 00:00:00 nginx: master process sbin/nginx nobody 3588 3376 0 11:48 ? 00:00:00 nginx: worker process nobody 3589 3376 0 11:48 ? 00:00:00 nginx: worker process root 3592 3566 0 11:48 pts/0 00:00:00 grep nginx