lamp architecture (1) installation

lamp architecture

One, install mysql

1. Download the mysql package to src

wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

Unzip

tar -zxf mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz

Move the unzipped directory and rename it

mv mysql-5.6.47-linux-glibc2.12-x86_64 /usr/local/mysql

2. Create a mysql user

useradd mysql

Create a directory to store data

cd /usr/local/mysql
mkdir -p /data/mysql;chown -R mysql:mysql /data/mysql

3. Compile mysql

Install perl environment

 yum install -y perl-Module-Install

Compile

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

4. Configuration file

Copy my-default.cnf

cp support-files/my-default.cnf  /etc/my.cnf

And edit

# basedir = /usr/local/mysql
# datadir = /data/mysql
# port = 3306
# server_id = 255
# socket = /tmp//mysql.sock

basedir is the installation directory, datadir is the created data directory, id is the local ip

Insert picture description here

Copy the mysql startup file

cp support-files/mysql.server /etc/init.d/mysqld

And edit

basedir=/usr/local/mysql
datadir=/data/mysql
Insert picture description here

5. Start the mysql service

Add mysql startup

chkconfig --add mysqld
chkconfig mysqld on

Start service

service mysqld start

Two, install Apache

1. Download httpd package, apr package, apr-util package

wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.27.tar.gz
 wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.gz
 wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.4.tar.gz

And unzip

tar -zxf apr-1.7.0.tar.gz
tar -zxf apr-util-1.6.1.tar.gz 
tar -zxf httpd-2.4.46.tar.gz 

2. Compile and install apr

cd apr-1.7.0.tar.gz
./configure --prefix=/usr/local/apr

Lack of libtool database

Insert picture description here


installation

yum install -y libtool*

Compile again

./configure --prefix=/usr/local/apr
make && make install

3. Compile and install apr-util

cd /usr/src/apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install

Show lack of dependency expat

Insert picture description here


install expat-devel

yum install -y expat-devel
make && make 

4. Compile and install httpd

Enter the decompressed httpd directory to
compile

./configure \
> --prefix=/usr/local/apache2.4 \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util \
> --enable-so \
> --enable-mods-shared=most

Display error

Insert picture description here


Need to install pcre-devel

yum install -y pcre-devel

Compile again

./configure \
> --prefix=/usr/local/apache2.4 \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util \
> --enable-so \
> --enable-mods-shared=most
make && make install

make shows an error

Insert picture description here

The reason is that the file is wrong.
Copy apr and apr-util to /srclib under http

cp -r apr-1.7.0 httpd-2.4.46/srclib/apr
cp -r apr-util-1.6.1 httpd-2.4.46/srclib/apr-util

Clear make first

make clean

Recompile

./configure --prefix=/usr/local/apache2.4 --enable-so --with-pcre --with-included-apr --enable-modules=most --enable-mps-shared=all --with-mpm=prefork
make && make install

5. You can view the loaded modules

/usr/local/apache2.4/bin/httpd -M 
Insert picture description here

Three, install php5

1. Download and install php5

cd /usr/src/
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar -zxf php-5.6.30.tar.gz 

2. Compile

Install the required dependencies first

yum install libxml2-devel bzip2 bzip2-devel libpng libpng-devel openssl openssl-devel freetype freetype-devel epel-release -y
yum install libmcrypt-devel -y

Recompile

cd php-5.6.30
 ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --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

And make install

make && make install

3. Copy the configuration file

cp php.ini-production /usr/local/php/etc/php.ini