centos lamp 安装(lamp官网)

老铁们,大家好,相信还有很多朋友对于centos lamp 安装和lamp官网的相关问题不太懂,没关系,今天就由我来为大家分享分享centos lamp 安装以及lamp官网的问题,文章篇幅可能偏长,希望可以帮助到大家,下面一起来看看吧!

如何搭建lamp(CentOS7+Apache+MySQL+PHP)环境

在网上搜资料,自己在本地虚拟机上尝试搭建,弄了整整一天一夜,终于弄好了.网上的资料,虽然很多,但大多都是重复的,拿去试了之后,又很多都不能得到正确的结果.最终找到了适合我的linux环境的搭建方式;在这里贴出来:度娘真不给力啊,没搜出来靠谱的方法。最后用喜乐搜找到的靠谱的教程。

这里还是要总结一下我的LAMP环境的搭建步骤。我先在电脑里装了虚拟机,在虚拟机中测试了数次之后,再在服务器上搭建的。说说我的环境:虚拟机是:VMware® Workstation 12.1.1 Pro;Linux系统用的是:CentOS-7-x86_64-DVD-1511.iso;(阿里云上也是用的CentOS7-64bit)准备好这两个之后,就开始一步一步搭建我们的LAMP环境了。

一、安装虚拟机

二、安装CentOS7

注意:以下安装,我都是用的root权限。

三、安装Apache1.安装yum-y install httpd2.开启apache服务systemctl start httpd.service3.设置apache服务开机启动systemctl enable httpd.service4.验证apache服务是否安装成功在本机浏览器中输入虚拟机的ip地址,CentOS7查看ip地址的方式为:ip addr(阿里云不需要用这种方式查看,外网ip已经在你主机列表那里给你写出来了的;)这里是访问不成功的(阿里云用外网访问,能成功,不需要做以下步骤)查了资料,说法是,CentOS7用的是Firewall-cmd,CentOS7之前用的是iptables防火墙;要想让外网能访问到apache主目录,就需要做以下的操作:firewall-cmd--permanent--zone=public--add-service=httpfirewall-cmd--permanent--zone=public--add-service=httpsfirewall-cmd--reload然后再访问外网ip,如果看到apache默认的页面--有Testing 123...字样,便是成功安装了apache服务了;

四、安装PHP1.安装yum-y install php2.重启apache服务systemctl restart httpd或者systemctl restart httpd.service然后,你可以写一个php文件在浏览器中运行一下了;eg:vi/var/www/html/info.phpi<?php phpinfo();?>Esc:wq然后,在自己电脑浏览器输入 192.168.1.1/info.php运行,会出现php的一些信息

五、安装MySQL我这里根据所学的那个教程,也安装了MariaDB1.安装

yum-y install mariadb*

2.开启MySQL服务systemctl start mariadb.service3.设置开机启动MySQL服务systemctl enable mariadb.service4.设置root帐户的密码mysql_secure_installation然后会出现一串东西,可以仔细读一下,如果你懒得读,就在提示出来的时候,按Enter就好了,让你设置密码的时候,你就输入你想要的密码就行,然后继续在让你选择y/n是,Enter就好了;当一切结束的时候,你可以输入mysql-uroot-p的方式,验证一下;

六、将PHP和MySQL关联起来yum search php,选择你需要的安装:yum-y install php-mysql

七、安装常用的PHP模块例如,GD库,curl,mbstring,...1.安装:yum-y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel2.重启apache服务systemctl restart httpd.service然后,再次在浏览器中运行info.php,你会看到安装的模块的信息;

至此,LAMP环境就搭建好了。

如何搭建lamp(CentOS7+Apache+MySQL+PHP)环境

标签:

如何在CentOS 7服务器上利用Apache安装并hpMyAdmin

在CentOS上安装phpMyAdmin,首先需要架设一台Web服务器(如Apache或nginx),安装好MySQL/MariaDB数据库和PHP。根据你的偏好和需求,你可以从LAMP和LEMP中选择一种安装。

