CentOS 6下搭建Apache+MySQL+PHP+SSL

网上的一些文章都已经比较老了,现在版本高了之后,其实配置是很省力的(不考虑什么负载的话)

分享全过程,出了文中提到的安装epel rpmfushion 源指令不同外,其他的过程也适用与Centos 5

1.安装CentOS 6 ,可以选择最小安装,也可以安装桌面

2.升级系统

yum update

3.安装mysql,并设置mysql开机自启动,同时启动mysql

yum install mysql
yum install mysql-server
chkconfig --levels 35 mysqld on
service mysqld start

4.配置mysql的root密码

mysql_secure_installation


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 MySQL
root user without the proper authorisation.

Set root password? [Y/n] (Y)

New password: (123456)
Re-enter new password: (123456)
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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]

(是否移出数据库的默认帐户,如果移出,那么在终端中直接输入mysql是会提示连接错误的)Y

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]

(是否禁止root的远程登录)Y
By default, MySQL 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
Reload privilege tables now? [Y/n] Y

5.安装apache,并设置开机启动

yum install httpd
chkconfig --levels 35 httpd on
service httpd start

这时候可以测试apache是否正常工作

直接浏览器访问localhost应该没问题,但是如果别的机子访问不了的话,是因为防火墙的关系,配置防火墙

(后面的ssl还会有这个问题的)

6.安装php

yum install phpyum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

这个时候php就安装完成拉,写个脚本测试一下

vi /var/www/html/info.php

输入

<?php
phpinfo();?>

访问localhost/info.php即可~

7.安装phpMyAdmin

首先先给系统安装epel 和rpmfushion两个软件大仓库

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/6/i386/rpmfusion-free-release-6-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/6/i386/rpmfusion-nonfree-release-6-0.1.noarch.rpm

如果是centos 5 的话执行下面

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/5/i386/rpmfusion-free-release-5-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/5/i386/rpmfusion-nonfree-release-5-0.1.noarch.rpm

接着安装起来就很方便拉,~根本不需要去下载就可以获得最新的版本

yum install phpmyadmin

安装完成后还需要配置一下访问权限,使得出了本机外,其他机子也能访问phpMyAdmin

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

找到两个directory的权限设置,Allow from 改成All

<Directory /usr/share/phpMyAdmin/>
   Order Deny,Allow
   Deny from All
   Allow from 127.0.0.1
   Allow from All
</Directory>
<Directory /usr/share/phpMyAdmin/setup/>
   Order Deny,Allow
   Deny from All
   Allow from 127.0.0.1
   Allow from All
</Directory>

重启服务器

service httpd restart

测试localhost/phpMyAdmin

用户名密码:root 123456

OK~ LAMP搭建完毕,

8.搭建SSL,让apache支持https

yum install mod_ssl

其实安装完这个模块后,重启完apache 就可以用https://localhost测试了,因为他创建了默认的证书

在/etc/pki/tls下

当然我们也可以用openssl创建自己的证书

yum install openssl

生成证书文件
创建一个rsa私钥,文件名为server.key

openssl genrsa -out server.key 1024


Generating RSA private key, 1024 bit long modulus
............++++++
............++++++
e is 65537 (0x10001)


用 server.key 生成证书签署请求 CSR

openssl req -new -key server.key -out server.csr

Country Name:两个字母的国家代号
State or Province Name:省份名称
Locality Name:城市名称
Organization Name:公司名称
Organizational Unit Name:部门名称
Common Name:你的姓名
Email Address:地址
至于 'extra' attributes 不用输入.直接回车

生成证书CRT文件server.crt。

openssl x509 -days 365 -req -in server.csr -signkey server.key -out server.crt

修改ssl.conf指定我们自己生成的证书

vi /etc/httpd/conf.d/ssl.conf

找到如下位置,修改路径

#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/localhost.crt

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

OK

service httpd restart

一切都搞定拉~~

整个过程我们不需要修改/etc/httpd/conf/httpd.conf 这就是版本高了的好处阿~

