In the current Linux operating system version, if you choose to install all by default, the LAMP environment has been installed, but the version is relatively low. We can install another LAMP environment and the original environment, but this is not necessary because only one LAMP environment can be enabled at the same time. Before installation, check whether the system has installed a low-version environment. If the system has been installed, stop the original service, or uninstall the original environment.A. Uninstall Apache
# Rpm-qa | grep httpd
Note: Check whether the httpd software package is installed.
# Rpm-e httpd-2.2.3-63.el5.centos -- nodeps
Note: uninstall the software package. If nodeps is associated, uninstall it forcibly.
# Cd/etc/httpd/
# Rm-rf *
Note: delete all the installation directories and files under the original apache installation directory.
B. uninstall Mysql
# Rpm-qa | grep mysql
# Rpm-e mysql-5.0.77-4.el5_4.2 -- nodeps
Instructions: uninstall mysql
C. Uninstall Php
# Rpm-qa | grep php
# Rpm-e php-common-5.1.6-27.el5 -- nodeps
# Rpm-e php-ldap-5.1.6-27.el5 -- nodeps
# Rpm-e php-cli-5.1.6-27.el5 -- nodeps
# Rpm-e php-5.1.6-27.el5 -- nodeps
Instructions: uninstall PHP
4. Disable selinux and clear firewall rules.
5. Use ssh shell to upload 13 source code packages in windows to/usr/local/src
6. Unpack
Write a shell script tar. sh to unpack the package.
#!/bin/sh cd /usr/local/src ls *.tar.gz > ls.list for TAR in `catls.list` dotar -zxvf $TAR done
Run the script tar. sh to unpack the package.
7. Delete all source code packages * .tar.gz
4. Install LAMP
1. Install libxml2
# Cd/usr/local/src/libxml2-2.6.30
#./Configure -- prefix =/usr/local/libxml2
# Make & make install
2. Install libmcrypt
# Cd/usr/local/src/libmcrypt-2.5.8
#./Configure -- prefix =/usr/local/libmcrypt
# Make & make install
3. Install zlib
# Cd/usr/local/src/zlib-1.2.3
#./Configure
# Make & make install
4. Install libpng
# Cd/usr/local/src/libpng-1.2.31
#./Configure -- prefix =/usr/local/libpng
# Make & make install
5. Install IIS6
The installation of this software package is somewhat special. If the directory does not exist during installation of other software packages, it will be automatically created, but this software package needs to be manually created during installation.
# Mkdir/usr/local/limit 6
# Mkdir/usr/local/partition 6/bin
# Mkdir/usr/local/IPv6/lib
# Mkdir/usr/local/latest 6/include
# Mkdir-p/usr/local/users 6/man/man1
# Cd/usr/local/src/jpeg-6b
#./Configure -- prefix =/usr/local/defaults 6/-- enable-shared -- enable-static
# Make & make install
6. Install freetype
# Cd/usr/local/src/freetype-2.3.5
#./Configure -- prefix =/usr/local/freetype
# Make
# Make install
7. Install autoconf
# Cd/usr/local/src/autoconf-2.61
#./Configure
# Make & make install
8. Install the GD library
# Cd/usr/local/src/gd-2.0.35
#./Configure \
-- Prefix =/usr/local/gd2 /\
Enable-m4_pattern_allow \
-- With-zlib =/usr/local/zlib /\
-- With-jpeg =/usr/local/defaults 6 /\
-- With-png =/usr/local/libpng /\
-- With-freetype =/usr/local/freetype/
# Make
Error:
Make [2]: *** [gd_png.lo] Error 1
Make [2]: Leaving directory '/usr/local/src/gd-2.0.35'
Make [1]: *** [all-recursive] Error 1
Make [1]: Leaving directory '/usr/local/src/gd-2.0.35'
Make: *** [all] Error 2
Analysis: this problem is caused by the failure to find png. h when the source file gd_png.c In the gd library contains png. h.
Solution:
In the compilation File
# Vi gd_png.c
Change include "png. h" to include "/usr/local/libpng/include/png. h"
/Usr/local/libpng/is the installation path of libpng.
# Make install
9. install Apache
# Cd/usr/local/src/httpd-2.2.9
#./Configure \
-- Prefix =/usr/local/apache2 \
-- Sysconfdir =/etc/httpd \
-- With-z =/usr/local/zlib \
-- With-defined ded-apr \
-- Enable-so \
-- Enable-deflate = shared \
-- Enable-expires = shared \
-- Enable-rewrite = shared \
-- Enable-static-support
# Make & make install
10. Configure Apache
Start Apache
#/Usr/local/apache2/bin/apachectl start
Disable Apache
#/Usr/local/apache2/bin/apachectl stop
Check whether port 80 is enabled
# Netstat-tnl | grep 80
Access Apache server
Add auto-start
# Echo "/usr/local/apache2/bin/apachectl start">/etc/rc. d/rc. local
11. Install Mysql
Add a mysql standard group
# Groupadd mysql
Add a mysql user to the mysql Group
# Useradd-g mysql
# Cd/usr/local/src/mysql-5.0.41
#./Configure \
-- Prefix =/usr/local/mysql /\
-- With-extra-charsets = all
Error:
Checking for tgetent in-lncurses... no
Checking for tgetent in-lcurses... no
Checking for tgetent in-ltermcap... no
Checking for tgetent in-ltinfo... no
Checking for termcap functions library... configure: error: No curses/termcap library found
Analysis: The ncurses installation package is missing
Solution:
# Yum install ncurses-devel
# Make & make install
12. Configure Mysql
Create a configuration file for the MySQL database server
# Cp support-files/my-medium.cnf/etc/my. cnf
Create an authorization table with the mysql user. After the table is created successfully, a var directory is generated under the/usr/local/mysql directory.
#/Usr/local/mysql/bin/mysql_install_db -- user = mysql
Change all attributes of the file to the root user.
# Chown-R root/usr/local/mysql
Change all attributes of the data directory to mysql users.
# Chown-R mysql/usr/local/mysql/var
Change Group attribute to mysql Group
# Chgrp-R mysql/usr/local/mysql
Start Database
#/Usr/local/mysql/bin/mysqld_safe -- user = mysql &
Check whether port 3306 is enabled
# Netstat-tnl | grep 3306
Simple Test
#/Usr/local/mysql/bin/mysqladmin version
View All mysql Parameters
#/Usr/local/mysql/bin/mysqladmin variables
Set Mysql to start automatically
# Cp/usr/local/src/mysql-5.0.41/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
13. Mysql Security Settings
You can directly log on to the server without a password.
#/Usr/local/mysql/bin/mysql-u root
View mysql user permission information
Mysql> select * from mysql. user;
Delete hosts that are not localhost
Mysql> delete from mysql. user WHERE Host = 'localhost' AND User = '';
Refresh authorization table
Mysql> flush privileges;
Add password for root user
Mysql> set password for 'root' @ 'localhost' = PASSWORD ('abc123 ');
Enter the Mysql client again
#/Usr/local/mysql/bin/mysql-u root-h localhost-p
Close MySQL database
#/Usr/local/mysql/bin/mysqladmin-u root-p shutdown
14. install PHP
# Cd/usr/local/src/php-5.2.6
#./Configure \
-- Prefix =/usr/local/php \
-- With-config-file-path =/usr/local/php/etc \
-- With-apxs2 =/usr/local/apache2/bin/apxs \
-- With-mysql =/usr/local/mysql /\
-- With-libxml-dir =/usr/local/libxml2 /\
-- With-png-dir =/usr/local/libpng /\
-- With-jpeg-dir =/usr/local/defaults 6 /\
-- With-freetype-dir =/usr/local/freetype /\
-- With-gd =/usr/local/gd2 /\
-- With-zlib-dir =/usr/local/zlib /\
-- With-mcrypt =/usr/local/libmcrypt /\
-- With-mysqli =/usr/local/mysql/bin/mysql_config \
-- Enable-soap \
-- Enable-mbstring = all \
-- Enable-sockets
# Make & make install
15. Configure PHP
Create a configuration file
# Cp php. ini-dist/usr/local/php/etc/php. ini
Use vi to edit the apache configuration file
# Vi/etc/httpd. conf
Add this code
Addtype application/x-httpd-php. php. phtml
Restart Apache
#/Usr/local/apache2/bin/apachectl restart
The above installation steps can be written as a shell script, detailed reference http://files.cnblogs.com/mchina/lamp.rar
16. Install Zend accelerator
# Cd/usr/local/src/ZendOptimizer-3.2.6-linux-glibc21-i386/
#./Install. sh
17. Install phpMyAdmin
Copy the directory to the specified location and change it to phpmyadmin # cp-a phpMyAdmin-3.0.0-rc1-all-languages/usr/local/apache2/htdocs/phpmyadmin # cd/usr/local/apache2/htdocs/phpmyadmin/# cp config. sample. inc. php config. inc. php18. Configure phpMyAdmin
# Change auth_type to http in vi/usr/local/apache2/htdocs/phpmyadmin/config. inc. php$cfg['Servers'][$i]['auth_type'] = 'http';
V. Test
1. Compile the info. php file to view the php configuration details.
# Vi/usr/local/apache2/htdocs/info. php
<?php phpinfo(); ?>
Access http: // 10.0.0.154/info. php in a browser to obtain detailed php configuration information.
2. Zend accelerator Information
3. Access phpMyAdmin
Now the LAMP environment has been configured.