zoukankan      html  css  js  c++  java
  • centos7 nginx安装 及MySQL-python

     1.pip install MySQL-python 出错问题

    pip install -r requirement.txt

    发现安装MySQL-python 出错,更新setuptools也没用

    解决办法:https://blog.csdn.net/default7/article/details/54927153

    先 yum install mysql-devel

    再 pip install MySQL-python

     还有问题可能是没装gcc

    yum install gcc-c++

    由于之前安装MySQL-python的时候中断了,所以所有包并没有全部安装完成,

    要继续 pip install -r requirement.txt

    2.Nginx 安装

    首先再根目录下建立了一个application目录,然后cd application,进入后进行下载安装操作

    安装依赖

    prce(重定向支持)和openssl(https支持,如果不需要https可以不安装。)
    yum -y install pcre*
    yum -y install openssl*

    下载

    wget http://nginx.org/download/nginx-1.12.2.tar.gz 
    
    # 如果没有安装wget
    # 下载已编译版本
    $ yum install wget
    
    tar xf nginx-1.12.2.tar.gz  #解压

    编译安装

    cd nginx-1.12.2
    ./configure

    安装报错误的话比如:“C compiler cc is not found”,这个就是缺少编译环境,安装一下就可以了 yum -y install gcc make gcc-c++ openssl-devel wget

    如果没有error信息,就可以执行下边的安装了:

    make
    make install

    上述全部执行完成,即安装完成

    开机自启动

    编辑 vi /lib/systemd/system/nginx.service 文件,没有创建一个 touch nginx.service 然后将如下内容根据具体情况进行修改后,添加到nginx.service文件中:

    [Unit]
    Description=nginx-1.12.2
    After=network.target remote-fs.target nss-lookup.target
    
    [Service]
    
    Type=forking
    PIDFile=/var/run/nginx.pid
    ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
    ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target

    设置开机启动,使配置生效:

    systemctl enable nginx.service

    服务管理

    # 启动
    /usr/local/nginx/sbin/nginx
    
    # 重启
    /usr/local/nginx/sbin/nginx -s reload
    
    # 关闭进程
    /usr/local/nginx/sbin/nginx -s stop
    
    # 平滑关闭nginx
    /usr/local/nginx/sbin/nginx -s quit
    
    # 查看nginx的安装状态,
    /usr/local/nginx/sbin/nginx -V 

    关闭防火墙,或者添加防火墙规则就可以测试了

    service iptables stop

    或者编辑配置文件:

    vi /etc/sysconfig/iptables

    添加这样一条开放80端口的规则后保存:

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

    重启服务即可:

    service iptables restart

    重启服务防火墙报错解决

    service iptables restart
    # Redirecting to /bin/systemctl restart  iptables.service
    # Failed to restart iptables.service: Unit iptables.service failed to load: No such file or directory.

    在CentOS 7或RHEL 7或Fedora中防火墙由 firewalld 来管理,当然你可以还原传统的管理方式。或则使用新的命令进行管理。
    假如采用传统请执行以下命令:

    # 传统命令
    systemctl stop firewalld
    systemctl mask firewalld
    # 安装命令
    yum install iptables-services
    
    systemctl enable iptables 
    service iptables restart

    nginx卸载

    如果通过yum安装,使用下面命令安装。

    yum remove nginx

    编译安装,删除/usr/local/nginx目录即可
    如果配置了自启动脚本,也需要删除。

    其他参数、配置

    https://segmentfault.com/a/1190000008866185

    http://seanlook.com/2015/05/17/nginx-install-and-config/

  • 相关阅读:
    Best Time to Buy and Sell Stock
    Remove Nth Node From End of List
    Unique Paths
    Swap Nodes in Pairs
    Convert Sorted Array to Binary Search Tree
    Populating Next Right Pointers in Each Node
    Maximum Subarray
    Climbing Stairs
    Unique Binary Search Trees
    Remove Duplicates from Sorted Array
  • 原文地址:https://www.cnblogs.com/huchong/p/8994208.html
Copyright © 2011-2022 走看看