转载于:https://www.cnblogs.com/cryinstall/archive/2011/09/25/2189900.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/361973.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

通过设计国际象棋游戏来了解策略模式

今天&#xff0c;我们将借助一个示例来尝试了解策略模式。 我们将考虑的示例是国际象棋游戏。 这里的目的是解释策略模式&#xff0c;而不是构建全面的国际象棋游戏解决方案。 策略模式&#xff1a;策略模式被称为行为模式-用于管理对象之间的算法&#xff0c;关系和职责。 策…

vs2010 问题 LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏

vs2010 问题 LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 在安装 VS2010 后&#xff0c;再安装 VS2012 VS2015 等&#xff0c;原来的 .NET 4.0 会被替换为 .NET 4.5。不会恢复 .NET 4.0 。这时&#xff0c;VS2010的 cvtres.exe 就无法使用了。如果 PATH…

Nginx 使用try_files遇到的问题

背景&#xff1a; root /some/path; location / {try_files $uri $uri/ /dist/index.html; }使用React之类的的库来开发前端页面的时候&#xff0c;因为是单页应用所以需要上面的Nginx配置&#xff0c;用来在找不到html文件的时候内部重定向到/dist/index.html文件。 服务器上…

群发邮件

最近&#xff0c;通过两周的学习&#xff0c;对.net 的基础知识有了进一步的了解。觉得自己可以写个小程序了。于是花了两天时间写了一个 群发邮件的一个WinForm小程序。自己在这里小秀一下&#xff0c;表扬及鼓励一下自己。哈哈&#xff01; 此小程序在发送邮件的基础上还添加…

深入研究ES6 Generators

ES6 Generators系列&#xff1a; ES6 Generators基本概念深入研究ES6 GeneratorsES6 Generators的异步应用ES6 Generators并发 如果你还不知道什么是ES6 generators&#xff0c;请看我的前一篇文章“ES6 Generators基本概念” 。如果你已经对它有所了解&#xff0c;本文将带你…

在JavaEE中使用CDI的简单面向方面的编程(AOP)

我们编写满足特定业务逻辑的服务API。 涵盖所有服务API&#xff08;如安全性&#xff0c;日志记录&#xff0c;审核&#xff0c;度量延迟等&#xff09;的跨领域问题很少。 这是一个重复的非业务代码&#xff0c;可以在其他方法之间重用。 重用的一种方法是将这些重复的代码移入…

sessionStorage什么时候失效

最近在调试程序的时候无意间看到 cookie 的过期时间是 session&#xff0c;这个 session 表示的是什么时候过期&#xff1f;牵扯出来另一个存储方案 sessionStorage 存储的数据又是什么时候过期呢&#xff1f; 在查找相关资料的时候总会看到会话结束的时候 cookie 会被清除&am…

ES6 解构赋值详解

解构赋值是对赋值运算符的扩展&#xff0c;可以将属性/值从对象/数组中取出&#xff0c;赋值给其他变量。 一、数组的解构赋值 1、基本用法 只要等号两边的模式相同&#xff0c;左边的变量就会被赋予对应的值。 let [a, [[b], c]] [1, [[2], 3]]; a // 1 b // 2 c // 3 let [a…

软件著作权申请流程

一、填写计算机软件著作权登记申请表&#xff08;表格1份&#xff09;包括软件全称、简称、版本号、开发完成日期、软件开发情况&#xff08;独立开发、合作开发、委托开发、下达任务开发&#xff09;、原始取得权利情况、继受取得权利情况、权利范围、软件用途和技术特点&…

Npm install failed with “cannot run in wd”

Linux环境下&#xff0c;root账户&#xff0c;安装某些npm包的时候报下面的错误&#xff0c;例如安装grunt-contrib-imagemin时&#xff1a; Error: EACCES, mkdir /usr/local/lib/node_modules/coffee-scriptnpm ERR! { [Error: EACCES, mkdir /usr/local/lib/node_modules/c…

