Linux服务器的使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_25639809/article/details/79484710

http://www.bt.cn/

查看主机命令
hostname
查看主机ip
hostname -i

修改主机名

//查看
hostnamectl status
hostname

//修改文件:
vi /etc/sysconfig/network 
//添加: HOSTNAME=hostname

//修改文件:
vi /etc/hosts
//在127.0.0.1 最后添加主机名

//重启
reboot

安装Apache

yum install httpd
//启动
service httpd start
systemctl start httpd
//修改配置文件
vi /etc/httpd/conf/httpd.conf
//访问localhost:80或使用curl测试安装是否成功
curl localhost

让httpd显示目录及文件名:
在根目录文件夹里新建文件名为.htaccess的文件,内容为Options All +Indexes
目录或文件名中文乱码:
修改配置文件,在最后一行添加 IndexOptions Charset=UTF-8

安装Nginx

yum install nginx
//启动
service nginx start
systemctl start nginx
//修改配置文件
vi /etc/nginx/nginx.conf
//访问localhost:80或使用curl测试安装是否成功
curl localhost

防火墙管理

CentOS 7.0默认使用的是firewall作为防火墙,可以改为iptables防火墙

查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
firewall-cmd --state 
systemctl list-unit-files|grep firewalld.service
systemctl status firewalld.service
关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
安装iptables
yum install iptables
启动iptables
systemctl start iptables.service
vi/etc/sysconfig/iptables #编辑防火墙配置文件

安装mysql

yum install mysql
yum install mysql-devel

docker 启动mysql

docker run mysql
docker run  -e MYSQL_ROOT_PASSWORD=root --name mysql -d mysql
//查看正在运行的端口
netstat -ntpl
tar命令
//压缩文件夹
tar czvf <FileName>.tar <DirName>
//解压文件
tar zxvf <FileName>.tar

gz命令
  解压1:gunzip FileName.gz
  解压2:gzip -d FileName.gz
  压缩:gzip FileName
  .tar.gz.tgz
  解压:tar zxvf FileName.tar.gz
  压缩:tar zcvf FileName.tar.gz DirName
   压缩多个文件:tar zcvf FileName.tar.gz DirName1 DirName2 DirName3 ...

zip命令
  解压:unzip FileName.zip
  压缩:zip FileName.zip DirName

猜你喜欢

转载自blog.csdn.net/qq_25639809/article/details/79484710
今日推荐