How to Set Up Apache, PHP, MySQL, and Zabbix on CentOS 7
Setting up Apache, PHP, and MySQL on CentOS 7 is a crucial part of configuring a robust web server environment. This guide walks you through the installation and configuration steps for Apache, PHP, and MySQL, followed by setting up Zabbix, a powerful open-source monitoring tool. By the end of this process, your server will be ready to deploy and manage applications effectively.

Step 1: Install and Configure Apache Web Server
To begin, install the Apache web server on your CentOS 7 system. The process is simple and can be achieved using the following commands:
- First, disable SELinux by running:
cat /etc/selinux/config SELINUX=disabled - Install Apache using:
yum install httpd -y - Update the Apache configuration by modifying the
/etc/httpd/conf/httpd.conffile. Here, you’ll set your server email and name as follows:vim /etc/httpd/conf/httpd.conf 86 ServerAdmin admin@zippyops.com 96 ServerName zabbix.zippyops.com - Restart Apache to apply changes:
systemctl restart httpd
Apache is now set up and ready to host your applications. If you need professional assistance in configuring or managing web servers, ZippyOPS offers consulting and managed services in DevOps and Cloud Infrastructure.
Step 2: Install and Configure PHP
Next, install PHP along with necessary extensions to ensure compatibility with Zabbix and other applications.
- Install PHP and essential extensions:
yum install epel-release -y yum install php php-pear php-cgi php-common php-mbstring php-snmp php-gd php-xml php-mysql php-gettext php-bcmath -y - Check the PHP version to ensure the installation was successful:
php --version
This setup equips your server with PHP, allowing it to process dynamic web content. If you are looking to optimize PHP for production environments, ZippyOPS can help with performance tuning as part of its Automated Ops services.
Step 3: Install and Configure MySQL
- First, add the MySQL 8.0 repository:
yum install https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm - Install MySQL using the following command:
yum --enablerepo=mysql80-community install mysql-community-server - Enable and start MySQL service:
systemctl enable mysqld.service systemctl start mysqld.service - Retrieve the temporary root password for MySQL from the log file:
grep 'temporary password' /var/log/mysqld.log - Run the
mysql_secure_installationcommand to set up a new password for the MySQL root user:mysql_secure_installation - After securing MySQL, log in to the MySQL shell:
mysql -u root -p - Create the Zabbix database and user:
CREATE DATABASE zabbixdb CHARACTER SET utf8 COLLATE utf8_bin; CREATE USER 'zabbixadmin'@'%' IDENTIFIED WITH mysql_native_password BY 'User@123'; GRANT ALL PRIVILEGES ON *.* TO 'zabbixadmin'@'%'; FLUSH PRIVILEGES;
Step 4: Install and Configure Zabbix Server
With Apache, PHP, and MySQL set up, we can now install Zabbix. Zabbix provides comprehensive monitoring for your infrastructure, and setting it up on CentOS 7 involves the following steps:
- Add the Zabbix repository:
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm - Install Zabbix server, proxy, and frontend with MySQL support:
yum install zabbix-server-mysql zabbix-proxy-mysql zabbix-web-mysql - Modify the Zabbix Apache configuration file (
/etc/httpd/conf.d/zabbix.conf) to set the correct timezone for PHP:php_value date.timezone Asia/Kolkata - Import the Zabbix database schema:
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbixadmin -p zabbixdb - Edit the Zabbix server configuration file to set the database connection details:
vim /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbixdb DBUser=zabbixadmin DBPassword=User@123 - Start the Zabbix server:
systemctl start zabbix-server systemctl enable zabbix-server
Step 5: Open Required Ports and Final Configuration
After setting up Zabbix, ensure the appropriate ports are open to allow traffic to Zabbix and Apache:
- Open the required ports:
firewall-cmd --zone=public --add-port={10050/tcp,10051/tcp} --permanent firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --reload - Finally, access the Zabbix web installer:
http://zabbix.zippyops.com/zabbix/
Complete the web-based installation process by following the on-screen instructions. After finishing the setup, you’ll be able to access the Zabbix dashboard to monitor your system’s performance and status.
Conclusion for setting up Apache, PHP, MySQL, and Zabbix on CentOS 7
By following these steps, you’ve successfully set up Apache, PHP, MySQL, and Zabbix on CentOS 7. This configuration provides a solid foundation for monitoring and managing your infrastructure.
For businesses seeking more advanced setups or managed services, ZippyOPS offers a variety of solutions in DevOps, Cloud, and Infrastructure management. Whether you’re interested in Automated Ops, AIOps, or MLOps, our experts are here to help. Learn more about our services at ZippyOPS Services and get in touch at sales@zippyops.com for a consultation.



