Linux amp Build

Source: Internet
Author: User
Tags curl install php mcrypt php script unpack

Linux Lamp Setup

First, install MYSQl

1. Download the MySQL package to this directory

cd/usr/local/src/


2. Download package

wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz

Note: The above address is for 32-bit machines, if your machine is 64-bit, download this package (http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-x86_64- ICC-GLIBC23.TAR.GZ) installation method is the same.

Need to install wget package, not installed by default

[email protected] src]# Yum install-y wget


3. Unpack the Package

Tar zxvf/usr/local/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz


4, the extracted files moved to the/usr/local/directory, and renamed to MySQL, this step needs to be noted, in the move to ensure that the/usr/local/directory is not the name of MySQL,

If so, it would be wrong to move the file to MySQL.

[Email protected] src]# MV Mysql-5.1.40-linux-x86_64-icc-glibc23/usr/local/mysql


5. Create a MySQL user and disable login

Useradd-s/sbin/nologin MySQL


6, enter into the/usr/local/mysql, as if not to enter this directory is also possible

Cd/usr/local/mysql


7. Create/data/mysql Directory

Mkdir-p/data/mysql


8. Change the owner and group of the/data/mysql directory

Chown-r Mysql:mysql/data/mysql


9, in the current directory initialization (the current directory refers to the/usr/local/mysql directory)

./scripts/mysql_install_db--user=mysql--datadir=/data/mysql

This step is to make a mistake, the original is not installed shared library, so if this step error, see if there is a shared library installed

Install the shared library: Yum Install compat-libstdc++-33

View/date/mysql Next generation two directories after completion: MySQL and test directories


10, under the current directory (/usr/local/mysql directory) Copy the template to the/etc/directory, and renamed to MY.CNF

CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF

Use Vim to enter the My.cnf file to turn off the following features:

Log-bin=mysql-bin

Binlog_format=mixed

Server-id = 1


11, copy the boot file to/etc/init.d/under the name Mysqld (also in the/usr/local/mysql directory)

CP Support-files/mysql.server/etc/init.d/mysqld

chmod 755/etc/init.d/mysqld (This step does not seem to be possible)


12. Modify the/etc/init.d/mysqld file

Vim/etc/init.d/mysqld #修改datadir

Modify the following configuration:

Basedir=/usr/local/mysql #定义了mysql所在的路径

Datadir=/data/mysql #数据存放路径


13. Add to System list

Chkconfig--add mysqld


14. Set Boot start

Chkconfig mysqld on


15. Restart MySQL

/etc/init.d/mysql start

[[email protected] mysql]#/etc/init.d/mysqld start

Starting MySQL ... success! #这个提示表示mysql已经启动成功


16, use PS aux |grep mysql to check to see if there is a MySQL process

Use NETSTAT-LNP to see if there are 3306 ports



Second, install Apache

1. Download Apache (also download to/usr/local/src/directory)

wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz


2. Unpack the Apache Package

Tar zvxf httpd-2.2.16.tar.gz


3. Enter the httpd-2.2.16 directory

CD httpd-2.2.16

[Email protected] src]# CD httpd-2.2.16


4, start compiling, if there is no documentation, go to the install file to see the help (this document is in the/usr/local/src/httpd-2.2.16 directory)

Information to view in the install file:

$./configure--prefix=prefix #指定安装的目录在哪里

$ make

$ make Install

$ prefix/bin/apachectl Startt

5, configure the compilation parameters (/usr/local/src/httpd-2.2.16 directory)

./configure--prefix=/usr/local/apache2--enable-mods-shared=most--enable-so

--prefix=: Installation path

--enable-mods-shared=most: Most of the modules installed are installed in a shared manner and are dynamic, as they are used

Static memory-intensive

--ENABLE-SO: Enable DOS

This step is wrong, the information is as follows: prompted to install GCC

Configure:error:in '/USR/LOCAL/SRC/HTTPD-2.2.16/SRCLIB/APR ':

