As a PHP developer, we have to understand how Linux is related. One of the most important is the build and build of the lamp environment. In this paper, the installation of the source code to demonstrate the lamp environment to build.
First, pre-compilation preparation work
1, ensure that the Linux system has installed GCC, gcc-c++, make;
# RPM-Q Make
# rpm-q GCC
# rpm-q Gcc-c++
2, check whether the system has installed Apache, MySQL, PHP
# Rpm-qa | grep httpd
# Rpm-qa | grep MySQL
# Rpm-qa | grep php
Stop all these services
# Service HTTPD Status
# service MySQL Status
3. Turn off SELinux services and firewalls
# Vi/etc/sysconfig/selinux ==> Settings selinux=disabled
# iptables-f Firewall off
4. Create a tar.sh script to extract the files
----Execute the script to extract the required source code package files. All source packages are uniformly placed under the/lamp/file.
Source code package file download please visit: Http://pan.baidu.com/s/1ntVy0QH Password: 5TKP
Contents of the Tar.sh file
=============begin
Cd/lamp
LS *.tar.gz > Ls.list
For TAR in ' Cat ls.list '
Do
TAR-ZXF $TAR
Done
==============end
Execute script: # sh-x tar.sh
Second, build lamp environment
Overview steps:
1) Unzip the package. tar.gz TAR-ZXF
2)./configure Configuration
3) Make installation source code compiled into an executable file
4) make install, copy
View help information./configure--help | grep zlib
========================================begin
Install the library files used to compile PHP
# cd/lamp/libxml2-2.6.30
#./configure--prefix=/usr/local/libxml2/
# make
# make Install
# LS/USR/LOCAL/LIBXML2 detects if the source code package is successfully installed
If there is an error: 1) rm-rf/usr/local/libxml2
2) rm-rf/lamp/libxml2-2.6.30
3) Re-unzip the build installation
# CD: /libmcrypt-2.5.8
#./configure--prefix=/usr/local/libmcrypt/
# make
# make Install
========================================
# cd/lamp/libmcrypt-2.5.8/libltdl/
#./configure--enable-ltdl-install
# make
# make Install
# CD: /zlib-1.2.3
#./configure//Do not specify the installation path
# make
# make install >/backup/zlib_20160122.install.log//write the installation process to the log file for later search
# CD: /libpng-1.2.31
#./configure--prefix=/usr/local/libpng/
# make
# make Install
# CD: /jpeg-6b
# Mkdir/usr/local/jpeg6
# Mkdir/usr/local/jpeg6/bin
# Mkdir/usr/local/jpeg6/lib
# Mkdir/usr/local/jpeg6/include
# mkdir-p/usr/local/jpeg6/man/man1
#./configure--prefix=/usr/local/jpeg6/--enable-shared--enable-static
# make
# make Install
# CD: /freetype-2.3.5
#./configure--prefix=/usr/local/freetype/
# make
# make Install
# CD: /autoconf-2.61
#./configure; make; Make install >/backup/autoconf_20160122.install.log
# CD: /gd-2.0.35
#./configure--prefix=/usr/local/gd2/--with-jpeg=/usr/local/jpeg6/--with-freetype=/usr/local/freetype/
# make
# make Install
Install compile Apache
# CD: /httpd-2.2.9
#./configure--prefix=/usr/local/apache2/--sysconfdir=/etc/httpd/--with-included-apr--disable-userdir-- Enable-so--enable-deflate=shared--enable-expires=shared--enable-rewrite=shared--enable-static-support
# make
# make Install
# Ls/usr/local/apache2
#/usr/local/apache2/bin/apachectl Start
# Ps-le | grep httpd detects Apache-related processes
# echo "/usr/local/apache2/bin/apachectl start" >>/etc/rc.d/rc.sysinit add self-starter httpd
Errors that do not have permissions or cannot load files
# chcon-t texrel_shlib_t filename
such as: # Chcon-t texrel_shlib_t/usr/local/apache2/mod_rewrite.so
Install compile MySQL
# CD: /mysql-5.0.41
# CD: /ncurses-5.6
#./configure--with-shared--without-debug--without-ada--enable-overwrite
# make
# make Install
# Groupadd MySQL
# useradd-g MySQL MySQL
# CD: /mysql-5.0.41
#./configure--prefix=/usr/local/mysql/--with-extra-charsets=all
# make
# make Install
# CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
#/USR/LOCAL/MYSQL/BIN/MYSQL_INSTALL-DB--user=mysql Authorized user
# 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 & Start MySQL
# Ps-le | grep Mysqld detects mysqld process
# Netstat-an | grep 3306
#/usr/local/mysql/bin/mysqladmin version view MySQL release information
#/usr/local/mysql/bin/mysqladmin Variables view MySQL version information
Set the root login password
#/usr/local/mysql/bin/mysql-u Root
mysql> SET PASSWORD for ' root ' @ ' localhost ' =password (' 98374toor ');
mysl> FLUSH privileges;
Mysql> quit
==================== add MySQL self-boot
# Cp/lamp/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
Install and compile PHP
# CD: /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-jpeg-dir=/usr/local/jpeg6/- -with-freetype-dir=/usr/local/freetype/--with-gd=/usr/local/gd2/--with-mcrypt=/usr/local/libmcrypt/-- 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
# echo "AddType application/x-httpd-php. php. phtml" >>/etc/httpd/httpd.conf
#/usr/local/apache2/bin/apachectl Restart
# vi/usr/local/apache2/htdocs/info.php New File
<?
Phpinfo ();
?>
Zendoptimizer Script Installation
# CD: /zendoptimizer-3.2.6-linux-glibc21-i386
# sh-x Install.sh
Change the PHP configuration file to store directory/usr/local/php/etc
Phpadmin Installation
# cp-a/lamp/phpmyadmin-3.0.0-rc1-all-languages/usr/local/apache2/htdocs/phpadmin
# Cd/usr/local/apache2/htdocs/phpadmin
# CP config.sample.inc.php config.inc.php build configuration file
# VI config.inc.php
$cfg [Servers '] [$i] [' auth_type '] = ' cookie ', change to $cfg [Servers '] [$i] [' auth_type '] = ' http '; Rewriting authentication Methods
========================================end
Note Other Apache and MySQL related commands
============= starting and shutting down the MySQL database
/etc/init.d/mysqld start
/etc/init.d/mysqld restart
/etc/init.d/mysqld stop
=========== booting and shutting Apache
/ETC/INIT.D/HTTPD start
/ETC/INIT.D/HTTPD restart
/ETC/INIT.D/HTTPD stop
Basic method of Operation:
This article assumes that your APAHCE installation directory is/usr/local/apache2 and that these methods are suitable for any situation
Apahce Start command:
Recommended/usr/local/apache2/bin/apachectl start Start
Apache Stop command:
/usr/local/apache2/bin/apachectl Stop Stop
Apache Restart command:
/usr/local/apache2/bin/apachectl Restart Restart
To restart the Apache server without interrupting the current connection, you should run:
/usr/local/sbin/apachectl Graceful
If Apache is installed as a Linux service, you can do this with the following command:
Service httpd Start
Service httpd Restart Restart
Service httpd Stop Services
This article is from the "Dongdongのhome" blog, make sure to keep this source http://autophp.blog.51cto.com/8062337/1743153
Lamp Environment Setup