Red Hat AS4下安裝LAMP
Red Hat AS4下安裝LAMP:
安裝MYSQL
- #tar –zxvf mysql-5.0.22.tar.gz //解開安裝包
- #cd mysql-5.0.22 //進(jìn)入安裝目錄
- #mkdir /usr/local/mysql //創(chuàng)建mysql目錄
- #./configure --prefix=/usr/local/mysql //設(shè)置安裝目錄
- #make //編譯
- #make install //安裝
- // 或是這樣 #make && make install 編譯并安裝
- #groupadd mysql //新建名為mysql的組
- #useradd –g mysql mysql //新建名為mysql的用戶,并且默認(rèn)屬于mysql組
- #chgrp –R mysql /usr/local/mysql //改變/usr/local/mysql及下屬文件與目錄屬于的組
- #cp support-files/my-large.cnf /etc/my.cnf //拷貝my-large.cnf到/etc中,替換原有的my.cnf
- #scripts/mysql_install_db //建立初始數(shù)據(jù)
- #chown –R mysql:mysql /usr/local/mysql/var //更改var及下面的文件目錄屬組與屬主
- #cp support-files/mysql.server /etc/init.d/mysqld //拷貝mysql.server到init.d目錄中并重命名為mysql,啟動文件
- #chmod 755 /etc/init.d/mysqld //設(shè)置啟動文件的權(quán)限為755
- #chkconfig --add mysqld //把此服務(wù)添加到系統(tǒng)啟動中,add為添加至/etc/rc.d/init.d中
- #chkconfig mysqld on //on默認(rèn)在3\5級別服務(wù)默認(rèn)啟動
- #/etc/init.d/mysqld start
- #/usr/local/mysql/bin/mysqld_safe & //啟動mysql
- #/usr/local/mysql/bin/mysqladmin –u root –p password 123 //默認(rèn)root用戶密碼為空,設(shè)置密碼為123
- #/usr/local/mysql/bin/mysql –u root –p //輸入上面設(shè)置的123后,以root身份登陸
- #./mysqladmin -u root -p password 456 //輸入上面設(shè)置的123后.以root身份登陸
- mysql> grant select on test.* to 'ttt' @'%' identified by'ttt' with grant option;
- //添加一個名稱為ttt,密碼為ttt的mysql賬戶,對test數(shù)據(jù)庫有修改權(quán)限
2、Apahce的安裝
- #tar -zxvf httpd-2.2.3.tar.gz //解壓httpd-2.2.3.tar.gz包
- #./configure –prefix=/usr/local/apache2 --enbale-module=so //這里的—prefix指定apache 的安裝將安裝到:/usr/local/apache2目錄下
- #make //編譯
- #make install //安裝
- #vi /usr/local/apache2/conf/httpd.conf //將里面的ServerName前面的#去掉,后面是:自己的ip:80
- #/usr/local/apache2/bin/apachectl start //啟動apache服務(wù)
如果你想一開機(jī)就讓apache自動運行的話,那么進(jìn)行如下操作:
編輯etc/rc.d /rc.local
- # vi /etc/rc.d/rc.local
在最后加上一句: /usr/local/apache2/bin/apachectl start
看這里的/usr/local/apache2的安裝路徑用到了吧,所以大家裝的時候一定要記清楚哦。。。。
jpeg包的安裝和設(shè)定
- #mkdir -p /usr/local/jpeg6
- # mkdir -p /usr/local/jpeg6/bin
- # mkdir -p /usr/local/jpeg6/lib
- # mkdir -p /usr/local/jpeg6/include
- # mkdir -p /usr/local/jpeg6/man/man1
- //上面的創(chuàng)建目錄
- #tar –zxvf jpegsrc.v6b.tar.gz //解壓jpegsrc.v6b.tar.gz包
- #./configure –prefix=/usr/local/jpeg6/ --enable-static
- #make //編譯
- #make install //安裝
安裝libpng
- # tar xvzf libpng-1.2.8.tar.gz
- # cd libpng-1.2.8
- # cp scritp/makefile.gcmmx makefile(本身自帶makefile文件,無需configure,copy一下就OK了)
- # make
- # make install
安裝freetype
- #tar –zxvf freetype-2.3.5.tar.gz
- #cd freetype-2.3.5
- #mkdir –p /usr/local/freetype
- #./configure –prefix=/usr/local/freetype
- #make
- #make install
安裝zlib(lib png支持包)
- #tar –zxvf zlib-1.2.2.tar.gz
- #cd zlib-1.2.2.tar.gz
- #./configure
- #make
- #make insatll
安裝GD庫
- #tar –zxvf gd-2.0.33.tar.gz
- #cd gd-2.0.33.tar.gz
- # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/lib/ --with-freetype=/usr/local/freetype/
- #make
- #make install
- #cp gd.h /usr/local/lib/
安裝xml包
- #tar –zxvf libxml2-2.6.19.tar.gz
- #cd libxml2-2.2.6.19
- #./configure –prefix=/usr/local/libxml2
- #make
- #make install
安裝Curl庫
- #tar –zxvf curl-7.16.4.tar.gz
- #cd curl-7.16.4
- #./configure –prefix=/usr/local/curl
- #make
- #make install
安裝php
- #tar –zxvf php-5.2.3.tar.gz
- #cd php-5.2.3.tar.gz
- #./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-curl=/usr/local/curl --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-gd-dir=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/lib --with-png=/usr/local/lib/ --with-freetype-dir=/usr/local/freetype
- #make
- #make install
- #cp php.ini-dist /usr/local/lib/php.ini
其中./configure 后的 --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2 是必要的選項 --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png=/usr/local/lib --with-zlib-dir=/usr/lib --with-freetype-dir=/usr/local/freetype 這是讓PHP支持GD庫的配置選項
--with-curl=/usr/local/curl 支持CURL庫 --enable-ftp 打開FTP庫函數(shù)支持
--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt 讓PHP支持SOAP, 上面這些一般用得少, 可以去掉
--- 收尾工作:
編輯apache的配置文件httpd.conf
- vi /etc/httpd/httpd.conf
找到 “#AddType application/x-gzip .gz .tgz”
并在后面加入
- AddType application/x-httpd-php .php
- AddType application/x-httpd-php-source .phps
這兩行的目的是讓apache識別php。
再找到“DirectoryIndex index.html”
加上 index.php 讓它把index.php做為默認(rèn)頁
---測試環(huán)境:
在/usr/local/apache/htdocs/下面建立php文件。
# vi /usr/local/apache/htdocs/index.php
輸入:
- phpinfo();
- ?>
重啟apache服務(wù)器
- # /usr/local/apache/bin/apachectl restart
瀏覽器中輸入:http://127.0.0.1/index.php測試一下,這樣Red Hat AS4下安裝LAMP就成功了。
【編輯推薦】