Installing Apache, PHP, and MySQL on CentOS 7.0
In this article, we will walk you through the process of installing the Apache web server, PHP scripting language, and MySQL relational database management system on CentOS 7.0.
Replacing MariaDB with MySQL
By default, CentOS 7.0 uses MariaDB as its MySQL equivalent. However, for this installation, we will uninstall MariaDB and install the official MySQL server.
Uninstalling MariaDB
To uninstall MariaDB, we will first list all installed RPM packages using the following command:
rpm -qa | grep mariadb
This will output a list of installed MariaDB packages. We will then delete each package one by one using the following command:
rpm -e --nodeps mariadb-libs-x86_64
Downloading and Installing MySQL
To download and install the MySQL server, we will use the following commands:
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
Installing Apache, PHP, and MySQL
To install the Apache web server, PHP scripting language, and MySQL relational database management system, we will use the following command:
yum -y install httpd php mysql mysql-server php-mysql
Installing Apache Extensions
To install Apache extensions, we will use the following commands:
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
Installing PHP Extensions
To install PHP extensions, we will use the following commands:
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
Installing MySQL Extension
To install the MySQL extension, we will use the following command:
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
Configuring Boot Services
To configure the boot services for the Apache and MySQL servers, we will use the following commands:
/sbin/chkconfig httpd on
/sbin/service httpd start
/sbin/service mysqld start
Setting the MySQL Root Password
To set the MySQL root password, we will use the following command:
mysql -u root
SET PASSWORD FOR root@localhost = PASSWORD('123456');
EXIT
Starting and Stopping Apache and MySQL Services
To start and stop the Apache and MySQL services, we will use the following commands:
systemctl start httpd
systemctl stop httpd
systemctl restart httpd
systemctl enable httpd
systemctl start mysqld
systemctl stop mysqld
systemctl restart mysqld
systemctl enable mysqld
By following these steps, you should now have a fully functional Apache, PHP, and MySQL installation on your CentOS 7.0 system.