日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發(fā)布時(shí)間:2023/12/2 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS 6下搭建Apache+MySQL+PHP+SSL 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

網(wǎng)上的一些文章都已經(jīng)比較老了,現(xiàn)在版本高了之后,其實(shí)配置是很省力的(不考慮什么負(fù)載的話)

分享全過程,出了文中提到的安裝epel rpmfushion 源指令不同外,其他的過程也適用與Centos 5

1.安裝CentOS 6 ,可以選擇最小安裝,也可以安裝桌面

2.升級(jí)系統(tǒng)

yum update

3.安裝mysql,并設(shè)置mysql開機(jī)自啟動(dòng),同時(shí)啟動(dòng)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]

(是否移出數(shù)據(jù)庫的默認(rèn)帳戶,如果移出,那么在終端中直接輸入mysql是會(huì)提示連接錯(cuò)誤的)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的遠(yuǎn)程登錄)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,并設(shè)置開機(jī)啟動(dòng)

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

這時(shí)候可以測試apache是否正常工作

直接瀏覽器訪問localhost應(yīng)該沒問題,但是如果別的機(jī)子訪問不了的話,是因?yàn)榉阑饓Φ年P(guān)系,配置防火墻

(后面的ssl還會(huì)有這個(gè)問題的)

6.安裝php

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

這個(gè)時(shí)候php就安裝完成拉,寫個(gè)腳本測試一下

vi /var/www/html/info.php

輸入

<?php phpinfo();?>

訪問localhost/info.php即可~

7.安裝phpMyAdmin

首先先給系統(tǒng)安裝epel 和rpmfushion兩個(gè)軟件大倉庫

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 的話執(zhí)行下面

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

安裝完成后還需要配置一下訪問權(quán)限,使得出了本機(jī)外,其他機(jī)子也能訪問phpMyAdmin

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

找到兩個(gè)directory的權(quán)限設(shè)置,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>

重啟服務(wù)器

service httpd restart

測試localhost/phpMyAdmin

用戶名密碼:root 123456

OK~ LAMP搭建完畢,

8.搭建SSL,讓apache支持https

yum install mod_ssl

其實(shí)安裝完這個(gè)模塊后,重啟完apache 就可以用https://localhost測試了,因?yàn)樗麆?chuàng)建了默認(rèn)的證書

在/etc/pki/tls下

當(dāng)然我們也可以用openssl創(chuàng)建自己的證書

yum install openssl

生成證書文件
創(chuàng)建一個(gè)rsa私鑰,文件名為server.key

openssl genrsa -out server.key 1024


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


用 server.key 生成證書簽署請(qǐng)求 CSR

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

Country Name:兩個(gè)字母的國家代號(hào)
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

一切都搞定拉~~

整個(gè)過程我們不需要修改/etc/httpd/conf/httpd.conf 這就是版本高了的好處阿~

轉(zhuǎn)載于:https://www.cnblogs.com/cryinstall/archive/2011/09/25/2189900.html

總結(jié)

以上是生活随笔為你收集整理的CentOS 6下搭建Apache+MySQL+PHP+SSL的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。