Skipping the LAMP introduction, as I’m sure that most of you know what is all about. This tutorial will concentrate on how lớn install and configure famous LAMP stack – Linux Apache, MariaDB, PHP, PhpMyAdmin – on the last release of Red Hat Enterprise Linux 7.0 và CentOS 7.0, with the mention that both distributions have upgraded httpd daemon to Apache HTTP 2.4.
Step 1: Install Apache hệ thống with Basic Configurations
1. After performing a minimal system installation and configure your server network interface with a Static IP Address on RHEL/CentOS 7.0, go ahead & install Apache 2.4 httpd service binary package provided khung official repositories using the following command.
# yum install httpd
2. After yum manager finish installation, use the following commands to manage Apache daemon, since RHEL và CentOS 7.0 both migrated their init scripts from SysV to systemd – you can also use SysV và Apache scripts the same time khổng lồ manage the service.
# systemctl status|start|stop|restart|reload httpdOR # service httpd status|start|stop|restart|reloadOR # apachectl configtest| graceful
3. On the next step start Apache service using systemd init script and mở cửa RHEL/CentOS 7.0 Firewall rules using firewall-cmd, which is the default command lớn manage iptables through firewalld daemon.
# firewall-cmd --add-service=httpNOTE: Make notice that using this rule will thất bại its effect after a system reboot or firewalld service restart, because it opens on-fly rules, which are not applied permanently. To lớn apply consistency iptables rules on firewall use –permanent option và restart firewalld service to lớn take effect.
# firewall-cmd --permanent --add-service=http# systemctl restart firewalld
Other important Firewalld options are presented below:
# firewall-cmd --state# firewall-cmd --list-all# firewall-cmd --list-interfaces# firewall-cmd --get-service# firewall-cmd --query-service service_name# firewall-cmd --add-port=8080/tcp4. To verify Apache functionality mở cửa a remote browser & type your server IP Address using HTTP protocol on URL (http://server_IP), & a mặc định page should appear like in the screenshot below.
5. For now, Apache DocumentRoot path it’s mix to /var/www/html system path, which by mặc định doesn’t provide any index file. If you want to see a directory list of your DocumentRoot path mở cửa Apache welcome configuration file và set Indexes statement from – to + on directive, using the below screenshot as an example.
# nano /etc/httpd/conf.d/welcome.conf
6. Close the file, restart Apache service to reflect changes and reload your browser page to see the final result.
Step 2: Install PHP5 support for Apache
7. Before installing PHP5 dynamic language support for Apache, get a full các mục of available PHP modules và extensions using the following command.
# yum tìm kiếm php
8. Depending on what type of applications you want khổng lồ use, install the required PHP modules from the above list, but for a basic MariaDB support in PHP and PhpMyAdmin you need lớn install the following modules.
# yum install php php-mysql php-pdo php-gd php-mbstring
9. To get a full information list on PHP from your browser, create a info.php file on Apache Document Root using the following command from root account, restart httpd service và direct your browser lớn the http://server_IP/info.php address.
# echo "" > /var/www/html/info.php# systemctl restart httpd
10. If you get an error on PHP Date và Timezone, open php.ini configuration file, tìm kiếm and uncomment date.timezone statement, append your physical location & restart Apache daemon.
# nano /etc/php.iniLocate and change date.timezone line to lớn look like this, using PHP Supported Timezones list.
date.timezone = Asia/Ho_Chi_Minh
Step 3: Install và Configure MariaDB Database11. Red Hat Enterprise Linux/CentOS 7.0 switched from MySQL to MariaDB for its mặc định database management system. Lớn install MariaDB database use the following command.
# yum install mariadb-server mariadb
12. After MariaDB package is installed, start database daemon & use mysql_secure_installation script khổng lồ secure database (set root password, disable remotely logon from root, remove thử nghiệm database và remove anonymous users).
# systemctl start mariadb# mysql_secure_installation
13. To demo database functionality login to MariaDB using its root account & exit using quit statement.
mysql -u root -pMariaDB > SHOW VARIABLES;MariaDB > quit
Step 4: Install PhpMyAdmin
14. By mặc định official RHEL 7.0 or CentOS 7.0 repositories doesn’t provide any binary package for PhpMyAdmin web Interface. If you are uncomfortable using MySQL command line to lớn manage your database you can install PhpMyAdmin package by enabling CentOS 7.0 rpmforge repositories using the following command.
# yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpmAfter enabling rpmforge repository, next install PhpMyAdmin.
# yum install phpmyadmin
15. Next configure PhpMyAdmin lớn allow connections from remote hosts by editing phpmyadmin.conf file, located on Apache conf.d directory, commenting the following lines.
# nano /etc/httpd/conf.d/phpmyadmin.confUse a # and phản hồi this lines.
# Order Deny,Allow# Deny from all# Allow from 127.0.0.1
16. To be able to login khổng lồ PhpMyAdmin website interface using cookie authentication method showroom a blowfish string to phpmyadmin config.inc.php file lượt thích in the screenshot below using the generate a secret string, restart Apache web service & direct your browser to the URL address http://server_IP/phpmyadmin/.
# nano /usr/share/phpmyadmin/config.inc.php# systemctl restart httpd
Step 5: Enable LAMP System-wide
17. If you need MariaDB và Apache services lớn be automatically started after reboot issue the following commands to lớn enable them system-wide.
# systemctl enable mariadb# systemctl enable httpdThat’s all it takes for a basic LAMP installation on Red Hat Enterprise 7.0 or CentOS 7.0.