LINUX-centos7服务器环境安装的那些坑

admin5年前IT技术1262


LINUX-centos7服务器环境安装的那些坑
亲自测试能用的

第一步 安装php

一定要加上--skip-broken,否则根本无法安装,依赖的程序实在是太多了,我走过这个弯路;
 yum -y install php*   --skip-broken

第二步 安装apache

 yum install httpd

设置HTTPD自动启动
systemctl enable httpd.service

yum安装的httpd,在/etc/httpd/conf.d/目录下添加vhosts.conf后重启即可,vhosts.conf文件格式如下


<VirtualHost *:80> 
 ServerName www.test.com 
 DocumentRoot "/website/siteone" 
 DirectoryIndex index.html index.php 
 
 <Directory "/website/siteone"> 
  Options -Indexes +FollowSymlinks 
  AllowOverride All 
  Require all granted 
 </Directory> 
 
</VirtualHost>

启动 service httpd start

注意了下面的是关键
 关闭关闭SELINUX

因为他不干人事,导致你们到处配置出问题,会导致APACHE站点目录出现无权限访问的提示

vi /etc/selinux/config

 # This file controls the state of SELinux on the system. 
# SELINUX= can take one of these three values: 
#     enforcing - SELinux security policy is enforced. 
#     permissive - SELinux prints warnings instead of enforcing. 
#     disabled - No SELinux policy is loaded. 
#SELINUX=enforcing 
SELINUX=disabled 
# SELINUXTYPE= can take one of three two values: 
#     targeted - Targeted processes are protected, 
#     minimum - Modification of targeted policy. Only selected processes are protected.  
#     mls - Multi Level Security protection. 
SELINUXTYPE=targeted  

:wq! #保存退出

setenforce 0 #使配置立即生效

第三步  安装MYSQL

千万不能简单的运行 yum install mysql,安装的根本不是mysql,而是变种的MariaDB

应该是rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

查看当前可用的mysql安装资源

yum repolist enabled | grep "mysql.*-community.*"

安装
 yum -y install mysql-community-server
设置将其开机启动
systemctl enable mysqld
启动
systemctl start mysqld
设置密码
mysql_secure_installation
进去MYSQL
mysql -uroot -p


mysql>use mysql;
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
      GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '962360' WITH GRANT OPTION; 

最后关闭防火墙
iptables -F

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

进行测试  

 

相关文章

etst新上传的产品搜索不到

etst新上传的产品搜索不到,原因有如下几个:1:平台没有更新索引--数据库的一种技术,大概需要7天到15天吧,投广告也没有什么用,只能等2.你的SEO有问题,建议学习一下SEO基础知识与etsy的关...

centos共享远程目录

服务器端设置:1.安装依赖包 yum -y install nfs*2.修改文件vim /etc/exports   添加如下内容    /要共享的目...

1.解压缩

将下载到本地的安装介质解压缩。然后,将解压后的文件夹mysql-5.7.16-winx64拷贝到安装目录(E盘根目录)下。

2.设置系统环境变量

右键点击 计算机>>属性>> 高级系统属性>>环境变量>> 编辑 Path ,在最后添加” ;E:\mysql-5.7.16-winx64\bin“,确定。

3.创建my.ini 文件和data目录,配置安装路径与数据存储路径

在E:\mysql-5.7.16-winx64目录下创建data目录和my.ini,并在my.ini中配置安装路径与数据存储路径等信息。

点击(此处)折叠或打开

  1. [mysql]
  2. default-character-set=utf8
  3. [mysqld]
  4. max_connections=200
  5. default-storage-engine=INNODB
  6. basedir =E:\mysql-5.7.16-winx64\bin
  7. datadir =E:\mysql-5.7.16-winx64\data
  8. port = 3306

 

4.安装MySQL服务

首先,以管理员身份运行 cmd 并切换到MySQL的bin目录下;

接下来,执行mysqld --initialize-insecure

    这条命令用来初始化data文件,其中insecure选项指定登录无需口令。

点击(此处)折叠或打开

  1. D:\>e:
  2.  
  3. E:\>cd mysql-5.7.16-winx64
  4.  
  5. E:\mysql-5.7.16-winx64>cd bin
  6.  
  7. E:\mysql-5.7.16-winx64\bin>mysqld --initialize-insecure
  8.  
  9. E:\mysql-5.7.16-winx64\bin>