Java EE 7 Batch中传递属性/参数的2种方式

对于Java EE 7批处理工具&#xff0c;有两种将属性/参数传递给块和批处理的方法。 本快速指南向您展示了两种方式&#xff0c;在开发批处理Java EE 7方式时可能会经常使用它们。 1.运行前预定义的属性/参数 预定义属性是您在部署应用程序之前定义的属性&#xff08;名称/值对&…

Csharp 打印Word文件默認打印機或選擇打印機設置代碼

//打印文檔object nullobj Missing.Value;//aDoc wordApp.Documents.Open(ref file,// ref nullobj, ref nullobj, ref nullobj,// ref nullobj, ref nullobj, ref nullobj,// ref nullob…

ESLint共享配置的两种方式eslint-plugin和eslint-config

使用ESLint很久了&#xff0c;也看了ESLint官方文档很多遍&#xff0c;但对于ESLint配置的规则还是不胜清楚&#xff0c;例如&#xff1a; {"extends": ["plugin:prettier/recommended"] }上面extends的值为什么要"plugin:"开头&#xff1f;这里…

使用aggregate在MongoDB中查找重复的数据记录

我们知道&#xff0c;MongoDB属于文档型数据库&#xff0c;其存储的文档类型都是JSON对象。正是由于这一特性&#xff0c;我们在Node.js中会经常使用MongoDB进行数据的存取。但由于Node.js是异步执行的&#xff0c;这就导致我们无法保证每一次的数据库save操作都是原子型的。也…

Gradle入门:创建二进制分发

创建有用的应用程序之后&#xff0c;很可能我们想与其他人共享它。 一种方法是创建一个可以从我们的网站下载的二进制发行版。 这篇博客文章描述了如何满足以下要求的二进制发行版&#xff1a; 我们的二进制分发绝对不能使用所谓的“胖子”方法。 换句话说&#xff0c;我们的…

我的Google Adsense帐户被关

一、 上周四&#xff0c;我收到Google的邮件&#xff0c;宣布关闭我的Adsense帐户。 "您好&#xff01; 查看了相关记录后&#xff0c;我们确认您的 AdSense 帐户存在引起无效活动的风险。保护 AdWords 广告客户&#xff0c;使其免受无效活动的侵害是我们的责任&#xff0…

网格布局之网格元素放置算法

接下来的网格元素放置算法将网格元素的自动位置解析为确定位置&#xff0c;确保每个网格元素具有布局明确的网格区域。&#xff08;Grid spans 不需要特别的解析&#xff1b;如果没有明确指定&#xff0c;默认是1&#xff09; 注意&#xff1a;当显式网格中没有位置放置自动放置…

csharp: ODP.NET,System.Data.OracleClient(.net 4.0) and System.Data.OleDb读取Oracle g 11.2.0的区别...

ODP.NET: 引用&#xff1a; using Oracle.DataAccess; //Oracle g 11.2.0 using Oracle.DataAccess.Client; using Oracle.DataAccess.Types; //下载 http://www.oracle.com/technetwork/topics/dotnet/downloads/net-downloads-160392.html //引用&#xff1a;D:\app\geovindu…

AngularJS快速入门指南15:API

API即Application Programming Interface&#xff08;应用程序接口&#xff09;。 AngularJS全局API AngularJS全局API是一组全局JavaScript函数&#xff0c;用来进行一些常用的操作&#xff0c;例如&#xff1a; 比较两个对象迭代对象进行数据格式转换 全局API函数可以通过an…

Java 9幕后花絮:新功能从何而来?

找出Java幕后发生的事情&#xff0c;以及新功能如何实现 在上一篇文章中&#xff0c;我们介绍了即将发布的Java 9版本的新功能和尚待解决的功能&#xff0c;并简要提到了将新功能添加到下一个版本之前要经历的过程。 由于此过程几乎影响了所有Java开发人员&#xff0c;但大多数…