CentOS下LAMP的安裝
基于CentOS的LAMP安裝
操作版本:centos 5.2
下載版本:
httpd-2.2.11.tar.gz
php-5.2.9.tar.gz
mysql-5.1.31.tar.gz
ZendOptimizer-3.3.3
phpMyAdmin-3.1.3.tar.gz
1、mysql的安裝
- #wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.31.tar.gz/from/http://mysql.easynet.be/
- #tar -zxvf mysql-5.1.31.tar.gz
- #cd mysql-5.1.31
- #./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all --enable-assembler --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile
- #make;make install
- #groupadd mysql
- #useradd -g mysql mysql
- #cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
- #sed -i 's/skip-federated/#skip-federated/g' /etc/my.cnf
- #/usr/local/mysql/bin/mysql_install_db --user=mysql
- #chmod +w /usr/local/mysql
- #chown -R mysql /usr/local/mysql/var
- #chgrp -R mysql /usr/local/mysql/.
- #cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
- #chmod 755 /etc/init.d/mysql
- #chkconfig --level 345 mysql on
- #service mysql start
- # /usr/local/mysql/bin/mysqladmin -u root -p password
設置root密碼,但出錯:mysql“Access denied for user 'root'@'localhost'”
解決:
- #/etc/init.d/mysql stop
- # mysqld_safe --user=mysql --skip-grant-tables --skip-networking &;
- #mysql -u root mysql
- mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
- mysql> FLUSH PRIVILEGES;
- mysql> quit
- # /etc/init.d/mysql restart
- # mysql -uroot -p
- Enter password: <輸入新設的密碼newpassword>
- mysql>
加入環(huán)境變量:
export PATH=$PATH:/usr/local/mysql/bin //臨時修改的
若要***生效
- #echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile //***修改的
- #source /etc/profile
#p#
2、apache的安裝
- #tar -zxf httpd-2.2.11.tar.gz
- #cd httpd-2.2.11
- #./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-rewrite
- #make; make install
安裝完后
# vi /usr/local/apache/conf/httpd.conf
找到 prefork.c 下的
- MaxClients 150
改為
- ServerLimit 2000
- MaxClients 1000
apache默認工作在prefork.c模式下,并發(fā)進程為150,超過后就無法訪問,150是遠遠不夠的,所以這里按自己網站的需求改, 如1000
由于apache默認***并發(fā)進程是 256 所以要先設置 ServerLimit 2000 將服務器可設的***并發(fā)數(shù)設為2000, 然后再設置***并發(fā)數(shù) MaxClients 1000
找到 #ServerName www.example.com:80 在其下設置 ServerName 如下
ServerName www.mysite.com
基中 www.mysite.com 為你網站名,也可用IP代替
找到 DocumentRoot "/usr/local/apache/htdocs"
設置你的 WEB 服務器的根目錄 如
DocumentRoot "/myweb"
找到 DirectoryIndex index.html index.html.var 改為
- DirectoryIndex index.html index.php index.htm
找到 ForceLanguagePriority Prefer Fallback 在其下加上
- AddDefaultCharset gb2312
改完后保存(vi 的用法請查 Linux vi 命令)
用下面命令啟動WEB服務器
- # /usr/local/apache/bin/apachectl start
查看自己的站點是否正常 http://www.mysite.com 也可用IP
用 # /usr/local/apache/bin/apachectl stop 可停止服務
此時在瀏覽器中試試,可能無法訪問,這是因為防火墻默認設置全部禁止訪問的原因,運行l(wèi)okkit設置就OK了~
如何更改了目錄:則:加上這一句
- Order allow ,deny
- Allow from all
#p#
3、PHP的安裝
安裝GD庫(讓PHP支持GIF,PNG,JPEG)
首先下載 jpeg6,libpng,freetype 并安裝模塊
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.9.tar.gz
wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
安裝 jpeg6
建立目錄
- # mkdir /usr/local/jpeg6
- # mkdir /usr/local/jpeg6/bin
- # mkdir /usr/local/jpeg6/lib
- # mkdir /usr/local/jpeg6/include
- # mkdir /usr/local/jpeg6/man
- # mkdir /usr/local/jpeg6/man/man1
- # cd /tmp
- # tar -zxf jpegsrc.v6b.tar.gz
- # cd jpeg-6b
- # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
- # make; make install
安裝libpng
- # cd /tmp
- # tar -zxf libpng-1.2.8.tar.gz
- # cd libpng-1.2.8
- # cp scrīpts/makefile.std makefile
- # make; make install
安裝 freetype
- # cd /root/soft
- # tar -zxf freetype-2.1.10.tar.gz
- # cd freetype-2.1.10
- # ./configure --prefix=/usr/local/freetype
- # make;make install
安裝***的GD庫
- # cd /tmp
- # tar -zxf gd-2.0.33.tar.gz
- # cd gd-2.0.33
- # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
- # make; make install
由于php5需libxml2的支持, 所以先下載并安裝libxml2
- # cd /tmp
- # wget http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/libxml2-2.6.30.tar.gz
- # tar -zxf libxml2-2.6.19.tar.gz
- # cd libxml2-2.6.19
- # ./configure --prefix=/usr/local/libxml2
- # make; make install
安裝 libxslt
- # cd /tmp
- # wget http://ftp.gnome.org/pub/gnome/sources/libxslt/1.1/libxslt-1.1.22.tar.gz
- # tar -zxf libxslt-1.1.22.tar.gz
- # cd libxslt-1.1.22
- # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
- # make; make install
終于要安裝PHP了:
- # tar -zxf php-5.2.3.tar.gz
- # cd php-5.2.3
- # ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --enable-mbstring
- # make
- # make install
其中./configure 后的
--prefix=/usr/local/php5
--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
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
這是讓PHP支持GD庫的配置選項
配置 httpd.conf 讓apache支持PHP
- # vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下內容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps在你Web目錄里建一內容為 PHP文件, 輸入URL地址查看PHP配置是否正確
安裝 phpmyadmin
下載
- # tar zxvf phpMyAdmin-2.11.2-all-languages.tar.gz
- # mv phpMyAdmin-2.11.2-all-languages /usr/local/httpd/htdocs/phpmyadmin
- # cd /usr/local/httpd/htdocs/phpmyadmin
- # cp ./libraries/config.default.php ./config.inc.php
- #vi config.inc.php
- $cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin';
- $cfg['Servers'][$i]['auth_type'] = 'http';
安裝zend:
- # tar zxvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz
- # cd ZendOptimizer-3.2.2-linux-glibc21
- # ./install.sh
OK,CentOS下LAMP安裝成功~!
【編輯推薦】