首页 > 代码库 > CentOS安装PHP和mysql

CentOS安装PHP和mysql

新生在不会编译的情况下:

1、安装PHP5

yum install php
根据提示输入Y直到安装完成
2、安装PHP组件,使 PHP5 支持 MySQL
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
 
2.安装Mysql:
**第一次安装时出现:
 

[root@VM_18_87_centos ~]# service mysql start
Redirecting to /bin/systemctl start mysql.service
Failed to start mysql.service: Unit mysql.service failed to load: No such file or directory.

[root@VM_18_87_centos mysql-5.5.3-m3]# service mysql status
Redirecting to /bin/systemctl status mysql.service
* mysql.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)

 

**在网上发现解决办法:

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

 

**然后移除已安装的Mysql后,再次安装:

yum install  mysql mysql-server mysql-libs mysql-server

 

最后重启Mysql服务:

 

[root@VM_18_87_centos ~]# service mysql start
Redirecting to /bin/systemctl start mysql.service

 

可以啦:

[root@VM_18_87_centos ~]# service mysql status
Redirecting to /bin/systemctl status mysql.service
* mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2016-11-20 16:02:08 CST; 3s ago
Process: 16986 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 16923 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 16985 (mysqld_safe)
CGroup: /system.slice/mysqld.service
|-16985 /bin/sh /usr/bin/mysqld_safe
`-17139 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-...

Nov 20 16:02:07 VM_18_87_centos mysql-systemd-start[16923]: Support MySQL by buying s...
Nov 20 16:02:07 VM_18_87_centos mysql-systemd-start[16923]: Note: new default config ...
Nov 20 16:02:07 VM_18_87_centos mysql-systemd-start[16923]: Please make sure your con...
Nov 20 16:02:07 VM_18_87_centos mysql-systemd-start[16923]: WARNING: Default config f...
Nov 20 16:02:07 VM_18_87_centos mysql-systemd-start[16923]: This file will be read by...
Nov 20 16:02:07 VM_18_87_centos mysql-systemd-start[16923]: If you do not want to use...
Nov 20 16:02:07 VM_18_87_centos mysql-systemd-start[16923]: --defaults-file argument ...
Nov 20 16:02:07 VM_18_87_centos mysqld_safe[16985]: 161120 16:02:07 mysqld_safe Logg....
Nov 20 16:02:07 VM_18_87_centos mysqld_safe[16985]: 161120 16:02:07 mysqld_safe Star...l
Nov 20 16:02:08 VM_18_87_centos systemd[1]: Started MySQL Community Server.
Hint: Some lines were ellipsized, use -l to show in full.

 

 

 

CentOS安装PHP和mysql