Configure:error:no acceptable C compiler found in $PATH

See ' Config.log ' for more details.

Configure failed for SRCLIB/APR

Need to install GCC

Installing Gcc:yum Install gcc-c++

6. Compiling

Makes && make install can be written on the same line, but it is separated by two && symbols. can also be written separately


Make install


7, after the completion of the compilation into the/usr/local/apache2/directory view

After entering the/usr/local/apache2/directory, use/bin/ls to view the modules directory, which holds the module


8. Check

[[email protected] httpd-2.2.16]#/usr/local/apache2/bin/httpd-t: Check configuration file for errors

[Email protected] httpd-2.2.16]#/usr/local/apache2/bin/httpd-l: View the core

[[email protected] httpd-2.2.16]#/usr/local/apache2/bin/httpd-m: Show All loaded modules

[[email protected] httpd-2.2.16]# Cat/usr/local/apache2/build/config.nice: View Historical Compilation configuration


9. Start Apache

[[email protected] httpd-2.2.16]#/usr/local/apache2/bin/apachectl start

/usr/local/apache2/bin/apachectl Start/stop/restart

/usr/local/apache2/bin/apachectl Graceful/graceful-stop

Start: Used to start the Apache service, first check the Apache configuration file is wrong, there is no error to start the service, such as incorrect output error message;

Stop: Used to stop the Apache server, if you have stopped the Apache server will be error;

Restart: Reboot the Apache server and launch it if Apache does not start;

Graceful: As with the start parameter, the difference is that it does not interrupt the connection being processed, nor does it close the log. Recommended use.

Graceful-stop: As with the stop parameter, the difference is that it does not interrupt the connection being processed, nor does it close the log, which is recommended.


10. See if you have started

[[email protected] apache2]# ps aux |grep httpd  root      58464  0.0  0.2 124448  2524 ?         ss   20:35   0:00 /usr/local/apache2/bin/ httpd -k start  daemon   58465  0.0  0.1 124448   1736 ?        S    20:35    0:00 /usr/local/apache2/bin/httpd -k start  daemon   58466   0.0  0.1 124448  1736 ?         S    20:35   0:00 /usr/local/apache2/bin/httpd -k  start  daemon   58467  0.0  0.1 124448  1736  ?          s    20:35   0:00 /usr/local/apache2/bin/httpd -k  start  daemon   58468  0.0  0.1 124448  1736  ?        s    20:35   0:00  /usr/local/apache2/bin/httpd -k start  daemon   58469  0.0   0.1 124448  1736 ?        S     20:35   0:00 /usr/local/apache2/bin/httpd -k start   root     58479  0.0  0.0 103248   872  Pts/0    s+   20:37   0:00 grep httpd

11, when the startup occurs similar to the error message or the like

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/64/wKiom1V6pL3S71GrAAF-jTRRq-Q356.jpg "title=" Error message. jpg "alt=" wkiom1v6pl3s71graaf-jtrrq-q356.jpg "/>

Configuration file needs to be modified: conf/httpd.conf

configuration file: [[email protected] apache2]# vim conf/httpd.conf

In the config file, remove the servername www.example.com:80 in front of the #

In the reboot, there will be no prompt.


12. Testing

Testing in Linux is working

[[email protected] apache2]# curl localhost

Enter the IP address in the browser to test, such as:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/60/wKioL1V6pqrjowfuAADFrjPfq4I082.jpg "title=" Itwork.jpg "alt=" Wkiol1v6pqrjowfuaadfrjpfq4i082.jpg "/>

Out of this it works means that the configuration is successful


./BIN/APACHECTL-T: Detects the same configuration file as the/usr/local/apache2/bin/httpd-t effect

./bin/apachectl Start: Restart

[[email protected] apache2]#./bin/apachectl Graceful: Dispatch a profile without killing the process


Third, install PHP

