centos7.1 yum 安装 MySQL5.7 和 PHP5.6
时间:2016-07-14 13:49 来源:linux.it.net.cn 作者:IT
1. 首先关闭防火墙
[root@svnhost html]# systemctl stop firewalld.service
2. 取消SELinux的安全设置,否则/var/log/httpd/error_log中会出现“permission denied"错误,不能解析PHP文件
#vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
#setenforce 0 #使配置立即生效
3. 安装MySQL5.7
3.1 因为缺省没有匹配的MySQL YUM 库,所以先要添加yum库
[root@svnhost backup]# rpm -Uvh mysql57-community-release-el7-8.noarch.rpm
mysql57-community-release-el7-8.noarch.rpm 在 http://dev.mysql.com/downloads/repo/yum/ 中下载
3.2 查看yum库是否已经添加
[root@svnhost backup]# yum repolist all |grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 21
mysql-connectors-community-source MySQL Connectors Community - So disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 33
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - So disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - So disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 74
mysql57-community-source MySQL 5.7 Community Server - So disabled
3.3 安装最新的MySQL5.7
root@svnhost backup]# yum install mysql-community-server
3.4 启动MySQL 服务
[root@svnhost system]# systemctl enable mysqld.service
[root@svnhost system]# systemctl start mysqld.service
[root@svnhost system]# systemctl stop mysqld.service
3.5 修改root密码
比较坑爹的是mysql在安装的时候会产生一个临时密码,可以通过下面命令看到:
# grep "temporary password" | /var/log/mysqld.log
然后使用这个密码登陆后修改成你需要的密码
[root@svnhost log]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> alter user 'root'@'localhost' identified by 'a3b4c5d6!!'; //只能使用这个命令修改密码
Query OK, 0 rows affected (0.18 sec)
mysql>quit;
4.安装PHP5.6.20
4.1 因为yum缺省安装的是PHP5.4,所以先要添加yum库
[root@svnhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
[root@svnhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
4.2. 安装PHP5.6.20
[root@svnhost ~]# yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64
[root@svnhost log]# yum install php-pear //安装SVNMANAGER需要的包
[root@svnhost ~]# yum install php-mysqli //安装svnmanage需要的包
4.3.配置PHP
vi /etc/php.ini #编辑
date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off #禁止显示php版本的信息
short_open_tag = ON #支持php短标签,一定要打开,否则不能解析PHP文件
:wq! #保存退出
4.4 测试PHP安装是否成功
#systemctl restart httpd.service
#systemctl start mysqld.service
# vi /var/www/html/index.php
<?
phpinfo();
?>
从客户端访问http://192.168.44.47:8000, 显示PHP版本信息,说明PHP安装成功。
5. 重启防火墙
#systemctl start firewalld.service
因为8000端口之前己经打开,所以测试PHP访问依然成功。
(责任编辑:IT)
1. 首先关闭防火墙 [root@svnhost html]# systemctl stop firewalld.service
2. 取消SELinux的安全设置,否则/var/log/httpd/error_log中会出现“permission denied"错误,不能解析PHP文件 #vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq! #保存退出 #setenforce 0 #使配置立即生效
3. 安装MySQL5.7 3.1 因为缺省没有匹配的MySQL YUM 库,所以先要添加yum库 [root@svnhost backup]# rpm -Uvh mysql57-community-release-el7-8.noarch.rpm mysql57-community-release-el7-8.noarch.rpm 在 http://dev.mysql.com/downloads/repo/yum/ 中下载 3.2 查看yum库是否已经添加
[root@svnhost backup]# yum repolist all |grep mysql 3.3 安装最新的MySQL5.7 root@svnhost backup]# yum install mysql-community-server 3.4 启动MySQL 服务
[root@svnhost system]# systemctl enable mysqld.service
3.5 修改root密码 比较坑爹的是mysql在安装的时候会产生一个临时密码,可以通过下面命令看到: # grep "temporary password" | /var/log/mysqld.log 然后使用这个密码登陆后修改成你需要的密码
[root@svnhost log]# mysql -uroot -p Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> alter user 'root'@'localhost' identified by 'a3b4c5d6!!'; //只能使用这个命令修改密码 mysql>quit;
4.安装PHP5.6.20 4.1 因为yum缺省安装的是PHP5.4,所以先要添加yum库 [root@svnhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm [root@svnhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 4.2. 安装PHP5.6.20 [root@svnhost ~]# yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 [root@svnhost log]# yum install php-pear //安装SVNMANAGER需要的包
[root@svnhost ~]# yum install php-mysqli //安装svnmanage需要的包 4.3.配置PHP vi /etc/php.ini #编辑 date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname #列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。 expose_php = Off #禁止显示php版本的信息 short_open_tag = ON #支持php短标签,一定要打开,否则不能解析PHP文件
:wq! #保存退出
4.4 测试PHP安装是否成功 #systemctl restart httpd.service #systemctl start mysqld.service # vi /var/www/html/index.php
<? 从客户端访问http://192.168.44.47:8000, 显示PHP版本信息,说明PHP安装成功。
5. 重启防火墙 #systemctl start firewalld.service 因为8000端口之前己经打开,所以测试PHP访问依然成功。 (责任编辑:IT) |