软件安装之编译安装
1../configure 配置 --prefix=/usr/local/httpd --with 依赖于某个软件 --without --enable --disable 2. make 编译 3.make install 安装 make && make install
想办法让硬件识别你的代码 将c 、c++代码 解析成二进制文件的过程 就叫做 编译 IDE php zend引擎 不识别PHP代码 我们需要 将我们的代码通过 php解析器 解析成 opcode yum -y install gcc gcc-c++ yum -y install expat-devel 好比wamp环境 .netframwork5.0 https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-1.6.3.tar.gz https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz wget -c https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz wget -c https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.29.tar.gz 1.先安装 apr tar -zxvf apr-1.6.3.tar.gz 进入目录 ./configure --prefix=/usr/local/apr make make install 2.安装apr-util tar -zxvf apr-util-1.6.1.tar.gz 进入目录 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install 3.安装 pcrecd wget -c https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz 解压并进入目录 ./configure make && make install 4.安装apache tar -zxvf httpd-2.4.29.tar.gz ./configure --prefix=/usr/local/apache2 --with-apr-util=/usr/local/apr-util make && make install 切换到 安装 目录 /usr/local/apache2/bin ./ 执行的意思 ./apachectl start 启动服务 cd /usr/local/apache2/conf vim httpd.conf 搜索 /ServerName set nu :191 去掉 注释 改为 ServerName 127.0.0.1:80 保存 重启 /usr/local/apache2/bin/apachectl restart 根目录:/usr/local/apache2/htdocs 好比开发过程中的 www
加入开机启动
vim /etc/inittab 启动的启动级别 开机会检查这个 init 0 关机 init 1 单用户模式 好比windows 中的安全模式 init 2 多用户模式 没有网络 init 3 完全多用户模式 包含网络 NFS init 4 用户自定义 init 5 命令行切换图形界面 init 6 重启 chkconfig --list 列出所有的 开机启动项 chkconfig nginx on 加入开机启动 chkconfig nginx off 取消开机启动 chkconfig --add nginx chkconfig --del nginx chkconfig --level 2345 iptables off 所有加入开机启动的服务 必须在 /etc/rc.d/init.d 下面 比如 network 我们可以 service network restart 也可以 /etc/rc.d/init.d/network restart|start|stop 或者 /etc/init.d/network restart lrwxrwxrwx. 1 root root 11 3月 4 02:48 init.d -> rc.d/init.d init.d 是 rc.d/init.d 的软链接
别名
alias 你的名称='ls -al' 等号前后没有空格 命令必须单引号引起来 vim /root/.bashrc alias tt='ls -al' 保存 source /root/.bashrc #source 让配置文件立即生效
iptables 防火墙
0~65535个端口 系统总共端口 ssh 22 mysql 3306 ftp 21 http 80 https 443 1024以下的端口 我们需要有root 权限 0~127 系统预留 vim /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A 增加一条规则 INPUT 入栈 OUTPUT 出栈 forward转发 -I 也是增加一条规则 -p 协议类型 tcp udp icmp 协议等 --dport 端口号 跟 -p 一起使用 -j accept 允许 drop 丢弃 reject 拒绝包 -s 源 ip -d 目标 ip -i 制定哪个网卡 查看开放了哪些端口 /etc/init.d/iptables status iptables -F 清空规则 /etc/init.d/iptables save 保存规则 /etc/init.d/iptables restart iptables -nvL 查看iptables 规则 只允许 ping别人 不允许被ping iptables -I INPUT -p icmp --icmp-type 8 -j DROP 拒绝某一个ip 访问 web服务 iptables -A INPUT -p tcp -s 10.0.113.252 --dport 80 -j DROP iptables -A OUTPUT -p tcp --dport 22 -d 10.0.113.186 -j DROP 拒绝本机ssh 访问 10.0.113.186 iptables -A INPUT -s 10.0.113.186 -j DROP 拒绝来自 10.0.113.186 所有的包 iptables-save > /root/myiptables.txt 备份iptables 规则 iptables-restore < /root/myiptables.txt 恢复规则 -A input -p tcp --dport 80 -m limit --limit 50/minute --limit-burst 1000 -j ACCEPT 当连接数 达到1000 启用连接限制 每分钟只能连接 50个
selinux
cd /etc/selinux vim config 关闭selinux 将enforcing 改为 disabled 禁用 setenforce 0 临时起作用 或者 立即生效 getenforce 获取selinux的状态
计划任务
在制定的时间 干什么事情 计划任务 vim /etc/crontab * * * * * 用户 命令 分 时 日 月 周 root echo '' >> test.php #这里需要加用户 crontab -e 添加一个计划任务 -l 列出所有的计划任务 不展示在配置文件中 写的计划任务 -r 清空计划任务 -u 制定用户的计划任务
每小时的第一分钟 1 * * * * shell脚本
每周天的凌晨两点 0 2 * * 0 shell 脚本
每月4号发工资 * * 4 * * salary.php
每年的10月1日6点半看升旗 30 6 1 10 * /usr/local/php/bin/php shengqi.php
0 0 14 2 6 情人节.php
0 0 3-10 * * 每个月的3-10号反省
0 8-12 * * 1-5 每天的8点-12点
0 8,,12,18 * * * /usr/local/php/bin/php message.php
进程的管理
什么是进程?
cpu 看做一个工厂 进程 就可以看做 工厂车间 线程 可以看做 车间里的工人 过个线程可以共享一个进程
ps
ps -aux 查看全部的进程 -a 显示会话信息 -u 用户的id 也显示出来 -x 进程号 也显示出来 ps -aux | grep crond/80 查看指定的进程 kill -9 进程号 killall -TERM httpd
netstat
查看网络 连接状况 netstat -an #打印网络连接情况 -a 所有的 -n 显示端口号 -t 表示tcp -u 表示udp -l 表示 listen 监听 -p 表示显示进程 netstat -ntlp 打印当前系统启动了哪些服务 mii-tool eth0 检测网卡是否正常
判断nginx服务是否启动
ps -aux | grep nginx
netstat -ntlp | grep 80
抓包工具
yum -y install tcpdump
tcpdump -n -i eth0 制定网卡查看 网络包
screen
yum -y install screen
screen -S 任务名字
Ctrl+A+D 离开任务 回到初始任务
screen -ls 列出所有的后台任务
screen -r 任务号
screen -r 任务号 然后 exit 退出会话
补充 改变文件及目录 所属的用户和组
chown -R 递归 用户名:用户名 目录或者文件