LAMP platform deployment and lamp deployment

Source: Internet
Author: User
Tags form post ldap mcrypt unpack website server

LAMP platform deployment and lamp deployment
LAMP platform Overview

LAMP environment script deployment: https://github.com/spdir/ShellScripts/tree/master/lamp

Introduction to LAMP: Baidu encyclopedia

Components of the LAMP platform:

  • Linux operating system
  • Apache
  • MySQL/mogodb
  • PHP/Perl/Python

Advantages of LAMP platform:

  • Low Cost
  • Customization
  • Easy to develop
  • Easy to use

Components in this article: Linux (CentOS6.5), Apache, MySQL, PHP

Compile and install the Apache (httpd) Service

Apache Introduction: Baidu encyclopedia

Apache features: open source code, cross-platform applications, support for various Web programming languages, modular design, extremely stable operation, and good security

Apache source package: http://httpd.apache.org/download.cgi

Installation steps:

1. Check whether the server has an httpd service installed in RPM mode (to prevent port conflict)

rpm -e httpd --nodeps

2. Compile and install the httpd source code package

Tar zxvf httpd-2.2.17.tar.gz-C/usr/src/# unpack cd/usr/src/httpd-2.2.17 /. /configure -- prefix =/usr/local/httpd/-- enable-so -- enable-rewrite -- enable-charset-lite -- enable-cig # configure make & make install # compile and install

Description of configuration parameters:

  • -- Prefix: Specifies the directory to which the httpd service program is installed, such as/usr/local/httpd;
  • -- Enable-so: enable dynamic loading module support, so that httpd can be further expanded;
  • -- Enable-rewrite: enable the web address rewriting function for website optimization and directory migration and maintenance;
  • -- Enable-charset-lite: enable character set support to support web pages using various character encoding;
  • -- Enable-cgi: enable CGI script program support to expand the application access capability of the website;

The main directory structure of the httpd service:

  • Service Directory:/usr/local/httpd/
  • Main configuration file:/usr/local/httpd/conf/httpd. conf
  • Webpage Directory:/usr/local/httpd/htdocs/
  • Service Script:/usr/local/httpd/bin/apachectl
  • Execution program:/usr/local/httpd/bin/httpd
  • Access log:/usr/local/httpd/log/access_log
  • Error log:/usr/local/httpd/log/error_log

3. Optimize the execution path

