加入收藏 | 设为首页 | 会员中心 | 我要投稿 莱芜站长网 (https://www.0634zz.com/)- 云连接、建站、智能边缘云、设备管理、大数据!
当前位置: 首页 > 运营中心 > LNMP > 正文

centos7搭建LNMP环境编译安装 yum安装超详细

发布时间:2023-02-17 14:01:11 所属栏目:LNMP 来源:互联网
导读:文章目录 1. 首先了解编译安装和yum安装的区别。 2. yum安装准备工作---切换阿里云yum源 3. 编译安装lnmp **很不建议使用编译安装,麻烦且容易报错。** 4.yum安装lnmp **可以先执行一下 yum update** 5. lnmp一键安装 [参考网站](https://lnmp.org/) **不喜

      killproc $prog -HUP
      retval=$?
      echo
  }
  force_reload() {
      restart
  }
  configtest() {
    $Nginx -t -c $Nginx_CONF_FILE
  }
  rh_status() {
      status $prog
  }
  rh_status_q() {
      rh_status >/dev/null 2>&1
  }
  case "$1" in
      start)
          rh_status_q && exit 0
          $1
          ;;
      stop)
          rh_status_q || exit 0
          $1
          ;;
      restart|configtest)
          $1
          ;;
      reload)
          rh_status_q || exit 7
          $1
          ;;
      force-reload)
          force_reload
          ;;
      status)
          rh_status
          ;;
      condrestart|try-restart)
          rh_status_q || exit 0
              ;;
      *)
          echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
          exit 2
  esac
  然后执行
 
  # 重新加载某个服务的配置文件
  systemctl daemon-reload
  然后查看Nginx状态
 
  service Nginx status
  我这里报错了!! 提示错误信息Can’t open PID file /var/run/Nginx.pid (yet?) after start:,原因是Nginx主配置文件Nginx.conf中 pid指令配置的pid路径 与 Nginx systemd service文件中的配置PIDFile路径不一致导致的。
  解决办法:
 
  我用此方法并没有解决!将/etc/init.d/Nginx(对应你的Nginx service配置文件) 的pidfile 注释去掉,修改内容为logs/Nginx.pid
  或者将你Nginx主配置文件Nginx.conf的pid注释去掉并修改内容为你的Nginx service配置文件的pidfile
  总之两者pid路径一直即可解决。
  用此方法解决了使用Nginx -c的参数指定Nginx.conf文件的位置。执行如下命令。
  ​1. /usr/local/Nginx/sbin/Nginx -c /usr/local/Nginx/conf/Nginx.conf
  2. systemctl daemon-reload
  3. service Nginx status 就没错了
 
  如果想虚拟机外访问Nginx记得关闭防火墙。centos有多种防火墙。
 
  systemctl status firewalld.service — 查看防火墙状态
  systemctl stop firewalld.service — 关闭防火墙
  systemctl disable firewalld.service — 设置开机禁用防火墙
  iptables防火墙的关闭!!!
  servcie iptables stop --临时关闭防火墙
  chkconfig iptables off --永久关闭防火墙
  service iptables status --查看防火墙状态
 
  最后一步:将Nginx添加到环境变量
 
  vim /etc/profile
  在最后面写入如下代码
  PATH=$PATH:/usr/local/Nginx/sbin
  export PATH
  最后执行 source /etc/profile
 
  至此,编译安装Nginx完成!
 
  MysqL
  1.1 首先卸载掉自带的MysqL
 
  rpm -qa | grep mariadb   查看已安装的mariadb
  rpm -e mariadb-***       卸载掉相应的mariadb
  yum -y remove mari*  卸载yum安装的mariadb
  rpm -qa |grep MysqL 查看已安装的MysqL
  rpm -e MysqL-*** 卸载已安装的MysqL
  yum remove MysqL** 卸载yum安装的MysqL
  find / -name MysqL
  rm -rf 相应的文件
  1.2 下载安装包
  首先查看自己的linux是32位还是64位?
 
  uname -a     # 如果是64位机器,会输出x86_64
  下载安装包 mysql下载地址。 要下载带boost的版本,Linux-Generic的版本是直接下载好解压完成,稍微配置一下就能用的。这种版本的MysqL安装配置方式有待研究一下。
 
  https://cdn.MysqL.com/archives/MysqL-5.7/MysqL-boost-5.7.33.tar.gz
  在这里插入图片描述
 
  然后解压 ,这里有cmake的配置说明。MySQL CMake参数说明手册
  tar -zxvf MysqL-boost-5.7.33.tar.gz
  cd ./MysqL-5.7.33
  cmake -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DMysqL_DATADIR=/usr/local/MysqL/data -DSYSconfdIR=/etc -DMysqL_TCP_PORT=3306 -DWITH_BOOST=/usr/local/MysqL-5.7.33/boost
  make && make install
  1.3 安装完成后,执行命令
 
  cd /usr/local/MysqL
 
  1.4 编辑/etc/my.cnf ( 如果没有则创建)
 
  [client]
  port        = 3306
  socket      = /tmp/MysqL.sock
  [MysqLd]
  port        = 3306
  socket      = /tmp/MysqL.sock
  user = MysqL
  base dir = /usr/local/MysqL
  datadir = /data/MysqL/data
  pid-file = /data/MysqL/MysqL.pid
  log_error = /data/MysqL/MysqL-error.log
  slow_query_log = 1
  long_query_time = 1
  slow_query_log_file = /data/MysqL/MysqL-slow.log
  skip-external-locking
  key_buffer_size = 32M
  max_allowed_packet = 1024M
  table_open_cache = 128
  sort_buffer_size = 768K
  net_buffer_length = 8K
  read_buffer_size = 768K
  read_rnd_buffer_size = 512K
  myisam_sort_buffer_size = 8M
  thread_cache_size = 16
  query_cache_size = 16M
  tmp_table_size = 32M
  performance_schema_max_table_instances = 1000
  explicit_defaults_for_timestamp = true
  #skip-networking
  max_connections = 500
  max_connect_errors = 100
  open_files_limit = 65535
  log_bin=MysqL-bin
  binlog_format=mixed
  server_id   = 232
  expire_logs_days = 10
  early-plugin-load = ""
  default_storage_engine = InnoDB
  innodb_file_per_table = 1
  innodb_buffer_pool_size = 128M
  innodb_log_file_size = 32M
  innodb_log_buffer_size = 8M
  innodb_flush_log_at_trx_commit = 1
  innodb_lock_wait_timeout = 50
  [MysqLdump]
  quick
  max_allowed_packet = 16M
  [MysqL]
  no-auto-rehash
  [myisamchk]
  key_buffer_size = 32M
  sort_buffer_size = 768K
  read_buffer = 2M
  write_buffer = 2M
  把当前用户和组改成MysqL
 
  cd /usr/local
  chown -R MysqL:MysqL MysqL
  初始化MysqL
 
  ./MysqLd --initialize-insecure --user=MysqL --basedir=/usr/local/MysqL --datadir=/data/MysqL/data
  如果没有创建data目录,记着创建一下,再次执行初始化即可。
 
  mkdir /data/MysqL/data
  #赋予权限
  chmod -R 777 /data/MysqL
  拷贝可执行配置文件
 
  cd /usr/local/MysqL/support-files
  cp MysqL.server /etc/init.d/MysqLd
  至此基本上安装成功了。启动MysqL
 
  service MysqLd start
  测试连接
 
  cd /usr/local/MysqL/bin
  ./MysqL -hlocalhost -uroot -p

(编辑:莱芜站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读