gcc是linux下的編譯器在此不多做解釋,感興趣的小伙伴可以去查一下相關資料,它可以編譯 C,C++,Ada,Object C和Java等語言
命令:查看gcc版本
gcc -v
一般阿里云的centOS7里面是都有的,沒有安裝的話會提示命令找不到,
安裝命令:
yum -y install gcc
pcre是一個perl庫,包括perl兼容的正則表達式庫,nginx的http模塊使用pcre來解析正則表達式,所以需要安裝pcre庫。
安裝命令:
yum install -y pcre pcre-devel
zlib庫提供了很多種壓縮和解壓縮方式nginx使用zlib對http包的內容進行gzip,所以需要安裝
安裝命令:
yum install -y zlib zlib-devel
openssl是web安全通信的基石,沒有openssl,可以說我們的信息都是在裸奔。。。。。。
安裝命令:
yum install -y openssl openssl-devel
wget http://nginx.org/download/nginx-1.9.9.tar.gz
tar -zxvf nginx-1.9.9.tar.gz
執(zhí)行三個命令:
- ./configure
- make
- make install
可以按照自己服務器的端口使用情況來進行配置
ESC鍵,wq!強制保存并退出
切換目錄到/usr/local/nginx/sbin下面
啟動nginx命令:
./nginx
ps -ef | grep nginx
顯示
說明安裝和配置都沒問題OK了
- #user nobody;
- worker_processes 1; #工作進程:數(shù)目。根據(jù)硬件調整,通常等于cpu數(shù)量或者2倍cpu數(shù)量。
- #錯誤日志存放路徑
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- #pid logs/nginx.pid; # nginx進程pid存放路徑
- events {
- worker_connections 1024; # 工作進程的最大連接數(shù)量
- }
- http {
- include mime.types; #指定mime類型,由mime.type來定義
- default_type application/octet-stream;
- # 日志格式設置
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
- #access_log logs/access.log main; #用log_format指令設置日志格式后,需要用access_log來指定日志文件存放路徑
- sendfile on; #指定nginx是否調用sendfile函數(shù)來輸出文件,對于普通應用,必須設置on。
- 如果用來進行下載等應用磁盤io重負載應用,可設著off,以平衡磁盤與網(wǎng)絡io處理速度,降低系統(tǒng)uptime。
- #tcp_nopush on; #此選項允許或禁止使用socket的TCP_CORK的選項,此選項僅在sendfile的時候使用
- #keepalive_timeout 0; #keepalive超時時間
- keepalive_timeout 65;
- #gzip on; #開啟gzip壓縮服務
- #虛擬主機
- server {
- listen 80; #配置監(jiān)聽端口號
- server_name localhost; #配置訪問域名,域名可以有多個,用空格隔開
- #charset koi8-r; #字符集設置
- #access_log logs/host.access.log main;
- location / {
- root html;
- index index.html index.htm;
- }
- #錯誤跳轉頁
- #error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ { #請求的url過濾,正則匹配,~為區(qū)分大小寫,~*為不區(qū)分大小寫。
- # root html; #根目錄
- # fastcgi_pass 127.0.0.1:9000; #請求轉向定義的服務器列表
- # fastcgi_index index.php; # 如果請求的Fastcgi_index URI是以 / 結束的, 該指令設置的文件會被附加到URI的后面并保存在變量$fastcig_script_name中
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- # HTTPS server
- #
- #server {
- # listen 443 ssl; #監(jiān)聽端口
- # server_name localhost; #域名
- # ssl_certificate cert.pem; #證書位置
- # ssl_certificate_key cert.key; #私鑰位置
- # ssl_session_cache shared:SSL:1m;
- # ssl_session_timeout 5m;
- # ssl_ciphers HIGH:!aNULL:!MD5; #密碼加密方式
- # ssl_prefer_server_ciphers on; # ssl_prefer_server_ciphers on; #
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- }