LAMP全新安裝 Linux+Apache+MySQL+PHP+php

else發表於2021-09-09


簡介:

  從上次發表的一篇在Windows下安裝Discuz論壇的文章到現在差不多快一個月了,一直想把在Linux下安裝的過程也寫出來,畢竟Linux下執行PHP效能要比Windows好.其實安裝編譯軟體不是很麻煩,難的是要將各個元件組合起來.在安裝過程中遇到了很多困難,也嘗試了不少的方法,最終成就這篇文章.文中軟體下載後存放的位置如果沒有特殊說明,都存入在 /tmp下.以下是安裝的過程:

一:安裝Apache([url][/url])

  a:先檢查系統中是否安裝有舊版本的相關軟體

[root@redhat ~]# rpm -qa |grep mysql 

[root@redhat ~]# rpm -qa |grep httpd 

[root@redhat ~]# rpm -qa |grep php

  b:解壓並安裝Apache

[root@redhat ~]# cd /tmp 

[root@redhat tmp]# tar zxvf httpd-2.2.4.tar.gz 

[root@redhat httpd-2.2.4]# ./configure --prefix=/usr/local/httpd  

--enable-isapi --enable-file-cache  

--enable-echo --disable-charset-lite  

--enable-charset-lite --enable-cache --enable-disk-cache --enable-mem-cache  

--enable-example --enable-case-filter --enable-case-filter-in --enable-dumpio  

--enable-ext-filter --enable-deflate --enable-log-forensic  

--enable-logio --enable-mime-magic --enable-headers --enable-proxy --enable-proxy-connect

--enable-proxy-ftp --enable-proxy-http --enable-ssl --enable-optional-hook-export  

--enable-optional-hook-import --enable-optional-fn-import --enable-http --enable-cgi  

--enable-cgid --enable-speling --enable-rewrite --enable-so --with-suexec-uidmin  

--with-suexec-gidmin --with-suexec-logfile --with-suexec-safepath --enable-static-htpasswd

--enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve 

[root@redhat httpd-2.2.4]# make 

[root@redhat httpd-2.2.4]# make install

二:安裝MySQL([url][/url])

[root@redhat tmp]# tar zxvf mysql-5.0.41-linux-i686.tar.gz 

[root@redhat tmp]# mv mysql-5.0.41-linux-i686 /usr/local/mysql 

[root@redhat mysql]# pwd 

/usr/local/mysql 

[root@redhat mysql]# groupadd mysql 

[root@redhat mysql]# useradd mysql -g mysql 

[root@redhat mysql]# chown -R root . 

[root@redhat mysql]# chown -R mysql data 

[root@redhat mysql]# chown -R mysql data/mysql/. 

[root@redhat mysql]# chgrp -R mysql . 

[root@redhat mysql]# cp ./support-files/my-medium.cnf /etc/my.cnf 

[root@redhat mysql]# ./scripts/mysql_install_db --user=mysql 

[root@redhat mysql]# bin/mysqld_safe --user=mysql & 

[root@redhat tmp]# /usr/local/mysql/bin/mysqlshow -p

三:安裝GD庫([url][/url])

  a:解壓並安裝libpng([url][/url] )

[root@redhat libpng-1.2.16]# ./configure --prefix=/usr/local/png 

[root@redhat libpng-1.2.16]# make 

