In this article, we will learn how to install a LAMP environment, which includes Apache, PHP, and MySQL, on a CentOS 6 cloud server. The installation process is divided into the following steps.
Before installation, we update the operating system to the latest version and reboot the cloud server.
yum update -y
reboot
Install Apache using the following command:
yum install httpd -y
service httpd start
Check the version of Apache with the following command:
httpd -v
The output will be displayed as follows:
Server version: Apache/2.2.15 (Unix)
Server built: Jun 19 2018 15:45:13
Set iptables to allow access to port 80:
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save
Also, configure Apache to start with the system boot:
chkconfig httpd on
If we access the cloud server's IP address http://IPAddress in a browser and the Apache default page appears, it indicates that Apache has been successfully installed.
Install PHP using the following command:
yum install php -y
Next, install the necessary PHP extensions:
yum install php-{bcmath,intl,gd,mcrypt,mbstring,mysql,fpm} -y
Check the PHP version with the following command:
php -v
The output will be displayed as follows:
PHP 5.3.3 (cli) (built: Nov 1 2019 12:28:08)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Check the installed PHP modules with the following command:
php -m
The output will be displayed as follows:
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
zip
zlib
[Zend Modules]
Install MySQL using the following command:
yum install mysql-server -y
service mysqld start
Check the MySQL version with the following command:
mysql -V
The output will be displayed as follows:
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
Then, run the MySQL post-installation setup wizard:
mysql_secure_installation
In the MySQL setup wizard, we need to enter the root password and answer some security-related questions, typically selecting the default values provided by the wizard.
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
Remove anonymous users? [Y/n]
... Success!
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n]
... Success!
By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n]
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? [Y/n]
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL installation should now be secure.
Thanks for using MySQL!
Also, configure MySQL to start with the system boot:
chkconfig mysqld on
Finally, restart Apache to work with PHP:
service httpd restart
This concludes our tutorial on installing Apache, PHP, and MySQL on a CentOS 6 cloud server.
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58