CentOS 6下搭建Apache+MySQL+PHP+SSL
2014-03-28 13:19
375 查看
1.安装CentOS 6 ,可以选择最小安装,也可以安装桌面
2.升级系统
3.安装mysql,并设置mysql开机自启动,同时启动mysql
4.配置mysql的root密码
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,并设置开机启动
这时候可以测试apache是否正常工作
直接浏览器访问localhost应该没问题,但是如果别的机子访问不了的话,是因为防火墙的关系,配置防火墙
(后面的ssl还会有这个问题的)
6.安装php
这个时候php就安装完成拉,写个脚本测试一下
输入
访问localhost/info.php即可~
7.安装phpMyAdmin
首先先给系统安装epel 和rpmfushion两个软件大仓库
如果是centos 5 的话执行下面
接着安装起来就很方便拉,~根本不需要去下载就可以获得最新的版本
安装完成后还需要配置一下访问权限,使得出了本机外,其他机子也能访问phpMyAdmin
找到两个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>
重启服务器
测试localhost/phpMyAdmin
用户名密码:root 123456
OK~ LAMP搭建完毕,
8.搭建SSL,让apache支持https
其实安装完这个模块后,重启完apache 就可以用https://localhost测试了,因为他创建了默认的证书
在/etc/pki/tls下
当然我们也可以用openssl创建自己的证书
生成证书文件
创建一个rsa私钥,文件名为server.key
Generating RSA private key, 1024 bit long modulus
............++++++
............++++++
e is 65537 (0x10001)
用 server.key 生成证书签署请求 CSR
Country Name:两个字母的国家代号
State or Province Name:省份名称
Locality Name:城市名称
Organization Name:公司名称
Organizational Unit Name:部门名称
Common Name:你的姓名
Email Address:地址
至于 'extra' attributes 不用输入.直接回车
生成证书CRT文件server.crt。
修改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
2.升级系统
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,并设置开机启动
直接浏览器访问localhost应该没问题,但是如果别的机子访问不了的话,是因为防火墙的关系,配置防火墙
(后面的ssl还会有这个问题的)
6.安装php
7.安装phpMyAdmin
首先先给系统安装epel 和rpmfushion两个软件大仓库
<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>
重启服务器
用户名密码:root 123456
OK~ LAMP搭建完毕,
8.搭建SSL,让apache支持https
在/etc/pki/tls下
当然我们也可以用openssl创建自己的证书
创建一个rsa私钥,文件名为server.key
............++++++
............++++++
e is 65537 (0x10001)
用 server.key 生成证书签署请求 CSR
State or Province Name:省份名称
Locality Name:城市名称
Organization Name:公司名称
Organizational Unit Name:部门名称
Common Name:你的姓名
Email Address:地址
至于 'extra' attributes 不用输入.直接回车
生成证书CRT文件server.crt。
# 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
warn _default_ virtualhost overlap on port 443 the first has precedence centos
echo "NameVirtualHost *:443" >> /etc/httpd/conf/httpd.conf
相关文章推荐
- CentOS 6下搭建Apache+MySQL+PHP+SSL
- 快速在CentOS下搭建LAMP(Apache、MySQL、PHP)环境
- centos安装搭建apache+mysql+php
- CentOS6.5使用yum快速搭建LAMP(Linux+Apache+MySQL+PHP)环境
- Linux:Linux操作系统Centos7.2版本搭建Apache+PHP+Mysql环境
- centos php+mysql+apache环境搭建
- CentOS 7 搭建 Apache+MySQL+PHP
- 飞飞实验室:CentOS 5.3快速搭建Apache+PHP5+MySQL完美Web服务器(LAMP)
- Linux操作系统Centos7.2版本搭建Apache+PHP+Mysql环境
- Centos 6安装完美搭建mysql、php、apache之旅
- Centos 7.2 搭建Apache+PHP+Mysql环境
- CentOS5.3搭建LAMP(Linux, Apache, MySQL, PHP)Web服务器
- centos6.4搭建apache+mysql+php环境
- centos6.4搭建apache+mysql+php环境
- centos下lamp(linux+apache+mysql+php)的搭建
- 如何在服务器上搭建一个lamp(Linux(CentOS7)+Apache+MySQL+PHP)环境
- centos6.4搭建apache+mysql+php环境
- 应用体验 CentOS 6.2下搭建Web服务器(apache+mysql+php)
- centos LAMP第一部分-环境搭建 Linux软件删除方式,mysql安装,apache,PHP,apache和php结合,phpinfo页面,ldd命令 第十九节课
- centos lamp 环境搭建 Linux+Apache+Mysql/MariaDB+Perl/PHP/Python