阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

一。

安裝Apache

1.檢視yum源中apache版本

yum info httpd

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

2.安裝httpd

A。檢視是否安裝httpd程式包

rpm -qa | grep httpd

B。安裝httpd程式包

yum install httpd -y

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

cd /etc/httpd/conf

cp -p httpd。conf httpd。conf。bak

4。

修改httpd配置檔案

A。建立Web站點目錄

mkdir -p /home/www

B。編輯httpd配置檔案修改Web站點目錄

vi /etc/httpd/conf/httpd。conf

DocumentRoot “/var/www/html” 修改為 DocumentRoot “/home/www”

修改為

5。

啟動httpd服務

A。設定開機自動啟動httpd服務

chkconfig httpd on

B。啟動服務

service httpd start

6。

使用瀏覽器測試

http://xxx。224。239。xxx/

二。

安裝mysql5.6

1. 修改伺服器主機名及伺服器配置

(1。修改主機名配置檔案

vi /etc/hosts

(2。 修改網路主機配置檔案

vi /etc/sysconfig/network

(3。 重啟網路服務,重啟伺服器

hostname NAME

service network restart

reboot

(4。 關閉防火牆

iptables -nv -L

service iptables stop

(5。 關閉安全機制

vi /etc/selinux/config

SELINUX=disabled

2.安裝MYSQL前準備:

A。 下載前檢視Linux伺服器版本:

uname -a

Linux YPSG 2。6。32-696。3。2。el6。x86_64 #1 SMP Tue Jun 20 01:26:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

B。 下載mysql安裝包時,下載次版本為e16

RPM下載地址:

http://mirrors。sohu。com/mysql/MySQL-5。6/

https://dev。mysql。com/downloads/mysql/5。6。html#downloads

C。下載MYSQL軟體上傳至伺服器後解壓

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

3.

安裝

之前檢查

版本與解除安裝:

(1:檢查之前版本;

rpm -qa | grep -i mysql

(2:安裝MySQL-shared-compat替換mysql-libs,如果不替換,再刪除mysql-libs,會提示postfix依賴於mysql-libs:

yum -y remove mysql-libs*

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

4。

安裝mysql

A。安裝MySQL-shared-compat

rpm -ivh MySQL-shared-compat-5。6。36-1。e16。x86_64。rpm

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

B。安裝MySQL-server

rpm -ivh MySQL-server-5。6。36-1。el6。x86_64。rpm

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

C。安裝MySQL-client

rpm -ivh MySQL-client-5。6。36-1。el6。x86_64。rpm

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

D。安裝MySQL-devel

rpm -ivh MySQL-devel-5。6。36-1。el6。x86_64。rpm

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

5. 建立配置檔案位置

cp /usr/share/mysql/my-default。cnf /etc/my。cnf

6. * 初始化資料庫 *

/usr/bin/mysql_install_db

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

7.啟動資料庫

啟動資料庫服務:service mysql start

檢視資料庫服務:ps -ef |grep mysql

8.修改資料庫密碼

A。檢視資料庫預設密碼:cat /root/。mysql_secret

阿里雲Centos6.8安裝Apache2.2+mysql5.6+php5.6

B。預設密碼登入資料庫:mysql -u root -pVlUfoaEytLInXMZ0

C。修改資料庫登入密碼:

SET PASSWORD = PASSWORD(‘XXXXXX’);

flush privileges;

D。授權資料庫遠端訪問:

grant all privileges on *。* to root@‘%’ identified by ‘XXXXXX’ with grant option;

flush privileges;

exit;

9.設定開機自啟動

chkconfig mysql on

chkconfig ——list | grep mysql

10.重啟伺服器

reboot

11.設定阿里雲出入站規則

埠範圍:22/3389

12。

還原資料庫

A。建立目錄,上傳資料備份檔案

mkdir /databack

B。還原資料庫

mysql -u root -pXXXXXX

CREATE DATABASE XXX DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

use XXX;

source /databack/XXX。sql

exit

三. 安裝php5.6

1.檢視伺服器PHP安裝包

rpm -qa | grep php

2.

追加CentOS 6.

8

的epel及remi源

rpm -Uvh http://ftp。iij。ad。jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8。noarch。rpm

rpm -Uvh http://rpms。famillecollet。com/enterprise/remi-release-6。rpm

3。

檢視可安裝的

php5.6

yum list | grep php56

4.

安裝php5.6和相關的擴充套件

yum -y install php56。x86_64 php56-php。x86_64 php56-php-mysqlnd。x86_64 php56-php-gd。x86_64 php56-php-devel。x86_64 libjpeg* php56-php-ldap。x86_64 php56-php-odbc。x86_64 php56-php-opcache。x86_64 php56-php-pear。noarch php56-php-xml。x86_64 php56-php-xmlrpc。x86_64 php56-php-mbstring。x86_64 php56-php-bcmath。x86_64 php-mhash php56-php-pecl-memcache。x86_64 php56-php-pecl-memcached。x86_64 php56-php-pecl-radius。x86_64 php56-php-mcrypt。x86_64 php56-php-pecl-igbinary。x86_64 php56-php-process。x86_64

5. 檢視PHP安裝情況

rpm -qa | grep php

6.重啟apache服務

service httpd restart

7。

安裝測試是否成功

A.建立編寫phpinfo檔案

cd /home/www

vi phpinfo。php

<?php

phpinfo();

?>

B.在瀏覽器測試檢視

http://XXX。224。239。XXX/phpinfo。php

8。

web程式訪問

A.使用CRT上傳WEB站點檔案

cd /home/www

lcd D:\qyweb

put ypsg.zip

B.解壓WEB站點檔案

yum install -y unzip zip

unzip ypsg

C.復權訪問WEB站點檔案

chmod -R 775 /home/www/ypsg

D.修改web訪問配置檔案

vi /etc/httpd/conf/httpd。conf

ServerAdmin webmaster@dummy-host。example。com

DocumentRoot /home/www/XXX

ServerName www。xxx。org。cn

# ErrorLog logs/dummy-host。example。com-error_log

# CustomLog logs/dummy-host。example。com-access_log common

E.重啟apache

service httpd restart

* 最近很多事情耽擱了寫作,今天放點乾貨,希望能夠幫助到正在學習資料庫的同學。