Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7
Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7
August 12, 2014
LAMP is a combination of operating system and open-source software stack. The acronym of LAMP is derived from first letters of Linux, Apache HTTP Server, MySQL/MariaDB database, and PHP/Perl/Python.
In this tutorial, let us see how to setup LAMP server on RHEL/CentOS/Scientific Linux 7.
My testbox hostname and IP address are server.unixmen.local and 192.168.1.101/24respectively.
Install Apache
Apache is an open-source multi-platform web server. It provides a full range of web server features including CGI, SSL and virtual domains.
The following commands should be run with root user privileges.
To install Apache, enter the following command in your terminal:
yum install httpd -y
Start the Apache service and make it to start automatically on every reboot:
systemctl start httpd
systemctl enable httpd
If you’re behind firewall or router, allow Apache server through your firewall/router in case you want to access it from the remote systems. To do that, enter the following commands from your Terminal:
firewall-cmd --permanent --add-service=http
systemctl restart firewalld
Test Apache
Open your web browser and navigate to http://localhost/ or http://server-ip-address/.
Install MariaDB
MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.
Now, start installing MariaDB as shown below:
yum install mariadb-server mariadb -y
Start MariaDB service and let it to start automatically on every reboot:
systemctl start mariadb
systemctl enable mariadb
Set MySQL root password
By default, MySQL root password is empty. So, to prevent unauthorized access to MySQL, let us set root user password. Enter the following command to setup mysql root user password:
mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, 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 MariaDB
root user without the proper authorisation. Set root password? [Y/n] y ## Enter Y and press Enter
New password: ## Enter new password
Re-enter new password: ## Enter password again
Password updated successfully!
Reloading privilege tables..
... Success! By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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] y ## Enter Y and press Enter
... 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] y ## Enter Y and press Enter
... Success! By default, MariaDB 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] y ## Enter Y and press Enter
- 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] y ## Enter Y and press Enter
... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB
installation should now be secure. Thanks for using MariaDB!
Install PHP
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.
Install PHP with following command:
yum install php php-mysql php-gd php-pear -y
Test PHP:
Create a sample “testphp.php” file in Apache document root folder and append the lines as shown below:
vi /var/www/html/testphp.php
Add the following lines.
<?php
phpinfo();
?>
Restart httpd service:
systemctl restart httpd
Navigate to http://server-ip-address/testphp.php. It will display all the details about php such as version, build date and commands etc.
If you want to install all php modules, enter the command yum install php* -y and restart the httpd service. To verify for the modules, open web browser and navigate to http://server-ip-address/testphp.php. You will then see all php modules.
Install phpMyAdmin (Optional)
phpMyAdmin is a free open-source web interface tool used to manage your MySQL databases. By default phpMyAdmin will not be not found in CentOS/RHEL/Scientific Linux official repositories. So let us install it from EPEL repository.
To add EPEL repository, just follow the link.
Now, install phpMyAdmin:
yum install phpmyadmin -y
Configure phpMyAdmin
By default, phpMyAdmin can only be accessed from the localhost itself. To make it to accessible globally, do the following steps.
Edit the phpmyadmin.conf file:
vi /etc/httpd/conf.d/phpMyAdmin.conf
Find and comment the whole /<Directory> section and add the lines as shown below:
[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin ## Comment the following Section ## #<Directory /usr/share/phpMyAdmin/>
# <IfModule mod_authz_core.c>
# # Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
# </IfModule>
# <IfModule !mod_authz_core.c>
# # Apache 2.2
# Order Deny,Allow
# Deny from All
# Allow from 127.0.0.1
# Allow from ::1
# </IfModule>
#</Directory>## Add the following lines: <Directory /usr/share/phpMyAdmin/>
[...]
Options none
AllowOverride Limit
Require all granted
</Directory>
Edit “config.inc.php” file and change from “cookie” to “http” to change the authentication in phpMyAdmin:
vi /etc/phpMyAdmin/config.inc.php
Change ‘cookie’ to ‘http’.
[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?
[...]
Restart the Apache service:
systemctl restart httpd
Now you can access the phpmyadmin console by navigating to the URL http://server-ip-address/phpmyadmin/ from your browser.
Enter your MySQL username and password which you have given in previous steps. In my case its “root” and “centos”.
You will be redirected to PhpMyAdmin main web interface.
Now you will able to manage your MariaDB databases from phpMyAdmin web interface.
That’s it. Your LAMP server is up and ready to use.
Cheers!
Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7的更多相关文章
- Setup VSFTPD Server with Virtual Users On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3
We have already shown you How to Setup VSFTPD Server on CentOS 6.5/6.4 in our previous article. In t ...
- 在CentOS/RHEL/Scientific Linux 6下安装 LAMP
LAMP 是服务器系统中开源软件的一个完美组合.它是 Linux .Apache HTTP 服务器.MySQL 数据库.PHP(或者 Perl.Python)的第一个字母的缩写代码.对于很多系统管理员 ...
- Setup FTP Server On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3
setsebool allow_ftpd_full_access onsetsebool -P ftp_home_dir on vsftpd (Very Secure File Transport P ...
- linux之 CentOS/RHEL/Scientific Linux 6 & 7上安装Telnet
声明: 在安装和使用Telnet之前,需要记住以下几点. 在公网(WAN)中使用Telnet是非常不好的想法.它会以明文的格式传输登入数据.每个人都可以看到明文.如果你还是需要Telnet,强烈建议你 ...
- Install Google Chrome on Fedora 28/27, CentOS/RHEL 7.5 (在 fedora 28 等 上 安装 chrome)
今天在使用 fedora 安装 chrome 的时候遇到了问题,今天进行将安装过程进行记录下来.需要安装第三方软件仓库. 我们需要进行安装 fedora-workstation-repositorie ...
- [转载]Install Opera 12.16 Web Browser in CentOS/RHEL and Fedora
FROM: http://tecadmin.net/install-opera-web-browser-in-centos-rhel-fedora/ Opera is an modern web br ...
- Install SVN (Subversion) Server on Fedora 20/19, CentOS/Red Hat (RHEL) 6.5/5.10
Install SVN (Subversion) Server on Fedora 20/19, CentOS/Red Hat (RHEL) 6.5/5.10 Updated by JR on Mar ...
- Ubuntu下快速安装LAMP server
Ubuntu下可快速安装LAMP server(Apache+MySQL+PHP5). 首先,打开Ubuntu虚拟机,Terminal打开root权限:“sudo -s”. 一.安装LAMP serv ...
- setting up a IPSEC/L2TP vpn on CentOS 6 or Red Hat Enterprise Linux 6 or Scientific Linux
This is a guide on setting up a IPSEC/L2TP vpn on CentOS 6 or Red Hat Enterprise Linux 6 or Scientif ...
随机推荐
- Struts2中struts.multipart.maxSize配置
今天使用Struts2的文件上传控件时,在struts.xml中,将处理上传的action中的fileUpload拦截器的maximumSize参数设置为5000000,上传了一个3M的文件后发现控制 ...
- Oozie的详细启动步骤(CDH版本的3节点集群)
不多说,直接上干货! 我的机器情况是,bigdatamaster(Oozie是安装在这台节点上).bigdataslave1和bigdatalsave2. 启动步骤 第一:先启动mysqld服务进程 ...
- 【图像处理】计算Haar特征个数
http://blog.csdn.net/xiaowei_cqu/article/details/8216109 Haar特征/矩形特征 Haar特征本身并不复杂,就是用图中黑色矩形所有像素值的和减去 ...
- 参考sectools,每个人至少查找5种安全工具、库等信息并深入研究至少两种并写出使用教程
1.Nessus Nessus是免费网络漏洞扫描器,它可以运行于几乎所有的UNIX平台之上.它不仅能永久升级,还免费提供多达11000种插件(但需要注册并接受EULA-acceptance--终端用户 ...
- [UI基础][不会说话的汤姆猫]
会说话的汤姆猫这个APP层级风靡一时,其UI部分就是利用了序列动画的技术, 接下来 我们用汤姆猫来演示怎么制作序列动画. [要求]: 1.学会使用序列动画的方法 2.学会分析动画播放中内存占用高的问题 ...
- Notepad++ 管理工程--转载
http://blog.csdn.net/cashey1991/article/details/7001385 @1.首先从下面这个菜单打开工程panel @2.在工程panel的“Workspace ...
- egg.js npm start 启动报错
开发环境运行项目即npm run dev的时候是正常的,但是npm start会启动失败,最可能的原因是因为npm start启动使用egg-scripts机制启动,对于运行中遇到error日志就会中 ...
- Rails 5 Test Prescriptions 第14章 Testing Exteranl Services(中断。)
external testing strategy ✅ the service integration test✅ introduce VCR✅ Client Unit Tests ❌ Why an ...
- Android------视频播放器(包含全屏播放,快退,快进,腾讯新闻的列表播放等)
前段时间做了一个新闻APP,涉及到了列表视频播放,和腾讯新闻APP差不多,总结了一下代码,写了一个Demo来分享给大家. 用了 TabLayout+RecylerView+自定义视频控件 完成的 ...
- bzoj1854: [Scoi2010]游戏 贪心
lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有2个属性,这些属性的值用[1,10000]之间的数表示.当他使用某种装备时,他只能使用该装备的某一个属性.并且每种装备最多只能使 ...