Compile and install the LAMP environment with source code and configure multiple virtual hosts Based on Domain Name access

Source: Internet
Author: User
Tags install openssl mcrypt php source code php website xsl web hosting hosting website

Compile and install the LAMP environment with source code and configure multiple virtual hosts Based on Domain Name access

Lab environment and software version:

CentOS version: 6.6 (2.6.32.-504. el6.x86 _ 64)
Apache version: apache2.2.27
Mysql version: Mysql-5.6.23
Php version: php-5.3.27
1. Disable firewall: service iptables stop
Chkconfig iptables off
Ii. Disable selinux: sed-I's/SELINUX = disabled/SELINUX = enforcing/G'/etc/selinux/config
Init 6 is required to restart the system!
Iii. apache installation
Install dependency: yum-y install zlib-devel

Tar zxvf apr-1.5.1.tar.gz

Cd apr-1.5.1

./Config -- prefix =/usr/local/apr
Make & make install
Tar zxvf apr-util-1.5.4.tar.gz
Cd apr-util-1.5.4
./Config -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr
Make & make install
2. install apache: tar zxvf apache2.2.27.tar.gz
Cd apache2.2.27
Mkdir/application
. /Configure -- prefix =/application/apache2.2.27 -- enable-deflate -- enable-expires -- enable-headers -- enable-modules = most -- enable-so -- with-mpm = worker -- enable- rewrite -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util
Make & make install
Ln-s/application/apache2.2.27 // application/apache/
Start:/application/apache/bin/apachectl start
Echo "/application/apache/bin/apachectl start">/etc/rc. local
Check whether the function is Enabled:
[Root @ LAMP tools] # lsof-I: 80
Command pid user fd type device size/OFF NODE NAME
Httpd 1344 root 4u IPv6 10747 0t0 TCP *: http (LISTEN)
Httpd 62462 wapp 4u IPv6 10747 0t0 TCP *: http (LISTEN)
Httpd 62463 wapp 4u IPv6 10747 0t0 TCP *: http (LISTEN)
Httpd 62464 wapp 4u IPv6 10747 0t0 TCP *: http (LISTEN)
Httpd 62546 wapp 4u IPv6 10747 0t0 TCP *: http (LISTEN)
4. Source Code installation Mysql-5.6.23
Please refer to the following link for more information: http://linuxzkq.blog.51cto.com/9425412/1584642.
V. php installation
1. install dependency: yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel-y
Tar zxvf libiconv-1.14.tar.gz
Cd libiconv-1.14
[Root @ LAMP libiconv-1.14] #./configure -- prefix =/usr/local/libiconv
Make & make install
2. php installation: tar zxvf php-5.3.27.tar.gz
. /Configure -- prefix =/application/php-5.3.27 -- with-apxs2 =/application/apache/bin/apxs -- with-mysql =/usr/local/mysql -- with-xmlrpc -- with-openssl -- with-zlib -- with-freetype-dir -- with-gd -- with-jpeg-dir -- with-png-dir -- with-iconv =/usr/local/libiconv -- enable-short -tags -- enable-sockets -- with-zend-multibyte -- enable-soap -- enable-mbstring -- enable-static -- enable-gd-native-ttf -- with-curl -- with-xsl -- enable-ftp -- with-libxml-dir -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util

Error: configure: error: Cannot find MySQL header files under/usr/local/mysql.
[Root @ localhost php-5.5.6] # find/-name mysql. h
/Usr/include/mysql. h
Find the mysql. h file and change the parameter to -- with-mysql =/usr. If not, install the mysql-devel package,

[Root @ localhost php-5.5.6] # yum install mysql-devel

Re-compile:
./Configure -- prefix =/application/php-5.3.27 ...... Omitted later

Configure: error: Cannot find libmysqlclient_r under/usr.
Note that the MySQL client library is not bundled anymore!
[Root @ LAMP: php-5.3.27] # yum-y install libxslt *
Modify the editing parameters as follows. The preceding parameters do not work because they are related to the previous apache and mysql parameters during compilation:
[Root @ LAMP: php-5.3.27] #. /configure -- prefix =/application/php-5.3.27 -- with-apxs2 =/application/apache/bin/apxs -- with-mysql =/usr -- with-xmlrpc -- with-openssl -- with-zlib -- with-freetype-dir -- with-gd -- with-jpeg-dir -- with-png-dir -- with-iconv -- enable-short-tags -- enable-sockets -- with-zend- multibyte -- enable-soap -- enable-mbstring -- enable-static -- enable-gd-native-ttf -- with-curl -- with-xsl -- enable-ftp -- with-libxml-dir -- with-libdir = lib64


+ -------------------------------------------------------------------- +


Thank you for using PHP.


Notice: Following unknown configure options were used:


