linux下本地包安裝nginx
由于在做go-fastdfs集群的時候用到了nginx進行代理,然后直接用yum安裝的nginx,在這里掛個本地寶安裝方法當鏈接。
1.安裝依賴包
//一鍵安裝上面四個依賴yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2.下載解壓軟件包
//創(chuàng)建一個文件夾cd /usr/local mkdir nginx cd nginx//下載tar包wget http://nginx.org/download/nginx-1.13.7.tar.gztar -xvf nginx-1.13.7.tar.gz
3.安裝nginx
//進入nginx目錄cd /usr/local/nginx//進入目錄cd nginx-1.13.7//執(zhí)行命令 考慮到后續(xù)安裝ssl證書 添加兩個模塊./configure //執(zhí)行make命令make//執(zhí)行make install命令make install
4.啟動nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
5.配置nginx
vi /usr/local/nginx/conf/nginx.conf
#user ?nobody; worker_processes ?1; #error_log ?logs/error.log; #error_log ?logs/error.log ?notice; #error_log ?logs/error.log ?info; #pid ? ? ? ?logs/nginx.pid; events { ? ?worker_connections ?1024; } http { ? ?include ? ? ? mime.types; ? ?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; ? ?sendfile ? ? ? ?on; ? ?#tcp_nopush ? ? on; ? ?#keepalive_timeout ?0; ? ?keepalive_timeout ?65; ? ?#gzip ?on; ? ?server { ? ? ? ?listen ? ? ? 80; ? ? ? ?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$ { ? ? ? ?# ? ?root ? ? ? ? ? html; ? ? ? ?# ? ?fastcgi_pass ? 127.0.0.1:9000; ? ? ? ?# ? ?fastcgi_index ?index.php; ? ? ? ?# ? ?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; ? ?# ? ?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; ? ?# ? ?location / { ? ?# ? ? ? ?root ? html; ? ?# ? ? ? ?index ?index.html index.htm; ? ?# ? ?} ? ?#} }
?
6.重啟nginx
/usr/local/nginx/sbin/nginx -s reload
7.關閉防火墻
setenforce 0systemctl stop firewalld
8.訪問nginx

?
安裝完成一般常用命令
進入安裝目錄中,
命令: cd /usr/local/nginx/sbin
啟動,關閉,重啟,命令:
./nginx 啟動
./nginx -s stop 關閉
./nginx -s reload 重啟
?鏈接:https://www.dianjilingqu.com/537686.html