ln -s /usr/local/httpd/bin/* /usr/local/bin

4. Add httpd to System Service

Cp/usr/local/httpd/bin/apachectl/etc/init. d/httpdcd/etc/init. d/chmod + x httpdvim/etc/init. d/httpd # add it to the configuration file
1 #! /Bin/sh2 # chkconfig: 2345 81 25 // service identification parameter, which is started in runtime level 2345. The sequence of startup and shutdown is 81,253 # description: this is Apache Server // service description information 4 # Content omitted ......Modify the httpd file chkconfig -- add httpd # add httpd as a system service
Chkconfig httpd on # view the self-starting status of the httpd service

Common global configuration parameters (httpd. conf)

1 ServerRoot: Service Directory 2 ServerAdmin: Administrator mailbox 3 User: User identity of the running service 4 Group: Group identity of the running service 5 ServerName: Domain Name of the website Server 6 DocumentRoot: the root directory of the Web document 7 Listen: listening IP address, Port Number 8 PidFile: Saving the httpd process PID Number file 9 DirectoryIndex: Default index page file 10 ErrorLog: location of the Error Log File 11 CustomLog: Location of the access log file 12 LogLevel: log record level, default value: warn13 Timeout: network connection Timeout, default value: 300 seconds 14 KeepAlive: whether to maintain the connection. Optional options: On or Off15 MaxKeepAliveRequests: Maximum number of requested files for each connection: 16 KeepAliveTimeout: timeout time when the connection is maintained 17 Include: other configuration files to be included

Regional configuration items

<Directory/> // define "/" the start Options FollowSymLinks of the Directory area // control Options, which allow the use of symbolic links AllowOverride None // do not allow overwrite configuration Order deny in the implicit control file, application order of the allow // access control policy Deny from all // prohibit anyone from accessing this region </Directory> // define "/" end of the Directory Area

Deploying an AWStats Website access statistical analysis system: http://www.cnblogs.com/zhichaoma/p/7487766.html

Virtual Host Configuration: http://www.cnblogs.com/zhichaoma/p/7489043.html

Site access restriction: http://www.cnblogs.com/zhichaoma/p/7488898.html

Compile and install MySQL Service

MySQL Introduction: Baidu encyclopedia

Source MySQL package: https://dev.mysql.com/downloads/

Installation steps:

1. Preparations

Uninstall the mysql-server and mysql software packages installed in RPM mode (to avoid port conflicts and program conflicts)

rpm -e mysql-server mysql

Install the ncurses-devel dependency package using rpm or yum

Rpm-ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm or yum-y install ncurses-devel

Compile and install the cmake package

tar zxvf cmake-2.8.6.tar.gz -C /usr/src/cd /usr/src/cmake-2.8.6/./configure && gmake && gmake install

Create a running user

# Delete the original mysql account userdel mysql of the system and create a new mysql account useradd-M-s/sbin/nologin mysql

Compile and install the mysql package

Tar zxvf mysql-5.5.22.tar.gz-C/usr/src/# unpack cd/usr/src/mysql-5.5.22/cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DSYSCONFDIR =/etc/-DDEFAULT_CHARSET = utf8 -DDEFAULT_COLLATION = utf8_general_ci-DWHIT_CHARSETS = all # configure make & make install # compile and install

Description of configuration parameters:

  • -DCMAKE_INSTALL_PREFIX: Specifies to install the mysql database program to a directory, such as/usr/local/mysql;
  • -DSYSCONFDIR: Specifies the directory of the initialization parameter file;
  • -DDEFAULT_CHARSET: Specify the default character set encoding, for example, utf8;
  • -DDEFAULT_COLLATION: Specifies the default character set verification rules, utf8_general_ci is a general rule for the UTF-8 Character Set;
  • -DWHIT_CHARSETS = all: specify other supported string encoding;

2. Adjustment after installation

Adjust the database directory

chown -R mysql:mysql /usr/local/mysql/

Create a configuration file

Rm-rf/etc/my. cnf // if my. the cnf file can delete cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf

Initialize Database

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

Optimized execution path

ln -s /usr/local/mysql/bin/* /usr/local/bin/

Add System Service

cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld    chmod +x /etc/rc.d/init.d/mysqld chkconfig --add mysqldchkconfig mysqld onservice mysqld start

Initialize the root password of the Database Administrator Account

mysqladmin -u root password "123.com"

Basic Database Operations:

Build a PHP Runtime Environment

PHP source package: http://php.net/downloads.php

Installation steps:

1. Preparations

Uninstall php, php-cli, php-ldap, php-common, php-mysql and other software packages installed in RPM mode (to avoid program conflicts)

rpm -e php php-cli php-ldap php-common php-mysql --nodeps

Install zlib-devel and libxml2-devel dependency packages using rpm or yum

Rpm-ivh zlib-devel-1.2.3-29.el6.x86_64.rpmrpm-ivh libxml2-devel-2.7.6-14.el6.x86_64.rpm or yum-y install zlib-develrpm-y install libxml2-devel

2. Install the php encryption extension plug-in (libmcrypt, mhash, mcrypt) ** for sequential Installation

Install the libmcrypt Program

: Http://mcrypt.hellug.gr/lib/

tar zxvf libmcrypt-2.5.8.tar.gz -C /usr/src/cd /usr/src/libmcrypt-2.5.8/./configure && make && make installln -s /usr/local/lib/libmcrypt.* /usr/bin/

Install the mhash Program

: Https://sourceforge.net/projects/mhash/files/mhash/

tar zxf mhash-0.9.9.9.tar.gz -C /usr/src/cd /usr/src/mhash-0.9.9.9/./configuremake && make installln -s /usr/local/lib/libmhash.* /usr/lib/

Install the mcrypt Program

: Https://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/

tar zxf mcrypt-2.6.8.tar.gz -C /usr/src/cd /usr/src/mcrypt-2.6.8/./configureexport LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH./configuremake && make install

3. Compile and install PHP

tar zxf php-5.3.28.tar.gz -C /usr/src/cd /usr/src/php-5.3.28/./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs     --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring     --enable-socketsmake && make install

Description of configuration parameters:

  • -- Prefix: Specify the directory to which the PHP program is installed, such as/usr/local/php5;
  • -- With-mcrypt: supports data encryption and other extension tools;
  • -- With-apxs2: set the File Location of the apxs module Support Program provided by Apache HTTP Server;
  • -- With-mysql: Set the installation location of the MySQL database service program;
  • -- With-config-file-path: Set the location where the PHP configuration file php. ini will be stored;
  • -- Enable-mbstring: enables the multi-string function to support Chinese and other code;
  • -- Enable-sockets: supports sockets;

4. php. ini file Adjustment

Cp/usr/src/php-5.3.28/php. ini-development/usr/local/php5/php. inivim/usr/local/php5/php. ini # modify in the configuration file
Default_charset = "UTF-8" // sets the default Character Set UTF-8; file_uploads = On // allows file upload through the PHP web page; upload_max_filesize = 2 M // specifies the size of the file to be uploaded; max_file_uploads = 20 // maximum number of files that can be uploaded by each HTTP request; post_max_size = 8 M // data size limit submitted by form post each time; short_open_tag = on // allow the identification of PHP phrase tags, <?...?>;Modify the php. ini configuration file

5. added the ZendGuardLoader optimization module.

ZendGuardLoader package download: http://www.zend.com/en/products/guard/downloads#Linux

Further improve the execution efficiency of PHP programs and optimize the page loading speed

Tar zxf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz-C/usr/src/cd/usr/src/ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/cp ZendGuardLoader. so/usr/local/php5/lib/php vim/usr/local/php5/php. ini # Add a configuration file
1 # Add 2 zend_extendsion =/usr/local/php/lib/php/ZendGuardLoader. O3 zned_loader = 1 at the endModify the php. ini configuration file

6. httpd. conf configuration Adjustment

Vim/usr/local/httpd/conf/httpd. conf # modify the httpd configuration file
LoadModule php5_module modules/libphp5.so # If php is installed successfully, this file AddType application/x-httpd-php. php # Add DirectoryIndex index. php index.html # modifyModify the httpd configuration file

Service httpd restart # restart httpd

7. Test

Test 1: Test whether the php file can be parsed properly (php test code)

1 <?php2 phpinfo();3 ?>

Test 2: test whether php Web pages can normally connect to the Database Service (php test code)

1 <? Php2 $ link = mysql_connect ('localhost', 'root', '2017. com '); 3 if ($ link) echo "database connection successful"; 4 mysql_close (); 5?>

8. Deploy phpMyAdmin (developed using php)

Tar zxf phpMyAdmin-2.11.11.3-all-languages.tar.gzmv phpMyAdmin-2.11.11.3-all-languages/usr/local/httpd/htdocs/phpMyAdmin # Place the source code under the root directory of the website cd/usr/local/httpd/htdocs/phpMyAdmin/cp config. sample. inc. php config. inc. php # create a configuration file

 

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.