Install Apache, PHP and MYSQL On CentOS 6 Server
This template is available in the client area to deploy to VPS servers running Virtuozzo
On most of our Operating system packages, Apache is installed by default. You can easily see if apache is installed and running by just visiting your IP address in a browser like Chrome or Edge. If for some reason it is not installed you can install Apache with the below commands.
install httpd -y service httpd start
Ensure port 80 is open in your servers firewall. If not, use the commands below to open the port.
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT /etc/rc.d/init.d/iptables save
To install MySQL you can use the below commands in an SSH console. All commands need to be run as the root user
yum install mysql-server service mysqld start
Once started run the post-installation script
You will be asked for the current root password, leave this blank by just hitting enter then, set a new MySQL root password.
Set root password? [Y/n] Y New password: YourMySQLPassword Re-enter new password: YourMySQLPassword
Select the following options when promoted too.
Remove anonymous user? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
MySQL is now installed on your server and you can move on to installing PHP.
The default PHP version in yum is currently PHP 5.3 which is end of life so we are going to use new RPMs to install a newer version of PHP. Copy the below code into your SSH console;
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm ; wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm ; rpm -Uvh epel-release-6-8.noarch.rpm remi-release-6.rpm
Next, install Yum Utils which we will use to enable the remi repository
yum install yum-utils
Enable your required version of PHP. you can enable PHP 5.4, PHP 5.5 and PHP 5.6.
To Intall PHP 5.4
yum-config-manager --enable remi-php54
To Intall PHP 5.5
yum-config-manager --enable remi-php55
To Intall PHP 5.6
yum-config-manager --enable remi-php56
Once installed you can then install any required PHP module by issuing the correct commands in the SSH console, for example
yum install php php-cli php-mcrypy php-curl php-gd php-mysql php-zip php-ldap php-fileinfo
How was this article? – Install Apache, PHP and MySQL On CentOS 6 Server
You might also like
More from All About Linux
Open And Close Ports In FirewallD - Manage Zones In FirewallD Like IPtables, FirewallD is a Linux firewall that filters packets …