另一个要求是允许在你的CentOS上安装EPEL库。在CentOS6或7上安装phpMyAdmin可以通过以下命令实现。在CentOS 7上:$ sudo yum install phpmyadmin。如果需要php-mcrypt扩展,可以使用:$ sudo yum install phpmyadmin php-mcrypt。

在CentOS 7上配置phpMyAdmin,其默认情况下只允许从回环地址(127.0.0.1)访问。为了能远程连接,需要改动它的配置文件。用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉带有"Require ip XXXX"字样的代码行。会有四处这样的代码行,用"Require all granted"取而代之。重新改动过的配置文件如下所示。$ sudo vi/etc/httpd/conf.d/phpMyAdmin.conf。

AddDefaultCharset UTF-8

# Apache 2.4

#Require ip 127.0.0.1

#Require ip::1

Require all granted

# Apache 2.2

Order Deny,Allow

Deny from All

Allow from 127.0.0.1

Allow from::1

# Apache 2.4

#Require ip 127.0.0.1

#Require ip::1

Require all granted

# Apache 2.2

Order Deny,Allow

Deny from All

Allow from 127.0.0.1

Allow from::1

最后,重启httpd使改动生效:$ sudo systemctl restart httpd。

在CentOS 6上配置phpMyAdmin,默认情况下是禁止从每个IP地址访问的。为了能远程连接,你需要改动它的配置。用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpmyadmin.conf),找出并注释掉"Deny from all"字样的代码行。然后把"Allow from 127.0.0.1"字样的代码行改成"Allow from 0.0.0.0"。重新改动过的配置文件如下所示。$ sudo vi/etc/httpd/conf.d/phpmyadmin.conf。

Order Deny,Allow

# Deny from all

Allow from 0.0.0.0

下一步是将phpMyAdmin的配置文件用blowfish加密工具加密。这一步需要加密cookie里的密码来作为基于cookie的部分认证。用文本编辑器打开如下路径所示的文件并且用blowfish设置一个随机密码,如下所示:$ sudo vi/usr/share/phpmyadmin/config.inc.php。

$cfg['blowfish_secret']='kd5G}d33aXDc50!';/* YOU MUST FILL IN THIS FOR COOKIE AUTH!*/

最后,重启httpd使改动生效:$ sudo service httpd restart(CentOS 6)或$ sudo systemctl restart httpd(CentOS 7)。

测试phpMyAdmin是否设置成功,访问这个页面:。你应该能通过Web界面来记录下任何MySQL用户(比如root)和管理MySQL/MariaDB的数据库/表。

疑难解答:在CentOS上安装phpMyAdmin的过程中遇到的一些问题解决方法。

当你在浏览器里尝试连接phpMyAdmin页面的时候,出现"403 Forbidding"错误:"You don't have permission to access/phpMyAdmin on this server."。这是因为phpMyAdmin默认阻止了IP地址远程连接。要修复这种错误,需要编辑它的配置文件来允许远程连接。具体操作见上述步骤。

当你连接phpMyAdmin页面时,出现"The configuration file now needs a secret passphrase(blowfish_secret)."信息,并且你无法登录。要修复这种错误,需要编辑/usr/share/phpmyadmin/config.inc.php这个文件来添加一个随机的blowfish密码,然后重启httpd,如下所示:$ sudo service httpd restart(CentOS 6)或$ sudo systemctl restart httpd(CentOS 7)。$cfg['blowfish_secret']='kd5G}d33aXDc50!';/* YOU MUST FILL IN THIS FOR COOKIE AUTH!*/

当你连接phpMyAdmin页面时,出现"Cannot load mcrypt extension. Please check your PHP configuration"错误信息。要修复这种错误,需要安装下面这个包,然后重启httpd:$ sudo yum install php-mcrypt。

如何在CentOS上安装phpMyAdmin

