Example of LAMP environment construction

Source: Internet
Author: User


First, the preparation of lamp construction

Lamp is the abbreviation for four sets of software, refers to l-linux,a-apache,m-mysql,p-php, the use of these four sets of software to build the environment of the web.
Need to download good software before building
#cd/home/soft
Apache:

Http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.31.tar.gz
Mysql:

32-bit: http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.31-linux-glibc2.5-i686.tar.gz
64-bit: http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz
Php:

wget ' Http://cn2.php.net/get/php-5.4.45.tar.bz2/from/this/mirror '-o php-5.4.45.tar.bz2
Software image http://mirrors.sohu.com/, Sohu image, Ari image, NetEase mirror can download various open source software
Install the extension library
Yum Install-y epel-release
Install library files
Yum-y install NTP make OpenSSL openssl-devel pcre pcre-devel libpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6 b freetype freetype-devel gd gd-devel fontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c++ Flex Bison bzip2-devel L IBXPM libxpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake Screen sy Sstat compat-libstdc++-33 Curl Curl-devel
Turn off SELinux

Temporarily closed: Setenforce 0
Permanently closed: Vim/etc/selinux/config Modify selinux=disabled # #需要重启生效

Shutting down the firewall

Iptables-f

Service Iptables Stop


Second, Apache installation


1) compiling

# Unzip the package
[Email protected] soft]# TAR-ZXVF httpd-2.2.31.tar.gz

# go to the software catalog
[Email protected] soft]# CD httpd-2.2.31

# Execute compilation parameters
[Email protected] httpd-2.2.16]#./configure \--prefix=/usr/local/apache2 \--with-included-apr \--enable-so \-- enable-deflate=shared \--enable-expires=shared \--enable-rewrite=shared \--with-pcre

# Start compiling and installing the software

[[email protected] httpd-2.2.16]# make

[[email protected] httpd-2.2.16]# make install

Input echo$? Display 0 compile and install correctly

2) Modify the configuration

[[email protected] ~]#  vim/usr/local/apache2/conf/httpd.conf
.......... The above is omitted ......... .....
# at a local disk.  if wish to share the same serverroot for multiple
# httpd daemons, you'll need To least LockFile and pidfile.
#
serverroot  "/usr/local/apache2"           # Apache program Directory
#Listen 12.34.56.78:80
Listen                         # listening Port
serveradmin [email protected]           # admin e-mail address
ServerName localhost:80                # default servername www.example.com:80 

DocumentRoot "/usr/local/apache2/htdocs/" # Site file storage location, file listening directory

Options FollowSymLinks
AllowOverride None
Order Deny,allow
Allow from all

# default = Deny from all, Access denied, modify to allow from all, access is allowed, otherwise 403 hints when visiting the site

3) Start Apache

# Modify configuration to detect if OK
[Email protected] ~]#/usr/local/apache2/bin/apachectl-t
Syntax OK
[[email protected] ~]#/usr/local/apache2/bin/apachectl start

[[email protected] ~]# PS Aux|grep httpd        
root     25675   0.0  0.2   5680  2148?        Ss   10:20   0:00/usr/local/apache2/bin/httpd -k start
daemon   25880  0.0  0.1    5680  1568?        S    10:20   0:00/usr/local/ Apache2/bin/httpd -k start
root     25886  0.0  0.0    4622  769ts/4    S+   10:23  0:00 grep httpd
[

[email  protected] ~]# netstat-nlp |grep httpd   # Port Detection

TCP 0 0::: +:::* LISTEN 25675/httpd


[[email protected] ~]# curl-i localhost # site state access detection

http/1.1 OK
Date:tue, APR 12:52:42 GMT
server:apache/2.2.16 (Unix) DAV/2
Last-modified:sat, 2004 20:16:24 GMT
ETag: "12a8-2c-3e9564c23b600"
Accept-ranges:bytes
Content-length:44
Content-type:text/html
Enter the IP address in the browser, if the display It works! representative success!


Third, MySQL installation

# unzip MySQL
[Email protected] soft]# TAR-ZXVF mysql-5.1.73-linux-x86_64-glibc23.tar.gz

# File program moved to the specified installation path
[Email protected] soft]# MV Mysql-5.1.73-linux-x86_64-glibc23/usr/local/mysql

# Create MySQL user, shell status is/sbin/nologin
[[email protected] mysql]# useradd-s/sbin/nologin MySQL

# CREATE DATABASE store directory, change directory permissions
[[email protected] MySQL] #cd/usr/local/mysql
[Email protected] mysql]# mkdir-p/data/mysql
[Email protected] mysql]# chown-r mysql:mysql/data/mysql/

# Enter the/usr/local/mysql, initialize the MySQL library, when there are 2 OK, on behalf of the successful initialization

# Note here that you need to modify the/etc/hosts to add the host name to the file
[[email protected] mysql]# vi/etc/hosts join 192.168.1.6 localhost
[Root[email protected] mysql]#./scripts/mysql_install_db--user=mysql--datadir=/data/mysql
Installing MySQL system tables ...
Ok
Filling Help Tables ...
Ok

# Copy startup scripts, change permissions
[email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysqld
[Email protected] mysql]# chmod 755/etc/init.d/mysqld

# Modify the startup script
[Email protected] mysql]# Vim/etc/init.d/mysqld

Basedir=/usr/local/mysql
Datadir=/home/data/mysql

# copy MySQL config file

[email protected] mysql]# CP support-files/my-large.cnf/etc/my.cnf
Cp:overwrite '/etc/my.cnf '? Y

# Add mysqld to the list of services
[Email protected] mysql]# chkconfig--add mysqld
[Email protected] mysql]# chkconfig mysqld on
[[Email protected] mysql]# service mysqld start
Starting MySQL ... success!
Startup successfully entered the database with/usr/local/mysql/bin/mysql


iv. installation of PHP

# decompression software
[[[email protected] php-5.3.28]# tar-jxvf php-5.4.45.tar.bz2
[[email protected] PHP-5.3.28] #cd   php-5.4.45
# into the php file directory, edit parameters
[email  protected] php-5.3.28]#/configure--prefix=/usr/local/php--WITH-APXS2=/USR/LOCAL/APACHE2/BIN/APXS-- With-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-libxml-dir--with-gd--with-jpeg-dir --with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt-- Enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exif--disable-ipv6
# performing a compilation installation
[[email protected] php-5.3.28]# make
[[email protected] php-5.3.28]# make install

v. PHP and Apache combination

Modify the Apache configuration file
[Email protected] ~]# vim/usr/local/apache2/conf/httpd.conf
DirectoryIndex index.html index.htm index.php add index.htm and index.php
AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
AddType application/x-httpd-php. PHP Plus this line, add to the parsing of PHP
#说明: To support PHP script parsing, you must add the corresponding type

LoadModule php5_module modules/libphp5.so Open Php5_module
After saving
Detection/usr/local/apache2/bin/apachectl-t
Start/usr/local/apache2/bin/apachectl Restart
To see if it starts:
[Email protected] ~]# NETSTAT-LNP |grep httpd

TCP 0 0::: +:::* LISTEN 7867/httpd

# Write PHP parsing test files
[Email protected] ~]# vim/usr/local/apache2/htdocs/test.php
<?php
Phpinfo ();
?>

Enter the 192.168.1.6/test.php address in the browser, display the PHP interface, representing the success of parsing PHP


This article is from the "Practical Linux knowledge and Skills sharing" blog, please be sure to keep this source http://superleedo.blog.51cto.com/12164670/1890429

Example of LAMP environment construction

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.