LAMP Environment Construction

Source: Internet
Author: User

1.0 Mysql the installation

There are 4 ways to install MySQL: yum/rpm package installation Binary installation source code compilation and installation of source code software combined

The difference between the binary package name and the source package name is as follows:

Binary Package Name: mysql-5.5.32-linux2.6-x86.tar.gz

SOURCE Package Name: mysql-5.5.32.tar.gz


The installation steps are as follows:

1. Create MySQL user account

# useradd-s/sbin/nologin-m MySQL

2. Go to the fixed directory to install the software download MySQL package

1) # CD/USR/LOCAL/SRC Note: This directory can be used as a fixed directory dedicated to all installed software

2) # wget download URL (or use the tool to enter)

3. Unzip and move the MySQL binary package to the specified installation path

1) # tar zxvf mysql-5.5.32-linux2.6-x86.tar.gz

2) # MV Mysql-5.5.32/usr/local/mysql

3) # Cd/usr/local/mysql

4. Initialize MySQL configuration file my.cnf

#/BIN/CP support-files/my-large.cnf/etc/my.cnf

Note: There are 5 different configuration templates for my.cnf under Support-files, and in the production environment, the requirements for server hardware from 5 different configuration templates are low to High:

MY-MEDIUM.CNF my-small.cnf my-large.cnf my-huge.cnf

My-innodb-heavy-4g.cnf

5. Initializing MySQL database files

1) # mkdir-p/data/mysql build MySQL data file directory

2) # Chown-r Mysql:mysql/data/mysql authorized MySQL user to manage MySQL installation directory

3) #./scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/mysql--User=mysql

There are two OK words, which means the initialization is successful or the problem of initialization is resolved.

echo $? Check installation status

6. Set MySQL startup script

1) # CP./SUPPORT-FILES/MYSQL.SERVER/ETC/INIT.D/MYSQLD copy mysql boot script to

MySQL Command Path

2) # chmod +x/etc/init.d/mysqld or

chmod 755/etc/init.d/mysqld

3) # Vim/etc/init.d/mysqld

Basedir=/usr/local/mysql

Datadir=/data/mysql

7. Start the database and check that the startup is successful

1) #/etc/init.d/mysqld start start

2) # PS aux |grep MySQL or

# netstat-lnptu |grep MySQL

Check whether the startup is successful, if the startup prompt has errors, view the error log, troubleshoot the issue based on the error log

8. View MySQL Database Startup results log

mysql error log path/data/mysql/www.err error logs are typically named after the hostname. Err.

9. Set MySQL to start

1) # Chkconfig--add mysqld Add to boot

2) # Chkconfig mysqld on set to start

3) # chkconfig--list mysqld check MySQL startup status at each operating level of the system

10. Configure the global use path for MySQL commands

1) # echo ' Export path=/usr/local/mysql/bin: $PATH ' >>/etc/profile

Note: Echo is followed by a single quotation mark

2) # Tail-1/etc/profile Check if the configuration added above is successful

3) # Source/etc/profile immediate effect

4) # echo $PATH View Settings results

11. Login MySQL Test

# mysql

There are three other ways to log in:

1) # Mysql-uroot-p

2) # Mysql-uroot

3) # Mysql-uroot-p ' Password '

12. Set the password for the root user of MySQL

# mysqladmin-u root password ' password '

# mysql-uroot-p ' Password '

1.1 Apache the installation

# cd/usr/local/src/
# wget Binary Package

# tar ZXVF httpd-2.2.16.tar.gz

to Configure the compilation parameters:

# CD 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

--prefix specify where to install, --enable-so means to enable DSO [1] --enable-deflate=shared represents the shared way of compiling deflate, followed by the same parameters.

Error:mod_deflate have been requested but can is built due to prerequisite failures

The solution is:

Yum Install-y zlib-devel

To avoid errors in make, it is best to install some library files in advance:

Yum install-y pcre pcre-devel Apr apr-devel

Compile, install:

# make

# make Install

The above two steps can be used echo $? to check for proper execution, or you need to fix the problem based on the error.

1.2 PHP the installation

# CD/USR/LOCAL/SRC
# wget http://am1.php.net/distributions/php-5.3.27.tar.gz

# tar zxf php-5.3.27.tar.gz

To configure the compilation parameters:

# CD php-5.3.27
#./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

Note:

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

The solution is: Yum install-y libxml2-devel


Configure:error:Cannot find OpenSSL ' s <evp.h>

The solution is: Yum install-y OpenSSL Openssl-devel


Checking for BZIP2 in default path ... not found
Configure:error:Please Reinstall the BZIP2 distribution

Workaround: Yum install-y bzip2 Bzip2-devel


Configure:error:png.h not found.

Workaround: Yum install-y libpng libpng-devel


Configure:error:freetype.h not found.

Workaround: Yum install-y freetype Freetype-devel


Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.

Workaround: RPM-IVH "RPM Package Address"
Yum Install-y libmcrypt-devel

Because the centos6.x default Yum source does not have a libmcrypt-devel package, only third-party yum sources are available.

Compile and install:

# make

# make Install

Copy the configuration file:

# CP Php.ini-production/usr/local/php/etc/php.ini


1.3 Apache with PHP

The Apache master configuration file is:/usr/local/apache2/conf/httpd.conf

Vim/usr/local/apache2/conf/httpd.conf

Found it:

AddType application/x-gzip. gz. tgz

Under this line, add the following:

AddType application/x-httpd-php. php

Found it:

<ifmodule dir_module>
DirectoryIndex index.html
</IfModule>

Change the line to read:

<ifmodule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>

Found it:

#ServerName www.example.com:80

Modified to:

ServerName localhost:80

1.4 Test if lamp is successful

Verify that the configuration file is correct before starting Apache:

/usr/local/apache2/bin/apachectl-t

If there is an error, please continue to modify httpd.conf, if it is correct, then display as "Syntax OK",

The command to start Apache is:

#/usr/local/apache2/bin/apachectl Start

To see if it starts:

# NETSTAT-LNP |grep httpd
TCP 0 0::: +:::* LISTEN 7667/httpd

If this line is displayed, it is started. You can also use the Curl command to simply test:

# curl localhost


Test if PHP is parsed correctly:

vim/usr/local/apache2/htdocs/1.php

Write:

<?php
echo "PHP parsing normal";
?>

: Wq

# Curl Localhost/1.php
PHP parsing normal [[email protected] ~]#

Display this means that the resolution is correct

The first time you use a browser to access a Web service, you may not be able to access it because of the firewall. Please run the following command:

# iptables-f


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.