Compile and install LAMP to test its performance pressure

Source: Internet
Author: User

This article describes how to install apache, php, and mysql. It also accelerates php with xcache and uses the AB command to test the pressure performance of php.

Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04

Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)

Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind

Build a WEB Server Linux + Apache + MySQL + PHP in the LAMP source code Environment

This environment is implemented on one host. The system is Centos6.5 _ 64-bit.

First install httpd-2.4.9;

The configuration after httpd is installed is not described in detail here. For details, click;

Compile and install apr

# Tar xf apr-1.5.0.tar.bz2

# Cd apr-1.5.0

#./Configure -- prefix =/usr/local/apr

# Make & make install

Compile and install apr-util

# Tar xf apr-util-1.5.3.tar.bz2

# Cd apr-util-1.5.3

#./Configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr

# Make & make instal

Compile and install httpd-2.4.9

# Tar xf httpd-2.4.9.tar.bz2

# Cd httpd-2.4.9

#. /Configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd -- enable-so -- enable-ssl -- enable-cgi -- enable-rewrite -- with-zlib -- -pcre -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util -- enables-modules = most -- enable-mpms-shared = most -- with-mpm = event

# Make & make install

--------------------------------------------------------------------------------

2. Compile and install mysql;

Mysql should put its data in a special directory and it should be called an independent device. Therefore, a new partition should be created to store the data and create an LVM volume, mount the file to an empty directory and enable automatic mounting upon startup.

1. Create a 10 Gb partition and change the partition ID to 8e (lvm );

Make the new partition into a logical volume and format it and mount it to the corresponding directory.

[Root @ linux ~] # Vgcreate/dev/sda3

Please enter a physical volume path

Run 'vgcreate -- help' for more information.

[Root @ linux ~] # Pvcreate/dev/sda3

Physical volume "/dev/sda3" successfully created

[Root @ linux ~] # Vgcreate myvg/dev/sda3

Volume group "myvg" successfully created

[Root @ linux ~] # Lvcreate-L 10G-n mydata myvg

Logical volume "mydata" created

Format

[Root @ linux ~] # Mke2fs-t ext4/dev/myvg/mydata

Create a mount directory

[Root @ linux ~] # Mkdir/data

Write it into the configuration file to enable automatic mounting upon startup

[Root @ linux ~] # Vim/etc/fstab

/Dev/myvg/mydata/data ext4 default 0 0

View the Mount directory;

[Root @ linux ~] # Ls/data

Lost + found mydata


2. Create a user to run mysql securely;


[Root @ linux data] # groupadd-r mysql
[Root @ linux data] # useradd-g mysql-l-s/sbin/nologin-M-d/mydata/data mysql
[Root @ linux data] # chown-R mysql: mysql mydata


3. Now you can officially install mysql Data;

Decompress mysql to the/usr/src directory.

[Root @ linux xf] # tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz-C/usr/src

[Root @ linux xf] # cd/usr/src/

[Root @ linux src] # ls

Debug kernels mysql-5.5.33-linux2.6-x86_64


4. Create a link file for mysql and do not change the name of the link file;

[Root @ linux src] # mv/usr/src/mysql-5.5.33-linux2.6-x86_64/usr/local

[Root @ linux src] # cd/usr/local/

[Root @ linux local] # ln-sv mysql-5.5.33-linux2.6-x86_64 mysql

'Mysql'-> 'mysql-5.5.33-linux2.6-x86_64'


5. Modify the Host group of mysql and initialize the data inventory;

[Root @ linux mysql] # chown-R mysql: mysql. Modify the Host group of the current directory and subdirectory

[Root @ linux mysql] # scripts/mysql_install_db -- datadir =/data/mydata/-- user = mysql initializes the database

Installing MySQL system tables...

OK

Filling help tables...

OK

To start mysqld at boot time you have to copy

Support-files/mysql. server to the right place for your system

Please remember to set a password for the MySQL root USER!

To do so, start the server, then issue the following commands:

./Bin/mysqladmin-u root password 'new-password'

./Bin/mysqladmin-u root-h linux.yang.com password 'new-password'

Alternatively you can run:

./Bin/mysql_secure_installation

Which will also give you the option of removing the test

Databases and anonymous user created by default. This is

Stronugly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon:

Cd ..;./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

Cd./mysql-test; perl mysql-test-run.pl

Please report any problems with the./bin/mysqlbug script!


