LNMP配置——安装Nginx
一、下载
#cd /usr/local/src/
#wget http://nginx.org/download/nginx-1.16.1.tar.gz
二、解压
# tar zxf nginx-1.16.1.tar.gz
三、配置安装
#cd nginx-1.16.1/
#./configure --prefix=/usr/local/nginx
#make && make install
#vi /etc/init.d/nginx
把下列代码写入
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start()
{
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart()
{
stop
start
}
configtest()
{
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac
exit $RETVAL
#chmod 755 /etc//init.d/nginx
#chkconfig --add nginx
#chkconfig nginx on
#> /usr/local/nginx/conf/nginx.conf
#vim /usr/local/nginx/conf/nginx.conf
把下列代码写入
user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 6000;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 3526;
server_names_hash_max_size 4096;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
' $host "$request_uri" $status'
' "$http_referer" "$http_user_agent"';
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 8 4k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm
application/xml;
server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
}
#/usr/local/nginx/sbin/nginx -t
#vim /usr/local/nginx/conf/nginx.conf
#/usr/local/nginx/sbin/nginx -t
#service nginx start
#ps aux |grep nginx
四、测试是否能正确解析
#vi /usr/local/nginx/html/2.php
写入
<?php
echo "test php scripts";
?>
#curl localhost/2.php
test php scripts //证明解析成功
最新文章
- TODO List - 任务表
- 倾力总结40条常见的移动端Web页面问题解决方案
- A ship is always safe at the shore - but that is not what it is built for.
- CSS代码记录
- [转]学习 WCF (6)--学习调用WCF服务的各种方法
- Canvas开发笔记(不断更新)
- What is machine learning?
- Python 学习 第十篇 CMDB用户权限管理
- toString结果
- HTML5 canvas中的转换方法
- 当开始输入文字以及完成文字输入时,变换text field的背景以及系统自带一键删除的 叉叉
- 【2017-06-27】Js中获取地址栏参数、Js中字符串截取
- truffle 安装以及基本指令
- ehcache与redis的比较与应用场景分析(转)
- Maven(十五)Maven 聚合
- 微信小程序之封装http请求
- memory拷贝与string拷贝的区别
- web前端工程师在移动互联网时代里的地位问题 为啥C/S系统在PC端没有流行起来,却在移动互联网下流行了起来 为啥移动端的浏览器在很多应用里都是靠边站,人们更加倾向于先麻烦自己一下,下载安装个客户端APP
- 成都Uber优步司机奖励政策(4月21日)
- PHP简单的图片上传
热门文章
- Python3.5 配置MySql数据库连接
- Navicat 快捷键 for Mysql
- Python 分析热卖年货,今年春节大家都在送啥?
- MySQL 连接管理
- LVS+Keepalived深度理解,阐述你不知道的坑点
- ARM汇编指令-STMFD/LDMFD
- Android 神奇的SpannableStringBuilder
- 产品经理进阶:如何用UML的顺序图表达思想?
- php 配置主机虚拟目录(使用虚拟域名访问 127.0.0.1) 一点也不好使?????
- DNS &; TXT recode &; Google Search Console