-- With-zend-multibyte


Check './configure -- help' for available options
Php checks the System Configuration Environment
3. Together with the php source code compilation errors in CentOS x64, refer to the situation and solutions (from the network ):


Configure: error: xml2-config not found. Please check your libxml2 installation.


Yum install libxml2-devel.x86_64
Configure: error: Cannot find OpenSSL's


Yum install openssl-devel.x86_64
Configure: error: cocould not find pcre. h in/usr/local


Yum install pcre-devel.x86_64
Configure: error: cocould not find pcre. h in/usr/local


"-- With-pcre-regex =/usr/include "\
Configure: error: cocould not find libpcre. (a | so) in/usr/include


"-- With-pcre-regex =/usr "\
Configure: error: Please reinstall the libcurl distribution-
Easy. h shoshould be in/include/curl/


Yum install curl-devel.x86_64
Configure: error: libjpeg. (a | so) not found.


Yum install libjpeg-devel.x86_64
Configure: error: libpng. (a | so) not found.


Yum install libpng-devel.x86_64
Configure: error: freetype. h not found.


Yum install freetype-devel.x86_64
Configure: error: Please reinstall the iconv library.


"-- With-iconv "\
Configure: error: mcrypt. h not found. Please reinstall libmcrypt.


Yum install libmcrypt. x86_64 libmcrypt-devel.x86_64
Configure: error: Please reinstall libmhash-I cannot find mhash. h


Yum install mhash. x86_64 mhash-devel.x86_64
Note that the MySQL client library is not bundled anymore!


Yum install php-mysql.x86_64 mysql-devel.x86_64
Configure: error: Please reinstall the BZip2 distribution


Yum install bzip2-devel.x86_64
Configure: error: utf8_mime2text () has new signature, but U8T_CANONICAL is missing. This shocould not happen. Check config. log for additional information.
DISABLE IMAP
Configure: error: Cannot find pspell


Yum install aspell-devel.x86_64
Configure: error: Cannot find libtidy


Yum install libtidy. x86_64 libtidy-devel.x86_64
Error: xslt-config not found. Please reinstall the libxslt> = 1.1.0 distribution


Yum install libxslt. x86_64 libxslt-devel.x86_64
Collect2: ld returned 1 exit status


Yum install glibc-utils.x86_64 libtool-ltdl-devel.x86_64
Step by step to guide PHP Compile
Step 1: Update & Install Development Tools & Libraries


Yum update
Yum group install "Development Tools"
Yum group install "Development Libraries"
Step 2: Run the bellow bash script


#! /Bin/sh
"./Configure "\
"-- Prefix =/usr/local/php5 "\
"-- Enable-force-cgi-redirect "\
"-- Enable-fastcgi "\
-- With-bz2 "\
"-- With-config-file-path =/usr/local/etc "\
"-- With-config-file-scan-dir =/usr/local/etc/php. d "\
"-- With-curl =/usr/local/lib "\
"-- With-gd "\
"-- With-gettext "\
"-- With-jpeg-dir =/usr/local/lib "\
"-- With-freetype-dir =/usr/local/lib "\
"-- With-kerberos "\
"-- With-mcrypt "\
"-- With-mhash "\
"-- With-mime-magic "\
"-- With-mysql "\
"-- With-mysqli "\
"-- With-pcre-regex =/usr "\
"-- With-pdo-mysql = shared "\
"-- With-pdo-sqlite = shared "\
"-- With-pear =/usr/local/lib/php "\
"-- With-png-dir =/usr/local/lib "\
"-- With-pspell "\
"-- With-sqlite = shared "\
"-- With-tidy "\
"-- With-ttf "\
"-- With-xmlrpc "\
"-- With-xsl "\
"-- With-zlib "\
"-- With-zlib-dir =/usr/local/lib "\
"-- With-openssl "\
"-- With-iconv "\
"-- With-libdir = lib64 "\
"-- Enable-bcmath "\
"-- Enable-calendar "\
"-- Enable-exif "\
"-- Enable-ftp "\
"-- Enable-gd-native-ttf "\
"-- Enable-libxml "\
"-- Enable-magic-quotes "\
"-- Enable-soap "\
"-- Enable-sockets "\
"-- Enable-mbstring "\
"-- Enable-zip "\
"-- Enable-wddx"
Fromhttp: // www.lifelinux.com/error-compiling-php-on-centos-x64/


Make & make install


