CentOS — 搭建 LAMP 運行環境 & Webmin

來源:互聯網
上載者:User

以 CentOS 5.8 32位的系統為例。 

安裝 CentOS RPM 簽署金鑰

你須要安裝 CentOS RPM 簽署金鑰。基於安全理由,這個金鑰在基本系統安裝時不會被安裝。如此你就可以在核實金鑰的真確性後才將它安裝在你的系統上。RPM 有能力從一個 CentOS 鏡像中取得金鑰:參考:我可以從哪裡取得 CentOS 的組件簽署金鑰?

rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

 

添加外部源

因為系統基本的源的MySQL和PHP程式比較舊,所以我們添加比較新的外部源。

vi /etc/yum.repos.d/CentOS-Base.repo

在底部增加下面資訊:

[utterramblings]name=Jason's Utter Ramblings Repobaseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/enabled=1gpgcheck=1gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

 

安裝 Apache

預設CentOS都安裝了Apache,你可以通過在終端輸入如下命令來啟動Apache伺服器:

apachectl start

啟動,停止,重啟的命令如下:

apachectl startapachectl stopapachectl restart

預設設定檔的路徑在:

/etc/httpd/conf/httpd.conf

預設的網頁檔案的存放路徑在:

/var/www/html/

* 如果您的Server沒有安裝Apache,那麼請參考以下命令安裝Apache

yum install httpdchkconfig --levels 235 httpd on/etc/init.d/httpd start

 

安裝 MySQL

執行yum程式安裝MySQL

yum install mysql mysql-server

添加MySQL進啟動項(這樣系統啟動時會自動啟動MySQL),並立即啟動MySQL伺服器:

chkconfig --levels 235 mysqld on/etc/init.d/mysqld start

設定MySQL root帳號密碼:

mysql_secure_installation

Shell互動:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!  In order to log into MySQL to secure it, we'll need the currentpassword for the root user.  If you've just installed MySQL, andyou haven't set the root password yet, the password will be blank,so you should just press enter here. 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 MySQLroot user without the proper authorisation. Set root password? [Y/n] <-- ENTERNew password: <-- 你的MySQL root密碼Re-enter new password: <-- 你的MySQL root密碼Password updated successfully!Reloading privilege tables.. ... Success!  By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment. Remove anonymous users? [Y/n] Y<-- ENTER #刪除匿名使用者? ... Success! Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n<-- ENTER #不允許遠端連線? ... Success! By default, MySQL comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment. Remove test database and access to it? [Y/n] Y<-- ENTER #刪除測試資料庫? - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so farwill take effect immediately. Reload privilege tables now? [Y/n] Y<-- ENTER #立刻重新整理許可權表? ... Success! Cleaning up...   All done!  If you've completed all of the above steps, your MySQLinstallation should now be secure. Thanks for using MySQL!

 這裡我設定了允許MySQL遠端連線,所以需要重啟MySQL伺服器:

/etc/init.d/mysqld restart

 MySQL預設的設定檔路徑為

/etc/my.cnf

 

安裝 PHP

我們可以按照下面的命令安裝PHP和Apache PHP模組:

yum install php

安裝相關模組使用PHP支援MySQL:為了讓PHP支援MySQL,我們可以安裝php-mysql軟體包;你也可以安裝其它的php模組;

可以使用以下命令搜尋可用的php模組:

yum search php

選擇一些你需要的模組進行安裝:

yum install php-mysql php-common php-mbstring php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pdo php-mcrypt

現在重啟Apache:

apachectl restart

 

安裝 Webmin

Webmin是目前功能最強大的基於Web的Unix系統管理工具。管理員通過瀏覽器訪問Webmin的各種管理功能並完成相應的管理動作。

下載Webmin RPM包

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.580-1.noarch.rpm

請到官網查看是否是最新版本的連結。Webmin Download

安裝Webmin

rpm -U webmin-1.550-1.noarch.rpm

* 在我的機器上出現了如下的錯誤:

Header V3 DSA signature: NOKEY, key ID 11f63c51

解決辦法如下:可參考 linux Header V3 DSA signature: NOKEY, key ID 錯誤解決方案

rpm --import /etc/pki/rpm-gpg/RPM*rpm -U webmin-1.550-1.noarch.rpm

在終端命令列下啟動Webmin

/etc/rc.d/init.d/webmin start

通過瀏覽器訪問Webmin,假設您的Ip地址為:192.168.100.100,那麼訪問Webmin的URL為 http://192.168.100.100:10000,使用者名稱為 root, 密碼為 root 的密碼。

 

參考:

CentOS 5.x yum安裝LAMP(Apache+MySQL+PHP) 

CentOS 5安裝免費主機控制台Webmin

linux Header V3 DSA signature: NOKEY, key ID 錯誤解決方案

Centos下webmin安裝

 

 

到這裡就完成了 LAMP 運行環境的搭建。對於MySQL的備份,請參考 CentOS — MySQL備份 Shell 指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.