17713433920 info@mac163.com

1.安装Apache


利用yum命令安装Apache

yum -y install httpd

启动httpd并且设置为开机启动

systemctl start httpd.service
systemctl enable httpd.service

安装成功后,可以看到熟悉的测试界面

Centos 7安装LAMP

另外,还需要配置一下防火墙,打开80和443端口
首先安装firewall

yum -y install firewalld firewall-config
systemctl start firewalld.service
systemctl enable firewalld.service

配置防火墙

firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

另外,如果对新的firewall配置不熟悉,或者想要使用原来的iptables也是可以的,利用一下命令便可以继续使用iptables service

systemctl stop firewalld
systemctl disable firewalld

iptables-service

touch /etc/sysconfig/iptables
systemctl start iptables
systemctl enable iptables

touch /etc/sysconfig/ip6tables
systemctl start ip6tables
systemctl enable ip6table

2.安装Mariadb


同样还是利用yum命令进行安装,并且配置开机启动

yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service

下面配置root密码

mysql_secure_installation

安装过程中会有几个选项,大家根据自己的需要进行配置就好了

Enter current password for root (enter for none):(输入原始root密码,若无enter)
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] (是否设置root密码)
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] (是否移除匿名用户)
 ... Success!

Disallow root login remotely? [Y/n] (是否禁止远程root登陆)
 ... skipping.

Remove test database and access to it? [Y/n] (是否删除测试数据库)

Reload privilege tables now? [Y/n] (重新载入)
 ... 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!

3.安装PHP 7.0

需要先安装epel-release。

1.安装epel-release

通过命令:

rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

成功安装。

2.安装PHP7

终端再次运行如下命令:

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

成功获取PHP7的yum源,然后再执行:

yum install php70w

这样就大功告成了。

3.验证安装

终端命令:php -v,显示当前PHP版本,信息如下:

[root@iZ94w0kemvtZ /]# php -v
PHP 7.0.2 (cli) (built: Jan  9 2016 14:00:11) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

这样就在CentOS 7下通过yum安装成功PHP 7。

重启httpd服务

 systemctl restart httpd.service

4.安装PHPMyAdmin(可选)


phpMyAdmin 是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的数据库管理工具,让管理者可用Web接口管理MySQL数据库。借由此Web接口可以成为一个简易方式输入繁杂SQL语法的较佳途径,尤其要处理大量资料的汇入及汇出更为方便。其中一个更大的优势在于由于phpMyAdmin跟其他PHP程式一样在网页服务器上执行,但是您可以在任何地方使用这些程式产生的HTML页面,也就是于远端管理MySQL数据库,方便的建立、修改、删除数据库及资料表。也可借由phpMyAdmin建立常用的php语法,方便编写网页时所需要的sql语法正确性。

首先要安装EPEL的源(注意要选择CentOS7的)

rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm  

安装并配置phpMyAdmin

yum install phpMyAdmin
vi /etc/httpd/conf.d/phpMyAdmin.conf

注释掉原来的部分配置文件,修改为以下格式:

# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

#<Directory /usr/share/phpMyAdmin/>
#   AddDefaultCharset UTF-8
#
#   <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>

<Directory /usr/share/phpMyAdmin/>
    Options none
    AllowOverride Limit
    Require all granted
</Directory>

修改认证方式(将 cookie 修改为 http)

vi /etc/phpMyAdmin/config.inc.php
[...]
$cfg['Servers'][$i]['auth_type']     = 'http';    // Authentication method (config, http or cookie based)?
[...]

重启http服务

systemctl restart  httpd.service

然后可以在浏览器中输入http://x.x.x.x/phpMyAdmin 利用前面设置的用户(root)和密码进行登录,登陆后下图:

phpMyAdmin

至此,我们就完成了环境配置。


微信二维码

微信扫描二维码联系我们!
我们在微信上24小时期待你的声音
提供外贸路由器设备产品,轻松翻墙,解答:WP主题推荐,WP网站建设,Google SEO,百度SEO,专业服务器环境搭建等!


需要提供WordPress主题/插件的汉化服务可以随时联系我们!另外成品WordPress网站以及半成品WordPress网站建设,海外Google SEO优化托管服务,百度SEO优化托管服务,Centos/Debian服务器WP专用环境搭建,WP缓存服务器搭建,我们都是你的首选,拥有多年WP开源程序服务经验,我们一直在坚持客户体验,没有最好,只有更好!
回到顶部