LAMP source code construction

Source: Internet
Author: User
Tags localhost mysql mysql create
Using the source code to build a LAMP using the source code mainly involves the following three steps: 1 .. /configure (script) -- prefix (specify the installation path) -- sysconfir (configure the script configuration path after installation) 2. make (compiled into a binary file or module) 3. makeinstall these servers...

Build LAMP with source code
Using the source code to build LAMP involves the following three steps:
 
1./configure (script) -- prefix (specify the installation path) -- sysconfir (configure the script configuration path after installation)
2. Make (compiled into a binary file or module)
3. make install
We can download the source code of these services on its official website.
Apache (official website) www.apache.org
Mysql (official website) www.mysql.com
Php (official website) www.php.net
Before installing these packages, we need to configure the gcc glib compiling environment in advance.
We can use yum grouplist to view the package group.
The following package groups must be installed:
Development Libraries Development Library
Legacy Software Development tool for traditional Software
Development Tools
Graphics-based development tools:
KDE Software Development tool kde
X Software Development gename Software Development tools
Java Development depends on java Development tools
We will not install these SDKs one by one:
Yum groupinstall "KDE Software Development" is installed one by one using this method.
Import the downloaded source code to linux:
[Root @ localhost ~] # Ll/home/
Total 174720
-Rw-r -- 1 root 5322082 Aug 5 httpd-2.2.19.tar.bz2
-Rw-r -- 1 root 162247449 Aug 5 mysql-5.5.15-linux2.6-i686.tar.gz
-Rw-r -- 1 root 11144328 Aug 5 php-5.3.7.tar.bz2
(1) first install mysql
Before installing the installation package, first check whether http php mysql has been installed with rpm-qa | grep-E "http | php | mysql". if so, you need to uninstall yum remove httpd and delete the httpd directory and all contents under/etc.
Then separate them:
Additional software needs to be installed in/usr/local/
[Root @ localhost ~] # Cd/home/
[Root @ localhost home] # ll
Total 174720
-Rw-r -- 1 root 5322082 Aug 5 httpd-2.2.19.tar.bz2
-Rw-r -- 1 root 162247449 Aug 5 mysql-5.5.15-linux2.6-i686.tar.gz
-Rw-r -- 1 root 11144328 Aug 5 php-5.3.7.tar.bz2
[Root @ localhost home] # tar-zxvf mysql-5.5.15-linux2.6-i686.tar.gz-C/usr/local/
Accessing the mysql installation directory does not provide a simple soft link to the mysql directory.
[Root @ localhost home] # cd/usr/local/
[Root @ localhost local] # ln-s mysql-5.5.15-linux2.6-i686 mysql
[Root @ localhost local] # ll
Total 76
Drwxr-xr-x 2 root 4096 Oct 1 2009 bin
Drwxr-xr-x 2 root 4096 Oct 1 2009 etc
Drwxr-xr-x 2 root 4096 Oct 1 2009 games
Drwxr-xr-x 2 root 4096 Oct 1 2009 include
Drwxr-xr-x 2 root 4096 Oct 1 2009 lib
Drwxr-xr-x 2 root 4096 Oct 1 2009 libexec
Lrwxrwxrwx 1 root 26 Aug 6 mysql-> mysql-5.5.15-linux2.6-i686
Drwxr-xr-x 13 root 4096 Aug 5 mysql-5.5.15-linux2.6-i686
Drwxr-xr-x 2 root 4096 Oct 1 2009 sbin
Drwxr-xr-x 4 root 4096 Aug 5 02: 09 share
Drwxr-xr-x 2 root 4096 Oct 1 2009 src
[Root @ localhost local] # run cd mysql to enter the mysql Directory
[Root @ localhost mysql] # ll
Drwxr-xr-x 2 root 4096 Aug 5 22: 58 bin
-Rw-r -- 1 7161 wheel 17987 Jul 14 COPYING
Drwxr-xr-x 4 root 4096 Aug 5 data
Drwxr-xr-x 2 root 4096 Aug 5 docs
Drwxr-xr-x 3 root 4096 Aug 5 include
-Rw-r -- 1 7161 wheel 7604 Jul 14 INSTALL-BINARY
Drwxr-xr-x 3 root 4096 Aug 5 22: 58 lib
Drwxr-xr-x 4 root 4096 Aug 5 22: 57 man
Drwxr-xr-x 10 root 4096 Aug 5 mysql-test
-Rw-r -- 1 7161 wheel 2552 Jul 14 README
Drwxr-xr-x 2 root 4096 Aug 5 scripts
Drwxr-xr-x 27 root 4096 Aug 5 share
Drwxr-xr-x 4 root 4096 Aug 5 SQL-Audit
Drwxr-xr-x 2 root 4096 Aug 5 22: 58 support-files
[Root @ localhost mysql] # less INSTALL-BINARY view the configuration help file, which describes the configuration steps
Shell> groupadd mysql
Shell> useradd-r-g mysql
Shell> cd/usr/local
Shell> tar zxvf/path/to/mysql-VERSION-OS.tar.gz
Shell> ln-s full-path-to-mysql-VERSION-OS mysql
Shell> cd mysql
Shell> chown-R mysql.
Shell> chgrp-R mysql.
Shell> scripts/mysql_install_db -- user = mysql
Shell> chown-R root.
Shell> chown-R mysql data
# Next command is optional
Shells> cp support-files/my-medium.cnf/etc/my. cnf
Shell> bin/mysqld_safe -- user = mysql &
# Next command is optional
Shell> cp support-files/mysql. server/etc/init. d/mysql. server
We can follow the steps to configure
[Root @ localhost ~] # Groupadd-r mysql create a mysql group (-r indicates creating a system Group)
[Root @ localhost ~] # Useradd-r-g mysql-s/sbin/nologin-M mysql
(Creating a system account belonging to the mysql group does not allow logon.-m indicates that there is no home directory)
[Root @ localhost ~] # Cd/usr/local/mysql
[Root @ localhost mysql] # chown-R mysql: mysql. (set the owner and group in the directory to mysql)
[Root @ localhost mysql] # scripts/mysql_install_db -- user = Execute the script in the mysql script directory to generate the initial Library
[Root @ localhost mysql] # chown-R root. change the file owner in the current directory to root.
[Root @ localhost mysql] # chown-R mysql data change the data owner to mysql
[Root @ localhost mysql] # cp support-files/my-medium.cnf/etc/my. cnf
Generate the mysql configuration file under/etc/
[Root @ localhost mysql] # cp support-files/mysql. server/etc/init. d/mysqld
Generate mysql control script under/etc
Export the mysql header file and library file to facilitate system search
The library files of the system are located in/lib/usr/local/lib.
/Etc/ld. so. conf. d defines the link to the installation library file of non-standard software packages
[Root @ localhost mysql] # vim/etc/ld. so. conf. d/mysql. conf
[Root @ localhost mysql] # ldconfig-v | grep mysql reload mysql database
/Usr/local/mysql/lib:
Libmysqlclient. so.18-> libmysqlclient_r.so.18.0.0 loaded successfully
[Root @ localhost mysql] #
The default storage location of the system's header file/usr/include/usr/local/include, but the mysql header file is not in it
[Root @ localhost mysql] # cd/usr/include/
[Root @ localhost include] # ln-s/usr/local/mysql/include link for creating header files for mysq
[Root @ localhost include] # chkconfig -- add mysqld add mysql startup settings
[Root @ localhost include] # chkconfig -- list | grep mysqld
Mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off
Now mysql is ready.
(2) install apache (pure source code)
[Root @ localhost home] # tar-jxvf httpd-2.2.19.tar.bz2-C/usr/src disassemble the http package to/usr/src
[Root @ localhost httpd-2.2.19] #./configure -- help | less view the configuration of the script for reference
-- Prefix = installation path
-- Sysconfdir = configure the script storage location
-- Enable-so enable dso (dynamic shared object)
-- With-z use zlib
-- Enable-ssl encryption
[Root @ localhost httpd-2.2.19] #./configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd -- enable-so -- with-z -- enable-ssl
Compile and execute the make command for a long time.
Then execute make install to form many directories.
The configuration of the main configuration file in/etc/httpd. conf is different from the previous configuration file.
Create VM files in/etc/httpd/extra/httpd-vhosts.conf
View the http configuration and startup instructions file
[Root @ localhost apache] # cd/usr/src/httpd-2.2.19/switch to the main file directory of http
[Root @ localhost httpd-2.2.19] # less INSTALL
$./Configure -- prefix = PREFIX
$ Make
$ Make install
$ PREFIX/bin/apachectl start apache startup method
Start apache
[Root @ localhost httpd-2.2.19] # cd/usr/local/apache/switch to the aopche home directory
[Root @ localhost apache] #./bin/apachectl start apache
[Root @ localhost apache] # netstat-tupln | grep http: view the apache Port
Tcp 0 0: 80: * LISTEN 19115/httpd
[Root @ localhost apache] #./bin/apachectl stop disable apache
[Root @ localhost apache] # netstat-tupln | grep http
[Root @ localhost apache] #./bin/apachectl start
Apache made of source code cannot be started using service httpd start.
Run the following command to enable apache automatic startup:
[Root @ localhost httpd-2.2.19] # vim/etc/rc. local
/Usr/local/apache/bin/apachectl start
To facilitate modification of environment variable files, you do not need to enter such a long directory at startup.
[Root @ localhost ~] # Vim/etc/profile add environment variables
Add PATH = $ PATH:/usr/local/apache/bin
[Root @ localhost ~] #./Etc/profile execute the environment variable script file
[Root @ localhost ~] # Echo $ PATH
/Usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin: /bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/apache/bin
[Root @ localhost ~] # Apachectl stop apache
[Root @ localhost ~] # Apachectl start apache
[Root @ localhost ~] # Cd/usr/include/
[Root @ localhost include] # ln-s/usr/local/apache/include/apache
Link the header file to the default system header file to facilitate calls by other software.
[Root @ localhost include] # cd/etc/ld. so. conf. d/
[Root @ localhost ld. so. conf. d] # vim apache. conf
/Usr/local/apache/lib specifies the path of the apache library file
[Root @ localhost ld. so. conf. d] # ldconfig-v | grep apache searches for apache library files
/Usr/local/apache/lib:
Client Access:
 