在CentOS上安装phpMyAdmin,你第一步需要架设一台Web服务器(如Apache或nginx),安装好MySQL/MariaDB数据库和PHP。根据你的偏好和需求,你可以从LAMP和LEMP中选择一种安装。

另一个要求是允许在你的CentOS上安装EPEL库。

在CentOS6或7上安装phpMyAdmin

一旦你设置了EPEL库,你就能轻松地用以下命令安装phpMyAdmin了。

在CentOS 7上:

$ sudo yum install phpmyadmin

在CentOS 7上:

$ sudo yum install phpmyadmin php-mcrypt

在CentOS 7上配置phpMyAdmin

默认情况下,CentOS 7上的phpMyAdmin只允许从回环地址(127.0.0.1)访问。为了能远程连接,你需要改动它的配置。

用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉带有"Require ip XXXX"字样的代码行。会有四处这样的代码行,用"Require all granted"取而代之。重新改动过的配置文件如下所示。

$ sudo vi/etc/httpd/conf.d/phpMyAdmin.conf

.....<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 Require all granted</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/setup/><IfModule mod_authz_core.c># Apache 2.4<RequireAny>#Require ip 127.0.0.1#Require ip::1 Require all granted</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>.....

最后,重启httpd使改动生效。

$ sudo systemctl restart httpd

在CentOS 6上配置phpMyAdmin

默认情况下,CentOS 6上的phpMyAdmin是禁止从每个IP地址访问的。为了能远程连接,你需要改动它的配置。

用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉"Deny from all"字样的代码行。然后把"Allow from 127.0.0.1"字样的代码行改成"Allow from 0.0.0.0"。重新改动过的配置文件如下所示。

$ sudo vi/etc/httpd/conf.d/phpmyadmin.conf

<Directory"/usr/share/phpmyadmin"> Order Deny,Allow# Deny from all Allow from 0.0.0.0</Directory>

下一步是将phpMyAdmin的配置文件用blowfish加密工具加密。这一步需要加密cookie里的密码来作为基于cookie的部分认证。

用文本编辑器打开如下路径所示的文件并且用blowfish设置一个随机密码,如下所示。

$ sudo vi/usr/share/phpmyadmin/config.inc.php

$cfg['blowfish_secret']='kd5G}d33aXDc50!';/* YOU MUST FILL IN THIS FOR COOKIE AUTH!*/

最后,重启httpd使改动生效。

$ sudo service httpd restart

测试phpMyAdmin

测试phpMyAdmin是否设置成功,访问这个页面:

你应该能通过Web界面来记录下任何MySQL用户(比如root)和管理MySQL/MariaDB的数据库/表。

疑难解答

这里有一些在CentOS上安装phpMyAdmin的过程中遇到的一些问题解决方法。

当你在浏览器里尝试连接phpMyAdmin页面的时候,你看到"403 Forbidding"错误:

You don't have permission to access/phpMyAdmin on this server.

发生这种错误是因为phpMyAdmin默认阻止了IP地址远程连接。要修复这种错误,你需要编辑它的配置文件来允许远程连接。具体操作见上。

当你连接phpMyAdmin页面时,你看见"The configuration file now needs a secret passphrase(blowfish_secret)."信息,并且你无法登录。

要修复这种错误,你需要编辑/usr/share/phpmyadmin/config.inc.php这个文件来添加一个随机的blowfish密码,然后重启httpd,如下所示。

$ sudo service httpd restart(CentOS 6)

$ sudo systemctl restart httpd(CentOS 7)

$cfg['blowfish_secret']='kd5G}d33aXDc50!';/* YOU MUST FILL IN THIS FOR COOKIE AUTH!*/

当你连接phpMyAdmin页面时,你看见"Cannot load mcrypt extension. Please check your PHP configuration"错误信息。

要修复这种错误,要安装下面这个包:

然后重启httpd:

$ sudo service httpd restart(CentOS 6)

$ sudo systemctl restart httpd(CentOS 7)

$ sudo yum install php-mcrypt

阅读剩余
THE END