[Root @ LAMP php-5.3.27] # ls php
Php5.spec php. ini-development
Php5.spec. in php. ini-production
Php.gif
[Root @ LAMP php-5.3.27] # diff php. ini-production php. ini-development Comparison of internal development configuration files and external application configuration files
521c521
<Error_reporting = E_ALL &~ E_DEPRECATED
---
> Error_reporting = E_ALL | E_STRICT
538c538
<Display_errors = Off
---
> Display_errors = On
549c0000
<Display_startup_errors = Off
---
> Display_startup_errors = On
593c593
<Track_errors = Off
---
> Track_errors = On
611c611
<Html_errors = Off
---
> Html_errors = On
751c751
<; Scheduled removed in PHP 5.4.
---
>; Removed in PHP 5.4.
845c845
<; Cgi. redirect_status_env =
---
>; Cgi. redirect_status_env =
1318c1318
<Mysqlnd. collect_memory_statistics = Off
---
> Mysqlnd. collect_memory_statistics = On
1587c1587
<Session. bug_compat_42 = Off
---
> Session. bug_compat_42 = On
1596c1596
<Session. bug_compat_warn = Off
---
> Session. bug_compat_warn = On
[Root @ LAMP php-5.3.27] # cp php
Php5.spec php. ini-development
Php5.spec. in php. ini-production
Php.gif
[Root @ LAMP php-5.3.27] # cp php. ini-production/application/php/lib/php. ini
[Root @ LAMP php-5.3.27] #
Summary: The official configuration file usually closes the display LOG and does not output the LOG.


6. Enable the VM function and modify the user and user group: useradd-M-s/sbin/nologin wapp
Cd/application/apache/conf
Vi httpd. conf
Find
Change User daemon to wapp
Change Group daemon to wapp
 

Find # Include conf/extra/httpd-vhosts.conf to enable Virtual Machine
Cancel the # Note and save and exit.
VII. Integrate php and apache: vi httpd. conf

Go to AddType application/x-gzip. gz. tgz and add the following lines:
AddType application/x-httpd-php. php. phtml
AddType application/x-httpd-php-source. phps
Go to DirectoryIndex index.html
To:
DirectoryIndex index. php index.html
Restart apache or re-load the configuration file to test whether php can be used normally.
8. Define virtual machines: cd/application/apache/conf/extra
Vi httpd-vhosts.conf
Add several domain name-based Virtual Machine instances at the end of the file as follows:

<VirtualHost *: 80>
ServerAdmin kk@bkjia.com
DocumentRoot "/data/cms"
ServerName www.bkjia.org
ServerAlias bkjia.org
ErrorLog "logs/www.bkjia.org-error_log"
CustomLog "logs/www.bkjia.org-access_log" common
</VirtualHost>
<VirtualHost *: 80>

ServerAdmin kk@bkjia.com
DocumentRoot "/data/bbs"
ServerName bbs.bkjia.org
ErrorLog "logs/bbs.bkjia.org-error_log"
CustomLog "logs/bbs.bkjia.org-access_log" common
</VirtualHost>
<VirtualHost *: 80>

ServerAdmin kk@bkjia.com
DocumentRoot "/data/blog"
ServerName blog.bkjia.org
ErrorLog "logs/blog.bkjia.org-error_log"
CustomLog "logs/blog.bkjia.org-access_log" common
</VirtualHost>
Save and exit. Restart the apache service!

9. After the virtual machine is enabled, the php website program is uploaded, and the user and User Group of the root directory and file of the virtual machine are changed to: wapp: root (chown-R wapp: root/data) the 403 error is returned after access. The solution is as follows:


This is an example in apache2.2 Chinese reference manual. Generally, this configuration is correct in earlier versions. But now it's different. When you access a page under a VM, the following error occurs: "403 (Access prohibited). You cannot view this page ..." . Obviously, this is a prompt to reject access. According to experience, it is easy to find the content below (httpd. conf:
<Directory "/Web Hosting root Directory">

Options FollowSymLinks
AllowOverride None
Order deny, allow
</Directory>
// Deny from all
// Reject all access requests </Directory>


Grant access permissions to the root directory of the web hosting website
Cd/application/apache/conf/extra
Vi httpd-vhosts.conf
Add the following code at the beginning of all defined virtual hosts:

<Directory "/data">

Options FollowSymLinks
AllowOverride None
Order deny, allow
</Directory>
Save and exit, restart apache service for normal access!

------------------------------------ Split line ------------------------------------

CentOS 6.5 system installation and configuration LAMP (Apache + PHP5 + MySQL) server environment

Configure the LAMP + phpMyAdmin PHP (5.5.9) development environment in Ubuntu 14.04

Ubuntu 14.10 text tutorial on hard drive installation in Windows 7

Install Ubuntu 14.10 on a USB flash drive

Official release and download of Ubuntu 14.10

How to upgrade Ubuntu 14.04 LTS to Ubuntu 14.10

Install LAMP in Ubuntu 14.10

------------------------------------ Split line ------------------------------------

This article permanently updates the link address:

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.