1, enter the/usr/local/src/directory, download the PHP package


Download package

wget http://cn2.php.net/distributions/php-5.3.28.tar.gz


2. Unpack the Package

Tar zxvf php-5.3.28.tar.gz


3. Go to php-5.3.28 directory, compile and configure PHP

[Email protected] src]# CD 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-freety Pe-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-na Tive-ttf--enable-mbstring--enable-sockets--enable-exif--disable-ipv6

This step will be a variety of errors, according to the prompt to install the required library files, if you do not know the use of Yum list to search,

The error message is as follows: Reference Document: http://sxct168.blog.51cto.com/824373/1640316

1, configure:error:xml2-config not found. Please check your LIBXML2 installation.

# yum Install-y libxml2-devel

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

# yum Install-y openssl-devel

3. Checking for BZIP2 in default path ... not found

Configure:error:Please Reinstall the BZIP2 distribution

# yum Install-y bzip2-devel

4, Configure:error:jpeglib.h not found.

# yum Install-y libjpeg-devel

5, Configure:error:png.h not found.

# yum Install-y libpng libpng-devel

6, configure:error:freetype.h not found.

# yum Install-y freetype-devel

7, configure:error:mcrypt.h not found. Please reinstall Libmcrypt.

# yum Install-y libmcrypt-devel

Grammar:

Yum List |grep-i The name of the error


If no yum source is found, you need to install the Yum extension source

Installing the Yum extension Source: Yum Install-y epel-release


4. Compiling

Make

Make install


After the installation is complete, you can see some files under/bin/ls/usr/local/php


/usr/local/php/bin/hph

PHP's executable file location


/USR/LOCAL/PHP/BIN/PHP-M: See which modules are installed in PHP

/usr/local/php/bin/php-i: View PHP parameters


Iv. configuring Apache with PHP

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

1. Edit the configuration file

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

And then find:

<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


2. Check that the configuration file is correct

[Email protected] php-5.3.28]#/usr/local/apache2/bin/apachectl-t

Syntax OK #出先这个就表示是正确的

3. Start Apache

/usr/local/apache2/bin/apachectl start


V. Testing and parsing PHP

1. Write a PHP script

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

Write:


<?php

echo "PHP parsing normal";

?>

After saving, continue testing:

2. Parse the error

[Email protected] php-5.3.28]# Curl localhost/1.php <?php echo "php parse normal"; ?>

/usr/local/apache2/bin//apachectl-m |grep-i php: Check if the PHP module is loaded

Check the configuration file, the original configuration file is wrong, modified a bit, after restarting the normal

Restart command:/usr/local/apache2/bin/apachectl graceful


3. Analysis

Curl localhost/1.php

[[email protected] php-5.3.28]# Curl localhost/1.php PHP parsing normal #出现这个就表示解析成功了

4, but in the browser parsing, the Chinese appeared garbled, specific

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/64/wKiom1V6qHXRQfvvAAC7WW-VulQ107.jpg "title=" garbled. png "alt=" Wkiom1v6qhxrqfvvaac7ww-vulq107.jpg "/>

Workaround: Change the 1.php script test file

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/61/wKioL1V6q33B4zTXAAE8TGJmelw334.jpg "title=" solution. jpg "alt=" wkiol1v6q33b4ztxaae8tgjmelw334.jpg "/>

Restart service after saving exit

/usr/local/apache2/bin/apachectl Graceful

It's normal to show up in the test.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/65/wKiom1V6qgyAE3IVAAC7ZWCbQCA900.jpg "title=" ok.jpg "alt=" Wkiom1v6qgyae3ivaac7zwcbqca900.jpg "/>

If there is a mistake in the experiment, I hope that the great God can correct me, if I find that there is a mistake in the document, I will also fix it.

This article is from the It Exchange Learning blog, so be sure to keep this source http://sxct168.blog.51cto.com/824373/1661366

Linux amp Build

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.