在CenterOS 6.5上安裝Apache mysql php

來源:互聯網
上載者:User

標籤:

在CenterOS 6.5 64位上配置LAMP環境,前提條件是要關閉防火牆
一、準備工作
1.檢查系統更新

yum update

2.編譯環境的安裝

yum -y install gcc  gcc  gcc-c 

3.需要將內建的httpd給卸載掉

yum erase httpd

4.安裝zlib-devel libtool ncurses-devel libxml2-devel

yum install zlib-devel libtool ncurses-devel libxml2-devel

二、安裝 MySQL
1.直接進行MySQL安裝

[root@localhost ~]# yum install mysql mysql-server

2.安裝完後,讓MySQL隨系統啟動

[root@localhost ~]# chkconfig --levels 235 mysqld on[root@localhost ~]# /etc/init.d/mysqld start

3.設定MySQL的密碼

[root@localhost ~]# mysql_secure_installation

當出現如下提示時候直接按斷行符號:

Enter current password for root

出現如下再次斷行符號

Set root password? [Y/n]

接下來,輸入密碼後,按斷行符號鍵

New password:

接下來的四個選擇項,全部按斷行符號

Remove anonymous users? [Y/n]Disallow root login remotely? [Y/n]Remove test database and access to it? [Y/n]Reload privilege tables now? [Y/n]

4.重啟MySQL

/etc/init.d/mysqld restart #重啟/etc/init.d/mysqld stop #停止/etc/init.d/mysqld start #啟動

三、安裝 Apache
1.由於 CentOS 已經封裝了 Apache,直接運行安裝

[root@localhost ~]# yum install httpd

2.同樣配置系統讓 Apache 隨系統啟動:

[root@localhost ~]# chkconfig --levels 235 httpd on

3.啟動Apache

[root@localhost ~]# /etc/init.d/httpd start

如果在啟動過程中出現

[[email protected] ~]# Starting httpd: httpd: Could not reliably determine the server‘s fully qualified domain name, using payment.meijialclub.com for ServerName [  OK  ]

那就修改一下httpd.conf,其實不修改也無所謂

4.配置完畢,啟動 Apache:

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf

找到#ServerName www.example.com:80然後在下面加入如下

ServerName 127.0.0.1:80

5.重啟apache

/etc/init.d/httpd restart

6.此時apache已經安裝好了,訪問你的ip地址(伺服器位址)就ok了
四、安裝php

1.安裝 PHP

[root@localhost ~]# yum install php

2.重啟Apache

[root@localhost ~]# /etc/init.d/httpd restart

四、測試 PHP 相關資訊
你可以建立一個 PHP 頁面進行測試,使用 vim 編輯器建立:

[root@localhost ~]# vi /var/www/html/test.php

按 “i” 鍵進行編輯,輸入:

<?php   echo "test";    ?>

在按:wq退出
最後在瀏覽器上輸入

你的ip/test.php

如果看到測試頁面就成功了

在CenterOS 6.5上安裝Apache mysql php

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.