应某客户要求安装纯编译的LAMP环境,这里记录下所有命令,由于比较忙,没时间像以前那样整理详细说明发布了,非常抱歉
程序准备
mkdir lamp && cd lamp
wget https://lnamp-web-server.googlecode.com/files/php-5.2.17.tar.gz
wget https://lnamp-web-server.googlecode.com/files/mysql-5.1.59.tar.gz
wget https://lnamp-web-server.googlecode.com/files/httpd-2.2.21.tar.gz
wget https://autosetup1.googlecode.com/files/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
tar -zxf httpd-2.2.21.tar.gz
tar -zxf mysql-5.1.59.tar.gz
tar -zxf php-5.2.17.tar.gz
tar -zxf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz |
mkdir lamp && cd lamp
wget https://lnamp-web-server.googlecode.com/files/php-5.2.17.tar.gz
wget https://lnamp-web-server.googlecode.com/files/mysql-5.1.59.tar.gz
wget https://lnamp-web-server.googlecode.com/files/httpd-2.2.21.tar.gz
wget https://autosetup1.googlecode.com/files/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
tar -zxf httpd-2.2.21.tar.gz
tar -zxf mysql-5.1.59.tar.gz
tar -zxf php-5.2.17.tar.gz
tar -zxf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
编译MySQL
cd mysql-5.1.59
groupadd mysql
useradd -r -g mysql mysql
./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data \
--enable-thread-safe-client --enable-assembler --enable-local-infile \
--with-charset=utf8 --with-collation=utf8_general_ci \
--with-extra-charsets=all --with-big-tables --with-readline --with-ssl \
--with-embedded-server
make && make install
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin
cd ~/lamp/mysql-5.1.59
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 0755 /etc/init.d/mysqld
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/lib/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
chkconfig --add mysqld
service mysqld start
/usr/local/mysql/bin/mysqladmin -u root password "new-password"
mysql -u root -p
mysql > use mysql;
mysql > delete from user where password="";
mysql>drop database test;
mysql>flush privileges;
mysql>quit; |
cd mysql-5.1.59
groupadd mysql
useradd -r -g mysql mysql
./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data \
--enable-thread-safe-client --enable-assembler --enable-local-infile \
--with-charset=utf8 --with-collation=utf8_general_ci \
--with-extra-charsets=all --with-big-tables --with-readline --with-ssl \
--with-embedded-server
make && make install
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin
cd ~/lamp/mysql-5.1.59
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 0755 /etc/init.d/mysqld
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/lib/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
chkconfig --add mysqld
service mysqld start
/usr/local/mysql/bin/mysqladmin -u root password "new-password"
mysql -u root -p
mysql > use mysql;
mysql > delete from user where password="";
mysql>drop database test;
mysql>flush privileges;
mysql>quit;
编译Apache
cd ~/lamp/httpd-2.2.21
./configure --prefix=/usr/local/apache --enable-so --enable-cache \
--enable-disk-cache --enable-file-cache --enable-mem-cache \
--enable-deflate --enable-headers --enable-mime-magic \
--enable-proxy --enable-rewrite --enable-ssl \
--enable-mods-shared=all --enable-expires
make && make install |
cd ~/lamp/httpd-2.2.21
./configure --prefix=/usr/local/apache --enable-so --enable-cache \
--enable-disk-cache --enable-file-cache --enable-mem-cache \
--enable-deflate --enable-headers --enable-mime-magic \
--enable-proxy --enable-rewrite --enable-ssl \
--enable-mods-shared=all --enable-expires
make && make install
vi /usr/local/apache/conf/httpd.conf 找到User和Gruop,把daemon改成www,取消ServerName的注释,改成127.0.0.1:80 vi /usr/local/apache/bin/apachectl 添加 # chkconfig:345 85 15 # description:httpd
groupadd www
useradd -M -g www -s /sbin/nologin www
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 345 httpd on
service httpd start |
groupadd www
useradd -M -g www -s /sbin/nologin www
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 345 httpd on
service httpd start
编译PHP
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-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-curl \
--with-pear \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--with-freetype-dir \
--with-mcrypt \
--with-mhash \
--with-openssl \
--with-xmlrpc \
--with-bz2 \
--with-gettext \
--with-mime-magic \
--disable-debug \
--enable-exif \
--enable-wddx \
--enable-zip \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-mbstring \
--enable-soap \
--enable-sockets \
--enable-sqlite-utf8 \
--enable-shmop \
--enable-dba \
--enable-magic-quotes
make && make install |
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-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-curl \
--with-pear \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--with-freetype-dir \
--with-mcrypt \
--with-mhash \
--with-openssl \
--with-xmlrpc \
--with-bz2 \
--with-gettext \
--with-mime-magic \
--disable-debug \
--enable-exif \
--enable-wddx \
--enable-zip \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-mbstring \
--enable-soap \
--enable-sockets \
--enable-sqlite-utf8 \
--enable-shmop \
--enable-dba \
--enable-magic-quotes
make && make install
编辑/usr/local/apache/conf/httpd.conf,添加以下配置
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch> |
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
找到
<IfModule dir_module>
DirectoryIndex index.html
</IfModule> |
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
修改为
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule> |
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
cd ~/lamp/5.2.17
cp php.ini-recommended /usr/local/php/etc/php.ini
ln -s /usr/local/php/bin/php /usr/bin |
cd ~/lamp/5.2.17
cp php.ini-recommended /usr/local/php/etc/php.ini
ln -s /usr/local/php/bin/php /usr/bin
编辑/usr/local/php/etc/php.ini,short_open_tag = Off编辑为short_open_tag = On
安装Zend Optimizer
cd ~/lamp/ZendOptimizer-3.3.3-linux-glibc23-i386
./install.sh |
cd ~/lamp/ZendOptimizer-3.3.3-linux-glibc23-i386
./install.sh
按照提示一路回车就行
配置完成测试
[root@MyCloudServer ~]# php -v PHP 5.2.17 (cli) (built: Oct 1 2013 21:09:27) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies 启动apache,无报错,无法运行,查看错误日志错误如下:
[Tue Oct 01 21:21:39 2013] [alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of “MyCloudServer” Configuration Failed 解决方法:编辑/etc/hosts,把主机名添加到127.0.0.1后面即可
相关配置文件路径
my.cnf /etc/my.cnf
apache /usr/local/apache/conf/httpd.conf
php.ini /usr/local/php/etc/php.ini
proftpd /usr/local/proftpd/etc/proftpd.conf |
my.cnf /etc/my.cnf
apache /usr/local/apache/conf/httpd.conf
php.ini /usr/local/php/etc/php.ini
proftpd /usr/local/proftpd/etc/proftpd.conf
你为什么不直接搞个脚本?
@阿福 有这个想法