博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos7 nginx安装 及MySQL-python
阅读量:7266 次
发布时间:2019-06-29

本文共 2406 字,大约阅读时间需要 8 分钟。

 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 wgettar 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信息,就可以执行下边的安装了:

makemake install

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

 

开机自启动

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

[Unit]Description=nginx-1.12.2After=network.target remote-fs.target nss-lookup.target[Service]Type=forkingPIDFile=/var/run/nginx.pidExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.confExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=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 firewalldsystemctl mask firewalld
# 安装命令yum install iptables-servicessystemctl 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/

 

你可能感兴趣的文章
(一)WebService基础
查看>>
定义不同模板的网站集
查看>>
Ibatis.Net 各种配置说明学习(二)
查看>>
vue.js 兄弟组件传值
查看>>
MXNet设计和实现简介
查看>>
不同JDK版本之间的intern()方法的区别-JDK6 VS JDK6+
查看>>
判断jQuery元素是否隐藏
查看>>
寄存器的英文全称_xiaofengzhiyu的空间_百度空间
查看>>
C/C++的编译与运行
查看>>
linux关于bashrc与profile的区别(转)
查看>>
关于Git和Github你不知道的十件事
查看>>
第二章学习小结
查看>>
Java基础语法
查看>>
ApplicationContext加载多个配置文件
查看>>
【vb.net机房收费系统】之sqlhelper ...
查看>>
36. Valid Sudoku
查看>>
39. Combination Sum
查看>>
350. Intersection of Two Arrays II
查看>>
Linux内核链表
查看>>
数据结构学习:利用链表建立二叉树
查看>>