nginx 入门安装和使用

安装nginx

#1 pcre 兼容正则表达式包
yum install pcre pcre-devel -y

#2 安装openssl 支持https的时候
yum install openssl openssl-devel -y

#3 安装nginx
wget nginx.tar.gz网址
tar nginx.tar.gz
cd ngin..xxxx

#4 seradd nginx -s /sbin/nologin -M
#5.
./configure --user=nginx --group=nginx --prefix=/applocation/nginx1.6.2 --with-http_stub_status_module --with-http_ssll_module

echo $? 返回0正常 其他都是错误,没有错误

#6. make
#7. make install 

#8. 做一个软链接 去版本号
ln -s /application/nginx1.6.2/ /application/nginx
# 补充  编译安装
wget xxx
tar zxf xxx
cd xxx
./configure
make && make install
cd  ../
# 错误解决
 libpcre.so.1 cannot openshared object file:No such file or directory
 解决办法
 # find / -name libpcre.so*  先把这个文件路径找到
 # vim /etc/ld.so.conf    编辑这个文件,把这个路径加进去
 # echo '路径 \' >>/etc/ld.so.conf   或者echo 加这个路径也可以
 
 # ldconfig 生效 
 
 # 做一个软链接也可以

nginx主配置文件

# nginx.conf 主模块
# events{}模块
# http{}模块,一直到最下边

# http里
#   server{}模块

#server里
#  locate / {} 模块
#user nobody;  默认用户
worker_processes 1; 指定进程,一般和cpu的核数是相当的,master一个主进程,其他事woeker

#error_log  logs/error.log;
#error_log  logs/error.log notice;
#error_log  logs/error.log info;     #错误日志级别

#pid logs/nginx.pid;  nginx的进程号

events {
    worker_connections 1024; # 可以看成work的连接数,最大连接数量
}#events


http {
    
    #log_format main  "略 访问日志的格式"
    #access_log loggs/access.log main ; # 访问日志
    
    
    server{
      	listen 80; #监听端口号
       	server_name localhost; #域名
        location / {
            
        }#locatoion
        error_page 500 502 503 /50x.html;
        location = /50.html {
            root html; # 如果是/50.html 这个页面,到哪个页面去找
        }
    }#server

}#http

猜你喜欢

转载自blog.csdn.net/sunt2018/article/details/85301357