[root@redhat libpng-1.2.16]# make install

  b:解壓並安裝jpeg([url]ftp://ftp.uu.net/graphics/jpeg/[/url] )

[root@redhat jpeg-6b]# mkdir /usr/local/jpeg 

[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/bin 

[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/lib 

[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/include 

[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/man 

[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/man/man1 

[root@redhat jpeg-6b]# ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static 

[root@redhat jpeg-6b]# make 

[root@redhat jpeg-6b]# make install

  c:解壓並安裝freetype ([url][/url])

[root@redhat freetype-2.3.2]# ./configure --prefix=/usr/local/freetype2 

[root@redhat freetype-2.3.2]# make 

[root@redhat freetype-2.3.2]# make install

  d:解壓並安裝fontconfig ([url][/url])

[root@redhat fontconfig-2.4.0]# ./configure --prefix=/usr/local/fontconfig  

--with-freetype-config=/usr/local/freetype2/bin/freetype-config 

[root@redhat fontconfig-2.4.0]# make 

[root@redhat fontconfig-2.4.0]# make install

  e:安裝xmkmf工具

  在安裝xpm時,會提示有找不到xmkmf這個命令.這時需要安裝xorg-devel包,在系統盤的第三張光碟上找到並安裝它.

[root@redhat tmp]# rpm -ivh freetype-devel-2.1.9-1.i386.rpm 

[root@redhat tmp]# rpm -ivh fontconfig-devel-2.2.3-7.i386.rpm 

[root@redhat tmp]# rpm -ivh /tmp/xorg-x11-devel-6.8.1-23.EL.i386.rpm

  f:解壓並安裝xpm ([url][/url])

[root@redhat xpm-3.4k]# xmkmf -a 

[root@redhat xpm-3.4k]# make 

[root@redhat xpm-3.4k]# make install

  g:解壓並安裝GD

[root@redhat tmp]# tar zxvf gd-2.0.34.tar.gz 

[root@redhat gd-2.0.34]# ./configure --prefix=/usr/local/gd --with-png=/usr/local/png/  

--with-jpeg=/usr/local/jpeg/ --with-freetyp=/usr/local/freetype2/  

--with-fontconfig =/usr/local/fontconfig/--with-xpm 

[root@redhat gd-2.0.34]# cp /usr/local/png/include/png.h ./ 

[root@redhat gd-2.0.34]# cp /usr/local/png/include/pngconf.h ./ 

[root@redhat gd-2.0.34]# make 

[root@redhat gd-2.0.34]# make install

四:解壓並安裝php([url][/url] )

[root@redhat tmp]# tar zxvf php-5.2.3.tar.gz 

[root@redhat php-5.2.3]# ./configure --prefix=/usr/local/php  

--with-mysql=/usr/local/mysql --with-apxs2=/usr/local/httpd/bin/apxs  

--with-libxml-dir=/usr/include/libxml2/libxml --with-gd=/usr/local/gd/  

--with-png=/usr/local/png/ --with-jpeg=/usr/local/jpeg/ --with-xpm  

--with-zlib --enable-debug --enable-magic-quotes --enable-libgcc  

--enable-ftp --enable-mbstring --enable-sockets --with-gnu-ld 

[root@redhat php-5.2.3]# make 

[root@redhat php-5.2.3]# make install 

[root@redhat php-5.2.3]# cp php.ini-recommended /usr/local/php/etc/php.ini

五:設定http.conf來支援PHP

[root@redhat php-5.2.3]# vi /usr/local/httpd/conf/httpd.conf 

AddType application/x-httpd-php .php .phtml 

AddType application/x-httpd-php-source .phps 

DirectoryIndex index.html index.html.var index.htm index.php

六:解壓並設定phpmyadmin

[root@redhat tmp]# tar zxvf phpMyAdmin-2.11.2-all-languages.tar.gz 

[root@redhat tmp]# mv phpMyAdmin-2.11.2-all-languages /usr/local/httpd/htdocs/phpmyadmin

[root@redhat tmp]# cd /usr/local/httpd/htdocs/phpmyadmin 

[root@redhat phpmyadmin]# cp ./libraries/config.default.php ./config.inc.php 

[root@redhat phpmyadmin]vi config.inc.php 

$cfg['PmaAbsoluteUri'] = '[url]';[/url] 

$cfg['Servers'][$i]['auth_type'] = 'http';

七:建立php測試檔案,啟動apache

[root@redhat tmp]#vi /usrc/local/httpd/htdocs/phpinfo.php 

---------------------------- 

<?php phpinfo(); ?> 

---------------------------- 

[root@redhat tmp]# /usr/local/httpd/bin/apachectl start  

  此時,在瀏覽器中輸入:[url][/url],會出現以下畫面,圖中顯示GD庫已正確安裝

  再測試phpmyadmin,同樣在瀏覽器中輸入:[url][/url]

八:安裝Zend

[root@redhat tmp]# tar zxvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz 

[root@redhat tmp]# cd ZendOptimizer-3.2.2-linux-glibc21 

[root@redhat ZendOptimizer-3.2.2-linux-glibc21 ]# ./install.sh

至此,LAMP已完全安裝成功,而且全面基於原始碼的方式安裝完成,所用的系統及已安裝的相關元件可以點這裡檢視.

©著作權歸作者所有:來自51CTO部落格作者waring_id的原創作品,如需轉載,請註明出處,否則將追究法律責任

phpLinuxmysqlLinux


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2318/viewspace-2820914/,如需轉載,請註明出處,否則將追究法律責任。

相關文章