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,system,chroot,scandir,chgrp,chown,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
<?php
phpinfo();
?>
從客戶端訪問http://192.168.44.47:8000, 顯示PHP版本信息,說明PHP安裝成功。
5. 重啓防火牆
#systemctl start firewalld.service
因爲8000端口之前己經打開,所以測試PHP訪問依然成功。