Lamp Environment Construction (centos6.9+apache2.4+mysql5.7+php7.1)

Source: Internet
Author: User
Tags chmod openssl

Pre-Installation Preparation

CentOS 6.9 64-bit minimized installation

Yum install-y make gcc gcc-c++ perl zlib-devel libaio libpng libpng-devel libjpeg-devel pcre-devel
Yum install-y libxpm-devel OpenSSL openssl-devel libxml2-devel bzip2-devel.x86_64 libjpeg-turbo-devel
Yum install-y freetype freetype-devel libtool cmake ncurses-devel bison re2c curl-devel wget
Rpm-ivh "http://mirrors.sohu.com/fedora-epel/epel-release-latest-6.noarch.rpm"
Yum install-y libmcrypt-devel re2c


First, install MySQL

1. Compiling the installation

Download package

cd/usr/local/src/
wget http://mirrors.sohu.com/mysql/MySQL-5.7/http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-boost-5.7.17.tar.gz

Extract
Tar zxvf mysql-boost-5.7.17.tar.gz

Compile & Install
CD mysql-5.7.17

CMake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/data/mysql \
-DSYSCONFDIR=/ETC \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-dmysql_unix_addr=/tmp/mysql.sock \
-dmysql_tcp_port=3306 \
-denabled_local_infile=1 \
-dwith_partition_storage_engine=1 \
-dextra_charsets=all \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-dwith_boost=./boost/boost_1_59_0/

Make && make install


Note: If a compilation error occurs, do the following and then reconfigure.

Make clean
RM CMakeCache.txt


2. Binary Package Installation
If the compilation process is slow, you can download the compiled binary package to install directly
cd/usr/local/src/
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
Tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

Move to/usr/local/mysql Directory
MV Mysql-5.7.17-linux-glibc2.5-x86_64/usr/local/mysql


3. Build MySQL Users
Useradd-s/sbin/nologin MySQL


Initialize the database and create the system's own database and table

Mkdir-p/data/mysql
Chown-r Mysql:mysql/data/mysql
Cd/usr/local/mysql
./bin/mysqld--initialize--basedir=/usr/local/mysql--datadir=/data/mysql--user=mysql

At the end, a password will be generated and noted.


The following warning appears when initializing:
[Warning] TIMESTAMP with implicit the DEFAULT value is deprecated.
--explicit_defaults_for_timestamp Server Option (see
Documentation for more details).

To cancel this warning, when you start MySQL, add the my.cnf
[Mysqld]
Explicit_defaults_for_timestamp=true


Add services, Copy service scripts to the INIT.D directory, and set boot boot
CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF
CP Support-files/mysql.server/etc/init.d/mysqld
chmod 755/etc/init.d/mysqld
Vi/etc/init.d/mysqld
Modify DataDir

Datadir=/data/mysql


Chkconfig mysqld on
Service mysqld Start

Change Password
/usr/local/mysql/bin/mysqladmin-uroot-p ' The password you just wrote ' Password ' new password '


Second, installation apache2.4

Download Source:

Cd/usr/local/src
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.25.tar.gz

wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.2.tar.gz

wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz

Tar zxvf/usr/local/src/httpd-2.4.25.tar.gz

Tar zxvf/usr/local/src/apr-1.5.2.tar.gz

Tar zxvf/usr/local/src/apr-util-1.5.4.tar.gz

Mv/usr/local/src/apr-1.5.2/usr/local/src/httpd-2.4.25/srclib/apr

Mv/usr/local/src/apr-util-1.5.4/usr/local/src/httpd-2.4.25/srclib/apr-util

cd/usr/local/src/httpd-2.4.25

./configure \--prefix=/usr/local/apache2 \--with-included-apr \--enable-so \--enable-deflate=shared \-- Enable-expires=shared \--enable-rewrite=shared

Make && make install

cd/usr/local/apache2/
VI conf/httpd.conf


Found it
#ServerName www.example.com:80
Change into
ServerName localhost:80


Check the configuration file syntax
Bin/apachectl-t

Configuring Startup Scripts
Cp/usr/local/src/httpd-2.4.25/build/rpm/httpd.init/etc/init.d/httpd

Note that there are three main areas of the file that need to be modified:

HTTPD=${HTTPD-/USR/LOCAL/APACHE2/BIN/HTTPD}
Pidfile=${pidfile-/usr/local/apache2/logs/${prog}.pid}
Conffile=/usr/local/apache2/conf/httpd.conf

Please change the corresponding path according to your actual situation!


Then run the following command:

chmod +x/etc/init.d/httpd
Chkconfig--add httpd
Chkconfig httpd on
/ETC/INIT.D/HTTPD start
NETSTAT-LNP |grep httpd


Third, PHP installation

Cd/usr/local/src
wget http://mirrors.sohu.com/php/php-7.1.3.tar.gz
Tar zxvf php-7.1.3.tar.gz
CD php-7.1.13

./configure \
--prefix=/usr/local/php \
--WITH-APXS2=/USR/LOCAL/APACHE2/BIN/APXS \
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC \
--with-mysql-sock=/tmp/mysql.sock \
--WITH-MYSQLI=SHARED,MYSQLND \
--WITH-PDO-MYSQL=SHARED,MYSQLND \
--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

Make && make install

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


Four, Apache combined PHP


Vi/usr/local/apache2/conf/httpd.conf

Found it

#ServerName www.example.com:80

Change into
ServerName localhost:80


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>


/usr/local/apache2/bin/apachectl-t
Service httpd Restart

Test parsing PHP

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

Write:

<?php
echo "PHP parsing normal";
Echo Phpinfo ();
?>
After saving, continue testing:

Curl localhost/1.php



Lamp Environment Construction (centos6.9+apache2.4+mysql5.7+php7.1)

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.