Now apache is ready.
(3) let's install the source code of php.
The PHP source code we downloaded is php-5.3.7.tar.bz2.
Select the path and decompress it: Put it in the/usr/src/directory.
# Tar-jxvf php-5.3.7.tar.bz2-C/usr/src/
[Root @ localhost home] # cd/usr/src/php-5.3.7/switch to the decompressed directory of php
[Root @ localhost php-5.3.7] #./configure -- help less View configuration script parameters and options
-- Prefix = installation path
-- With-apxs2 = specifies the path and name of the apache tool that calls the php module
-- Enable-mbstring supported
-- With-mysql = specifies the mysql path
-- With-mysqli = specifies the path name of mysql_config
[Root @ localhost php-5.3.7] #. /configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache/bin/apxs -- enable-mbstring -- with-mysql =/usr/local/mysql -- with-mysqli =/usr/local/mysql/bin/mysql_config
Execute make to compile after checking that the domain compilation environment has no errors.
[Root @ localhost php-5.3.7] # make
Then execute make install to install
[Root @ localhost php-5.3.7] # make install
Test whether php can work
Find the website home directory defined in the/etc/httpd. conf file and compile it.
[Root @ localhost ~] # Cd/usr/local/apache/htdocs/enter the website directory
[Root @ localhost htdocs] # vim index.html compile this file
It works!
Phpinfo (); call php
?>
[Root @ localhost htdocs] # mv index.html index. php rename the site file
[Root @ localhost htdocs] # vim/etc/httpd. conf: compile the apache Main configuration file

DirectoryIndex index.html index. php add an index

AddType application/x-httpd-php. php is added to the system to process php script items.
Restart the apache service.
[Root @ localhost htdocs] # apachectl restart
Then, the client will perform the verification:
 

Then we are trying to use php to test the connection to mysql.
[Root @ localhost ~] # Cd/usr/local/apache/htdocs/enter the website directory
[Root @ localhost htdocs] # vim index. php compilation homepage
It works!
$ Link = mysql_connect ('2017. 0.0.1 ', 'root ','');
If ($ link)
Echo "connect success !!! ";
Else
Echo "connect failed !!! "
?>
Test with a client:
 

When the database is closed, use the client for testing:
[Root @ localhost htdocs] # service mysqld stop
 

Now php is successfully installed.
The setup of Lamp source code is also complete, so we can proceed with the application.
Author "missingluo"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.