Contact Us

Install Apache, PHP, MySQL on CentOS 7


This article shows you how to install Apache and PHP and MySQL CentOS 7. The default CentOS 7 image does not have access to repositories that support PHP version 5.6 and higher, so we need to enable a repository that does. The advantages of using yum to perform the installation (instead of the source code) is that yum also automatically installs future security updates and handles dependencies.

Install Apache

yum install httpd

systemctl start httpd

systemctl enable httpd.service

firewall-cmd --add-service=http --permanent

firewall-cmd --reload

Install PHP 7.3

yum install

yum-config-manager --enable remi-php73

yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

php -v

Install MySQL


rpm -ivh mysql57-community-release-el7-9.noarch.rpm

yum install mysql-server

service mysqld start

grep "A temporary password" /var/log/mysqld.log

*** [Note] A temporary password is generated for root@localhost: hjkygMukj5+t783


*** Follow prompts, answer Y to all

service mysqld restart

chkconfig mysqld on

mysql -u root -p

Change SSH Port from Default

vi /etc/ssh/sshd_config

*** The Port line should be in the first page of the file, as either Port 22 or commented out as #Port 22. Go to the line. Press Insert to enter edit mode. Remove the # if present and change the port number to the required value. Press the Esc key to return to command mode and enter :wq to write out the file and quit vi.

yum -y install policycoreutils-python

semanage port -a -t ssh_port_t -p tcp 2132

firewall-cmd --zone=public --add-port=2132/tcp --permanent

firewall-cmd --reload

systemctl restart sshd.service

That’s all, Enjoy 🙂

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Consent to display content from Youtube
Consent to display content from Vimeo
Google Maps
Consent to display content from Google
Consent to display content from Spotify
Sound Cloud
Consent to display content from Sound