centos5.1最小化安裝+apache+php+mysql+gd+zend+phpmyadmin
把我這10天的筆記總結到一個文檔里,這次centos5.1是採用最小化的安裝,全部的軟體都是採用編譯安裝,軟體基本都是最新版本。整個編譯的過程,我都重複了不下10次。應該是沒有問題的,改天我再按照我自己的文檔,從新來一次。
我的筆記本只有512m內存,給了vm160m內存,在這種惡劣的情況下完成這個的。
參考了無數的同類文章,cu的web的精華帖幾乎都翻遍了。謝謝各位前輩朋友,現在真的很方便了,編譯出什麼錯誤,到網上基本都能找到,很難想象,沒有搜索,怎麼辦
1 安裝
1.1 CentOS5.1
• 所有需要安裝的包都放在/usr/src下,解壓也是解壓在/usr/src下。
• 所有的軟體都是安裝在/usr/local下。
1.2 基本信息
• vmware workstation 6.2
• 創建一個redhat as 5.0 vm
• 8g硬碟,160m內存,去掉音效卡,軟碟機
• ip:192.168.1.168
• 掩碼:255.255.255.0
• 網關:192.168.1.1
• dns:192.168.1.1
• hostname:centos
1.3 最小化安裝
通過命令行的方式進行安裝,所有的選擇都是採用預設的,
時區選擇:中國
語言:英語
安裝了342個包,佔用空間是536m,不選擇任何組件
1.4 分區
/swap:320
/ :全部空間
2 基本命令使用
2.1 VI
進入編輯狀態:i
退出編輯狀態:Esc
到第一行:gg
到最後一行:G
到某一行:xxG
到行首:0
到行末:$
複製:yy
貼上:p
復原:u
刪整行:dd
刪除全部內容:dG
顯示行數::set nu
不顯示行數::set nonu
搜尋:/、再次搜尋:n
儲存::w
離開::q
儲存兼離開::wq 或 shift+zz
強制離開(不儲存)::q!
2.2 yum
更新:yum update
安裝:yum install xxx
移除:yum remove xxx
清除已經安裝過的檔案(/var/cache/yum/):yum clean all
搜尋:yum search xxx
列出所有檔案:yum list
查詢檔案訊息:yum info xxx
群組安裝功能:
yum grouplist
yum groupinstall "Web Server"
2.3 rpm
安裝:rpm -ivh xxx
移除:rpm -e xxx
升級:rpm -Uvh xxx
查詢:
查詢所有安裝的包: rpm -qa
查詢某個包:rpm -qa | grep xxx
rpm -qi xxx
查詢軟體的安裝路徑:rpm -ql xxx
rpm -qc xxx
查詢某個文件是那個rpm包產生:rpm -qf /etc/yum.conf
rpm -qpi xxx
2.4 chkconfig
查看所有服務:chkconfig --list
查看3啟動的狀態:chkconfig --list | grep 3:on
把某些服務設置為啟動:chkconfig --level 345 xxx on
把某些服務設置當前啟動:chkconfig xxx on
列出某項服務:chkconfig --list xxx
2.5 查看系統狀態
查看系統使用字符集:echo $LANG $LANGUAGE
環境變數:set
2.6 解壓
如果是以gz結尾的如:test.tar.gz
tar zxvf test.tar.gz
如果是以bz或bz2結尾如:test.tar.bz2
tar jxvf test.tar.bz2
2.7 基本信息查看和修改
查看 IP:ifconfig
修改 IP:
運行命令:system-config-network-tui
或修改:/etc/sysconfig/network-scripts/ifcfg-eth0
FQDN 設定:
hostname
more /etc/hosts
more /etc/sysconfig/network
修改計算機名字
1:vi /etc/sysconfig/network
2:vi /etc/hosts
如果通過
hostname xxx
來修改計算機名字,則重新啟動后就不起作用
DNS 設定:
vi /etc/resolv.conf
nameserver 192.168.1.1
nameserver 202.106.195.68
重新啟動網卡:
/etc/rc.d/init.d/network restart
3 登陸後設置
3.1 關閉selinux
1:運行命令setup,可以在圖形化界面進行關閉
2:vi /etc/sysconfig/selinux
SELINUX=enforcing 改成--> SELINUX=disabled
3.2 關閉不需要服務
1:運行命令setup
2:運行命令ntsysv
只啟用下面9個服務(autofs是為了方便使用光碟機,其實可以不啟用這個服務)
acpid
anacron
autofs
cpuspeed
crond
network
sshd
syslog
yum-updatesd
3.3 配置ssh
修改兩個地方
vi /etc/ssh/sshd.config
#PermitRootLogin yes 改為
PermitRootLogin yes
#UseDNS yes 改為
UseDNS no
3.4 配置yum
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.save
vi /etc/yum.repos.d/CentOS-Base.repo
######################
name=CentOS-5 - Base
repo=os
baseurl=http://centos.ustc.edu.cn/centos/5.1/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
name=CentOS-5 - Updates
baseurl=http://centos.ustc.edu.cn/centos/5.1/updates/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
name=CentOS-5 - Addons
baseurl=http://centos.ustc.edu.cn/centos/5.1/addons/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
name=CentOS-5 - Extras
baseurl=http://centos.ustc.edu.cn/centos/5.1/extras/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
name=CentOS-5 - Plus
baseurl=http://centos.ustc.edu.cn/centos/5.1/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
name=CentOS-5 - Contrib
baseurl=http://centos.ustc.edu.cn/centos/5.1/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
###################
rpm --import http://centos.ustc.edu.cn/centos/5.1/os/i386/RPM-GPG-KEY-CentOS-5
yum update
4 :編譯前準備
4.1 安裝編譯器gcc
最小化安裝,沒有安裝編譯器
yum install gcc
4.2 gcc-c++
如果不安裝,在編譯mysql的時候會出現【exec: g++: not found】錯誤
yum install gcc-c++
5:安裝軟體
5.1安裝mysql
1:去下載一個ncurses-5.6.tar.gz,
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug
make
make install clean
2:安裝mysql
tar -zxvf mysql-5.0.51a.tar.gz
cd mysql-5.0.51a
./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5 --with-extra-charset=all --without-isam --exec-prefix=/usr/local/mysql5
echo $?
make && make install
3:初始化資料庫:
groupadd mysql
useradd -g mysql mysql
scripts/mysql_install_db
cp /usr/local/mysql5/share/mysql/my-medium.cnf /usr/local/mysql5/var/my.cnf
cp /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
chown mysql:mysql -R /usr/local/mysql5/
service mysqld start
ln -s /usr/local/mysql5/bin/mysql /sbin/mysql
ln -s /usr/local/mysql5/bin/mysqladmin /sbin/mysqladmin
4:設定mysql密碼
mysqladmin -uroot password "123456"
5:讓系統找到mysql(如果必要的話):
PATH=$PATH:/usr/local/mysql5/bin
export PATH
echo "/usr/local/mysql5/lib/mysql" >> /etc/ld.so.conf
ldconfig
6::測試
netstat -nplt | grep mysql
ps aux|grep mysql
5.2 安裝apache
1:編譯安裝
tar zxvf httpd-2.2.8.tar.gz
cd httpd-2.2.8
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
echo $?
make && make install
/usr/local/apache2/bin/apachectl configtest
/usr/local/apache2/bin/apachectl start
/usr/local/apache/bin/apachectl stop
2:修改默認啟動頁
vi /usr/local/apache2/conf/httpd.conf
DirectoryIndex index.html 改為
DirectoryIndex index.html index.htm default.htm default.html index.php index.php3 index.jsp
#ServerName www.example.com:80 改為
ServerName www.example.com:80
3:apache 開機啟動的辦法
1:#echo "/usr/local/apache/bin/apachectl start" >>/etc/rc.local(系統啟動時服務自動啟動)
2:創建一個httpd啟動腳本,內容如下:
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd
在第三行添加以下內容
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server.
chmod +x /etc/rc.d/init.d/httpd
chkconfig --add httpd
修改亂碼
步驟1:
在httpd.conf中將Include conf/extra/httpd-autoindex這個模塊的註釋去掉
@vi /usr/local/apache/conf/httpd.conf
步驟2:
在httpd-autoindex.conf中加入IndexOptions Charset=UTF-8
@vi /usr/local/apache/conf/extra/httpd-autoindex.conf
5.3 安裝GD
1:安裝ZLIB2
######zlib#############
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install clean
2:安裝PNG
##########libpng###########
tar zxvf libpng-1.2.26.tar.gz
cd libpng-1.2.26
cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make
make install clean
3:安裝freetype
##########freetype#########
cd freetype-2.3.5
./configure
make
make install
4:安裝JPEG6
#########jpeg###############
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
./configure --prefix=/usr/local/jpeg --enable-shared --enable- static
make
make install
5:安裝GD
########GD###########
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --with-png --with-freetype --with-jpeg=/usr/local/jpeg/
make
make install
5.4 安裝php
1:安裝LIBXML2
#####libxml2 #####
tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
make
make install
cp xml2-config /usr/bin
2::安裝PHP5.2.5
#########php##########
tar zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/include/freetype2 --with-zlib --with-png-dir=usr/local/libpng12 --with-libxml-dir=/usr/local/libxml2 --with-gd --enable-ftp --enable-sockets
make
make test
make install
3:配置
cp php.ini-dict /usr/local/php5/lib/php.ini
編輯httpd.conf
/usr/local/apache2/conf/httpd.conf
載入php模塊,去掉註釋,我的版本是預設就啟用的。
LoadModule php5_module modules/libphp5.so
加上下面兩行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
5.5 安裝zend
tar -zxvf ZendOptimizer-3.0.0-linux-glibc23- x86_64.tar.gz
cd ZendOptimizer-3.0.0-linux-glibc23-x86_64
./install
5.6 安裝phpmyadmin
cp -rf phpMyAdmin-v2.11.5.2 /usr/local/apache2/htdocs/phpmyadmin
cd /usr/local/apache2/htdocs/phpmyadmin/
cp config.sample.inc.php config.inc.php
vi config.inc.php
$cfg['blowfish_secret'] = ''改為
$cfg['blowfish_secret'] = 'dd'
只要不為空就可以了,這樣就可以登陸,如果還有問題,就修改一下語言就解決「配置文件現在需要絕密的短語密碼(blowfish_secret)」這個錯誤了。
6:軟體
ncurses
http://ftp.gnu.org/pub/gnu/ncurses/ncurses- 5.6.tar.gz
安裝GD庫和GD庫所需的環境
zlib
http://www.zlib.net/zlib-1.2.3.tar.gz
jpeg
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
freetype
http://download.savannah.gnu.org/releases/freetype/freetype- 2.3.5.tar.gz
png
ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng- 1.2.26.tar.gz
GD
http://www.libgd.org/releases/gd-2.0.35.tar.gz
安裝php必須安裝libxml
wget ftp://xmlsoft.org/libxml2/libxml2-2.6.31.tar.gz
apache2.2.8
http://apache.mirror.phpchina.com/httpd/httpd- 2.2.8.tar.gz
phpmyadmin2.11.5.2
http://4.gxdx1.crsky.com/200804/phpMyAdmin- v2.11.5.2.rar
Zend3.3
http://downloads.zend.com/optimizer/3.3.0a/ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
php5.2.5
http://cn.php.net/distributions/php- 5.2.5.tar.gz
mysql5.051
http://mirror.trouble- free.net/mysql_mirror/Downloads/MySQL- 5.0/mysql-5.0.51a.tar.gz
[ 本帖最後由 eddiechen 於 2008-4-27 01:12 編輯 ]
《解決方案》
沒什麼好說的,樓主的精神值得學習
不過,vmware workstation好像最新的才6.0.3吧。。。。
[ 本帖最後由 ubuntu590 於 2008-4-28 10:14 編輯 ]
《解決方案》
搞錯啊,我用的是6.02,佩服,看的那麼仔細
《解決方案》
phpmyadmin下的兩個錯誤的解決辦法
當你配置好,登陸phpmyadmin,你會發現有兩個錯誤
1:沒有mbstring 擴展的phpMyAdmin 不能正確識別字元串,可能產生不可意料的結果
2:無法載入 mcrypt 擴展,<br />請檢查 PHP 配置
網上搜索了一下,基本找到的都是windows下使用的解決辦法,我這裡是linux,怎麼搞定。
第一問題,比較好辦,只需要編譯php的時候加入參數-enable-mbstring=all 就可以了。
第二個問題就比較麻煩,這應該是出現在新的版本的phpmyadmin里,不過搜索找到了答案。
到這裡ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/下載libmcrypt-2.5.7.tar.gz,編譯很簡單,依舊是configure,make,make check,make install。
裝完馬上重新去編譯php,安裝非常順利。
我已經測試通過了,非常不錯。大家可以去看看作者的blog,久聞大名。
現在已經是深夜2點了,明天還有參加朋友的婚禮。
下面是我的編譯參數,記錄一下
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/include/freetype2 --with-zlib --with-png-dir=usr/local/libpng12 --with-libxml-dir=/usr/local/libxml2 --with-gd --enable-ftp --enable-sockets -enable-mbstring=all- --with-mcrypt
http://blog.5ilinux.com/archives/linux/
http://www.weithenn.idv.tw/cgi-bin/wiki.pl/phpmyadmin-Web_%E4%BB%8B%E9%9D%A2%E6%8E%A7%E5%88%B6_Mysql
http://itblog.blogdns.net/index.php?load=read&id=27
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=6516
《解決方案》
頂起,認真研究一下
《解決方案》
我覺得這樣的東西,最好是做成一個大的rpm包,
然後只需要裝一個rpm,就可以搞定一切。
《解決方案》
頂起,認真研究一下
《解決方案》
歡迎寫成安裝角本。
《解決方案》
不錯!
還是喜歡編譯安裝,看的中規中矩!