源码编译安装LAMP虽然过程繁琐,但可以根据自己PHP程序的需要配置相应的环境,非常的灵活。对于比较急于配置好LAMP的同学,可以使用lamp一键安装。
卸载yum或rpm安装的amp软件
rpm -qa|grep httpd
-
rpm -e httpd
-
rpm -qa|grep mysql
-
rpm -e mysql
-
rpm -qa|grep php
-
rpm -e php
-
-
yum -y remove httpd
-
yum -y remove php
-
yum -y remove mysql-server mysql
-
yum -y remove php-mysql
-
-
yum -y install yum-fastestmirror
-
yum -y remove httpd
-
yum -y update
禁用SeLinux
-
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
yum安装必要工具
-
yum -y install gcc gcc-c++ libtool-libs autoconf freetype freetype-devel gd libjpeg libjpeg-devel libmcrypt libmcrypt-devel libpng libpng-devel libxml2 libxml2-devel ncurses ncurses-devel zlib zlib-devel zip unzip curl curl-devel
下载所需源码
安装apache2.2.21
cd /lamp/httpd-2.2.21
-
./configure --prefix=/usr/local/apache/ --with-included-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support
-
make
-
make install
-
cp build/rpm/httpd.init /etc/init.d/httpd
-
chmod 755 /etc/init.d/httpd
-
chkconfig --add httpd
-
chkconfig --level 35 httpd on
-
cd /etc
-
mv httpd httpd_old
-
ln -s /usr/local/apache/ httpd
-
cd /usr/sbin/
-
ln -fs /usr/local/apache/bin/httpd
-
ln -fs /usr/local/apache/bin/apachectl
-
cd /var/log
-
rm -rf httpd/
-
ln -s /usr/local/apache/logs httpd
-
groupadd apache
-
useradd -g apache apache
在httpd.conf文件找到daemon,修改为apache。
增加如下代码到httpd.conf文件:
<Location />
-
AddOutputFilterByType DEFLATE text/plain
-
AddOutputFilterByType DEFLATE text/css
-
AddOutputFilterByType DEFLATE application/xml
-
AddOutputFilterByType DEFLATE application/rss+xml
-
AddOutputFilterByType DEFLATE application/atom_xml
-
AddOutputFilterByType DEFLATE application/x-javascript
-
AddOutputFilterByType DEFLATE application/x-httpd-php
-
AddOutputFilterByType DEFLATE text/html
-
</Location>
安装mysql5.1.59
groupadd mysql
-
useradd -g mysql mysql
-
cd /lamp/mysql-5.1.59
-
./configure --prefix=/usr/local/mysql/ --with-extra-charsets=all
-
make
-
make install
-
-
cp support-files/my-medium.cnf /etc/my.cnf
-
sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf
-
sed -i 's/^log-bin=mysql-bin/#log-bin=mysql-bin/g' /etc/my.cnf
-
sed -i 's/^binlog_format=mixed/#binlog_format=mixed/g' /etc/my.cnf
-
echo "skip-innodb" >> /etc/my.cnf
-
echo "skip-bdb" >> /etc/my.cnf
-
/usr/local/mysql/bin/mysql_install_db --user=mysql
-
chown -R root /usr/local/mysql
-
chown -R mysql /usr/local/mysql/var
-
chgrp -R mysql /usr/local/mysql
-
-
/usr/local/mysql/bin/mysqld_safe --user=mysql &
-
-
cp /lamp/mysql-5.1.59/support-files/mysql.server /etc/rc.d/init.d/mysqld
-
chown root.root /etc/rc.d/init.d/mysqld
-
chmod 755 /etc/rc.d/init.d/mysqld
-
chkconfig --add mysqld
-
chkconfig --list mysqld
-
chkconfig --levels 245 mysqld off
-
ln -s /usr/local/mysql/bin/mysql /usr/bin
-
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
-
service mysqld start
-
/usr/local/mysql/bin/mysqladmin -u root password '新密码'
安装PHP5.2.17
cd /lamp/php-5.2.17
-
./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-zlib -with-zlib-dir=/usr --with-libxml-dir=/usr --with-jpeg-dir --with-freetype-dir --with-gd --enable-gd-native-ttf --with-curl --enable-zip --with-mcrypt=/usr --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
-
make
-
make install
-
-
cp php.ini-dist /usr/local/php/etc/php.ini
-
sed -i '/\s\s*AddType.*tgz$/a\ Addtype application/x-httpd-php .php .phtml' /etc/httpd/conf/httpd.conf
-
service httpd restart
安装ZendOptimizer-3.3.9(可选)
64位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
32位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
cd /lamp
-
wget http://downloads.zend.com/optimi ... glibc23-i386.tar.gz
-
tar xzf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
-
cd /lamp/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/
-
mkdir -p /usr/local/Zend/lib/
-
cp ZendOptimizer.so /usr/local/Zend/lib
-
-
sed -i '$a\[zend]\
-
zend_optimizer.optimization_level=15\
-
zend_extension=/usr/local/Zend/lib/ZendOptimizer.so' /usr/local/php/etc/php.ini
-
-
service httpd restart
安装eAccelerator-0.9.6.1(可选)
cd /lamp
-
wget http://voxel.dl.sourceforge.net/ ... lerator-0.9.6.1.zip
-
unzip eaccelerator-0.9.6.1.zip
-
cd eaccelerator-0.9.6.1
-
export PHP_PREFIX="/usr/local/php"
-
$PHP_PREFIX/bin/phpize
-
./configure -enable-eaccelerator=shared -with-php-config=$PHP_PREFIX/bin/php-config
-
make && make install
-
cd /tmp
-
mkdir eaccelerator
-
chmod 0777 eaccelerator
-
-
sed -i '/^\[zend]$/i\
-
[eaccelerator]\
-
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"\
-
eaccelerator.shm_size="32"\
-
eaccelerator.cache_dir="/tmp/eaccelerator"\
-
eaccelerator.enable="1"\
-
eaccelerator.optimizer="1"\
-
eaccelerator.check_mtime="1"\
-
eaccelerator.debug="0"\
-
eaccelerator.filter=""\
-
eaccelerator.shm_max="0"\
-
eaccelerator.shm_ttl="0"\
-
eaccelerator.shm_prune_period="0"\
-
eaccelerator.shm_only="0"\
-
eaccelerator.compress="1"\
-
eaccelerator.compress_level="9" ' /usr/local/php/etc/php.ini
-
-
service httpd restart
安装phpmyadmin-3.4.5(可选)
cd /lamp
-
mv phpMyAdmin-3.4.5-all-languages /etc/httpd/htdocs/phpmyadmin
-
chmod -R 755 /etc/httpd/htdocs/phpmyadmin
-
chown -R apache:apache /etc/httpd/htdocs/phpmyadmin
-
cd /etc/httpd/htdocs/phpmyadmin
-
cp config.sample.inc.php config.inc.php
-
sed -i "/\?>/i\$cfg['ZipDump'] = TRUE" config.inc.php
-
sed -i '$a\Alias /phpmyadmin "/etc/httpd/htdocs/phpmyadmin/"' /etc/httpd/conf/httpd.conf
(责任编辑:IT) |