需要注意的是,如果不指定insecure选项,则会随机生成登陆密码, 在E:\mysql-5.7.16-winx64\data文件夹下,有一个 hoegh.err 文件,其中hoegh是主机名,打开会看到:
2016-10-20T09:34:56.806257Z 1 [Note] A temporary password is generated for root@localhost: p-mcI:ijR6Xg,
其中 p-mcI:ijR6Xg即为随机密码。

然后,输入 mysqld --install安装MySQL服务

我们会看到界面出现:Server successfully installed,这就说明MySQL服务安装成功。 

点击(此处)折叠或打开

  1. E:\mysql-5.7.16-winx64\bin>
  2.  
  3. E:\mysql-5.7.16-winx64\bin>mysqld --install
  4. Service successfully installed.
  5.  
  6. E:\mysql-5.7.16-winx64\bin>

5.启动MySQL服务

输入  net start mysql  回车, 就会看到: MySQL 服务已经启动成功。尝试使用root用户登录数据库,并通过show databases命令查看数据库概要信息。

点击(此处)折叠或打开

  1. E:\mysql-5.7.16-winx64\bin>
  2. E:\mysql-5.7.16-winx64\bin>net start mysql
  3. MySQL 服务正在启动 .
  4. MySQL 服务已经启动成功。
  5.  
  6.  
  7. E:\mysql-5.7.16-winx64\bin>mysql -u root
  8. Welcome to the MySQL monitor. Commands end with ; or \g.
  9. Your MySQL connection id is 2
  10. Server version: 5.7.16 MySQL Community Server (GPL)
  11.  
  12. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  13.  
  14. Oracle is a registered trademark of Oracle Corporation and/or its
  15. affiliates. Other names may be trademarks of their respective
  16. owners.
  17.  
  18. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  19.  
  20. mysql> show databases;
  21. +--------------------+
  22. | Database |
  23. +--------------------+
  24. | information_schema |
  25. | mysql |
  26. | performance_schema |
  27. | sys |
  28. +--------------------+
  29. 4 rows in set (0.00 sec)
  30.  
  31. mysql>

 

6.修改root密码

    安全起见,我们修改一下root密码。

点击(此处)折叠或打开

  1. mysql>
  2. mysql> alter user 'root'@'localhost' identified by 'root';
  3. Query OK, 0 rows affected (0.00 sec)
  4.  
  5. mysql>
  6. mysql> exit
  7. Bye
  8.  
  9. E:\mysql-5.7.16-winx64\bin>mysql -u root -proot
  10. mysql: [Warning] Using a password on the command line interface can be insecure.
  11. Welcome to the MySQL monitor. Commands end with ; or \g.
  12. Your MySQL connection id is 4
  13. Server version: 5.7.16 MySQL Community Server (GPL)
  14.  
  15. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  16.  
  17. Oracle is a registered trademark of Oracle Corporation and/or its
  18. affiliates. Other names may be trademarks of their respective
  19. owners.
  20.  
  21. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  22.  
  23. mysql> show databases;
  24. +--------------------+
  25. | Database |
  26. +--------------------+
  27. | information_schema |
  28. | mysql |
  29. | performance_schema |
  30. | sys |
  31. +--------------------+
  32. 4 rows in set (0.00 sec)
  33.  
  34. mysql>


MySQL数据库可以用任意ip连接访问的方法

 

过CMD命令行修改

MYSQL安装

  今天在Windows Server 2008 r2系统下部署了MySQL Community Server 5.7.16,安装过程中也遇到了一些问题,在这儿记录一下最终的安装过程。0.下...

本人安装Magento2.4.6安装踩坑大集合

1.痛点1 composer 的版本查看命令输入错误,导致我以为我安装失败 composer --version或者 composer -Vcomposer create-proj...

MYSQL替换第一个匹配的值

UPDATE zq_newsSET zq_content = CONCAT(    REPLACE (      &nb...

mysql数据库的还原与备份的注意事项

mysqldump -R -u root -p  *** > ***.sql   指定数据库的备份,包括存储过程.mysqldump  -u root -...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。