centos 6 lamp,centos官网
老铁们,大家好,相信还有很多朋友对于centos 6 lamp和centos官网的相关问题不太懂,没关系,今天就由我来为大家分享分享centos 6 lamp以及centos官网的问题,文章篇幅可能偏长,希望可以帮助到大家,下面一起来看看吧!
如何在CentOS6下实现Apache+PHP+MySQL的快速安装
LAMP是一个免费、开源的解决方案,代表了Linux、Apache、MySQL、PHP,主要用作建立可行的通用的web服务器。那么如何在CentOS6下实现安装Apache+php+Mysql的快速安装?其具体安装配置步骤可以如下进行:
1.准备工作
使用yum进行安装,为了提高速度,最好先是修改为中国CentOS镜像服务器。目前国内有三个镜像可以选择,分别是:中国科学技术大学、163和Sohu的镜像,建议教育网用户选择中科大,电信用户选择163,他们的repo文件本博客作了备份如下:
下面命令是备份CentOS-Base.repo文件,并修改使用163镜像作为yum源:
mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.save
wget
mv CentOS6-Base-163.repo/etc/yum.repos.d/CentOS-Base.repo
2.更新系统内核
yum-y update
3.安装Apahce、Mysql、PHP
yum-y install httpd php mysql mysql-server
默认情况下,mysql数据目录位于/var/lib/mysql
4.安装相关组件:
yum install php-mysql php-gd php-imap php-ldap php-odbc
php-pear php-xml php-xmlrpc
5.安装MySQL管理工具phpMyAdmin
yum-y install phpMyAdmin
6.配置Apache随系统启动
chkconfig--levels 235 httpd on
/etc/init.d/httpd start
7.配置MySQL随系统启动
chkconfig--levels 235 mysqld on
/etc/init.d/mysqld start
8.设置数据库root密码
/usr/bin/mysqladmin-u root password'New+Password#www.yupengyan.com'
9.测试PHP是否安装成功
在 CentOS中 Apache的默认根目录是/var/www/html,配置文件/etc/httpd/conf/httpd.conf。其他配置存储在/etc/httpd/conf.d/目录。
如何在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
求大神指导Centos7 源码编译安装Nginx+PHP 配置动静分离
这个是我的服务的实际将配置Nginx实现动静分离,对php页面的请求转发给LAMP处理,而静态页面交给Nginx,以实现动静分离。客户请求静态数据给Nginx,Nginx直接应答客户端,当请求动态数据到Nginx时,Nginx让客户端去找LAMP,通过代理的方式,LAMP就和客户端连接了。分别配置动态分离和静态分离
(1)架设并调试后端LAMP架构,指定的域名,IP地址为xxxx,创建动态页面test.php。
(2)配置Nginx(xxxx)处理动态页面请求,并把域名改为 chaodiquan.com在server{};段中加入以下代码,检测语法后,重启Nginx
(3)客户端输入xxxx/test.php成功后动态分离就实现了,接下来再配置静态分离
(4)配置Nginx处理静态页面请求,在server{};中加入以下代码,检测语法后,重启Nginx
location~.*\.(gif|jpg|jpeg|bmp|swf)${#这段代码意思是任意网址以这5种格式为结尾就到Nginx根目录下的html文件夹寻找资源
root html;
expires 1d;#缓存一天}
(5)在nginx的html目录中,放入图片aa.jpg,然后在apache的动态测试页test.php中添加
<html>
<body>
<img src="aaaa/aa.jpg">
</body>
</html>
(6)客户端输入xxxx/test.php测试,由于test.php是动态页面,因此客户端会找到LAMP架构中的Apache,然后调取图片aa.jpg是静态数据,所以从Nginx提取,最后反馈给客户端。这个是