CentOS下安裝LAMP的方法
CentOS下安裝LAMP的方法:
-------------------編譯前準(zhǔn)備
安裝編譯器gcc
最小化安裝,沒有安裝編譯器
yum install gcc
gcc-c++
如果不安裝,在編譯mysql的時候會出現(xiàn)【exec: g++: not found】錯誤
yum install gcc-c++
--------------------------------ncurses-5.6.tar.gz http://ftp.gnu.org/pub/gnu/ncurses/
- tar zxvf ncurses-5.6.tar.gz
- cd ncurses-5.6
- ./configure --prefix=/usr --with-shared --without-debug
- make
- make install clean
------------------mysql-5.0.22.tar.gz http://download.mysql.cn/download_file/gz/5.0/mysql-5.0.22.tar.gz
- tar -zxvf mysql-5.0.22.tar.gz
- cd mysql-5.0.22
- ./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5 --with-extra-charset=all --without-isam --exec-prefix=/usr/local/mysql5
- make && make install
初始化數(shù)據(jù)庫:
- 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 //手動創(chuàng)建/usr/local/mysql5/var目錄
- 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
設(shè)定mysql密碼
- mysqladmin -uroot password "123456"
測試
- netstat -nplt | grep mysql
- ps aux|grep mysql
------------------apache
http://httpd.apache.org/download.cgi
http://labs.xiaonei.com/apache-mirror/httpd/httpd-2.2.13.tar.gz
tar zxvf httpd-2.2.13.tar.gz
cd httpd-2.2.13
- ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
- make && make install
- /usr/local/apache2/bin/apachectl configtest
- /usr/local/apache2/bin/apachectl start
- /usr/local/apache2/bin/apachectl stop
修改默認(rèn)啟動頁
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
修改亂碼
步驟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
---------------安裝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
------------------php
http://cn.php.net/distributions/php-5.2.11.tar.gz
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'
只要不為空就可以了,這樣就可以登陸,如果還有問題,就修改一下語言就解決“配置文件現(xiàn)在需要絕密的短語密碼(blowfish_secret)”這個錯誤了。以上就是CentOS下安裝LAMP的方法。本文就介紹到這里啦。
【編輯推薦】