6. Provide a master configuration file for mysql and copy it to the/etc/directory. A data file with the same name will be available under the/etc/directory in advance, which can be overwritten, then edit the/etc/my, conf file and add a directory for storing data.

[Root @ linux mysql] # cp support-files/my-large.cnf/etc/my. cnf

Cp: overwrite '/etc/my. cnf '? Y

[Root @ linux mysql] # ls/etc/my. cnf

/Etc/my. cnf

[Root @ linux mysql] # vim/etc/my. cnf

Thread_concurrency = 4 indicates that the value is the number of CPUs of the current host multiplied by 2.

Datadir =/date/storage location of mydata Database


7. Provide sysv scripts for mysql. Fortunately, mysql itself provides scripts. You only need to copy them and store them in the/init. d/directory;

[Root @ linux mysql] # cd/usr/local/mysql

[Root @ linux mysql] # cp support-files/mysql. server/etc/rc. d/init. d/mysqld

[Root @ linux mysql] # chmod + x/etc/rc. d/init. d/mysqld

Add to service list

[Root @ linux mysql] # chkconfig -- add mysqld

[Root @ linux mysql] #

[Root @ linux mysql] # chkconfig mysqld on


8. Now you can start mysqlb

[Root @ linux mysql] # service mysqld start

Starting MySQL... [OK]

[Root @ linux mysql] # mysql

Welcome to the MySQL monitor. Commands end with; or \ g.

Your MySQL connection id is 1

Server version: 5.5.33-log MySQL Community Server (GPL)

Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql> show databases;

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

| Database |

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

| Information_schema |

| Mysql |

| Performance_schema |

| Test |

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

4 rows in set (0.00 sec)

Mysql> \ q

Bye


After mysql is started, a database file is generated under the/data/mydata/directory, and a special file is generated under the/tmp/directory. The socket file is used if the client is on the local machine, A particularly efficient communication method used by the server on the local machine;


9. Enter the path from the mysql header file to the system header file.

# Ln-sv/usr/local/mysql/include/usr/include/mysql

10. Enter the mysql database file to find the path of the system database;

# Echo "/usr/local/mysql/lib '>/etc/ld. so. conf. d/mysql. conf

Ldconfig allows the system to reread database files

[Root @ linux mysql] # ldconfig-p | grep mysql
Libtcmalloc_minimal.so.0 (libc6, x86-64) =>/usr/local/mysql/lib/libtcmalloc_minimal.so.0
Libmysqlclient_r.so.16 (libc6, x86-64) =>/usr/lib64/mysql/libmysqlclient_r.so.16
Libmysqlclient. so.18 (libc6, x86-64) =>/usr/local/mysql/lib/libmysqlclient. so.18
Libmysqlclient. so.16 (libc6, x86-64) =>/usr/lib64/mysql/libmysqlclient. so.16
Libmysqlclient. so (libc6, x86-64) =>/usr/local/mysql/lib/libmysqlclient. so

11. Modify the PATH environment variable so that the system can directly use mysql-related commands;

Vim/etc/profile. d/mysql. sh is followed by mysql. sh, but it must end with. sh.

Export PATH =/usr/local/mysql/bin: $ PATH

Source/etc/profile. d/mysql. sh can take effect after you repeat the file

12. After installing mysql, You need to delete the anonymous mysql user and add a password to the Administrator;

Directly execute the mysql command to access mysql;

Mysql> use mysql; set the default table

Database changed

Mysql> select user, host, password from user; view

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

| User | host | password |

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

| Root | localhost |

| Root | linux.yang.com |

| Root | 127.0.0.1 |

| Root |: 1 |

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

4 rows in set (0.00 sec)

Mysql> UPDATE user SET password = PASSWORD ('redhat') WHERE user = 'root'; change the password of all users to redhat

Query OK, 4 rows affected (0.00 sec)

Rows matched: 4 Changed: 4 Warnings: 0

Mysql> select user, host, password from user;

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

| User | host | password |

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

| Root | localhost | * 84BB5DF4823DA319BBF86C99624479A198E6EEE9 |

| Root | linux.yang.com | * 84BB5DF4823DA319BBF86C99624479A198E6EEE9 |

| Root | 127.0.0.1 | * 84BB5DF4823DA319BBF86C99624479A198E6EEE9 |

| Root |: 1 | * 84BB5DF4823DA319BBF86C99624479A198E6EEE9 |

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

4 rows in set (0.00 sec)

Mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

The mysql database has been installed.

  • 1
  • 2
  • 3
  • Next Page

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.