LAMP architecture construction details, source code compilation and installation

LAMP architecture construction details

LAMP overview

LAMP refers to a group of free software acronyms that are usually used together to run dynamic websites or servers

  • Linux, operating system
  • Apache, web server
  • MariaDB or MySQL, database management system (or database server)
  • PHP, Perl or Python, scripting language

Linux operating system is self-provided, here we are using Centos 7 system

The order of installation,
Linux-Apache-Mysql-PHP
2 and 3 are variable, but the scripting language must be installed last

Software package

partpackage
Apacheapr-1.6.2.tar.gz
apr-util-1.6.0.tar.gz
httpd-2.4.29.tar.bz2
Mysqlmysql-5.7.17.tar.gz
boost_1_59_0.tar.gz
PHPphp-7.1.10.tar.bz2
forumDiscuz_X3.4_sC_UTF8.zip

Download these packages to Linux, where I store them in the opt directory

Insert picture description here

Next we build

Apache source code compilation

  1. Installation environment dependent packages
yum -y install gcc gcc-c++ make pcre pcre-devel expat-devel perl
Insert picture description here
  1. Configuration software module

3 packages needed to decompress

tar zxvf apr-1.6.2.tar.gz
tar zxvf apr-util-1.6.0.tar.gz
tar jxvf httpd-2.4.29.tar.bz2
Insert picture description here

Install the module

./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
  1. Compile and install

make && make install
can add -j4 number after make to the number of cpu cores of this machine, which can speed up compilation

Insert picture description here
  1. Use soft links to optimize the path of configuration files
ln -s /usr/local/httpd/conf/httpd.conf /etc/
  1. Use a soft link to put the httpd executable program file in the path variable for easy system identification
ln -s /usr/local/httpd/bin/* /usr/local/bin/
Insert picture description here
  1. Add httpd system service
Insert picture description here


Insert picture description here
  1. Modify the httpd service configuration file
vim /etc/httpd.conf
Insert picture description here


Insert picture description here


Insert picture description here
Insert picture description here
  1. verification
Insert picture description here


Insert picture description here


Insert picture description here


Insert picture description here


Configuration complete

Mysql source code compilation

  1. Installation environment dependent packages
yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake
Insert picture description here
  1. Configuration software module

Unzip the package

tar zxvf mysql-5.7.17.tar.gz
tar zxvf boost_1_59_0.tar.gz
Insert picture description here
CMake
-DCMAKE_INSTALL_PREFIX = / usr / local / MySQL
-DMYSQL_UNIX_ADDR = / usr / local / MySQL / mysql.sock
-DSYSCONFDIR = / etc
-DSYSTEMD_PID_DIR = / usr / local / MySQL
-DDEFAULT_CHARSET = UTF8
-DDEFAULT_COLLATION = utf8_general_ci
-DWITH_EXTRA_CHARSETS = All
- DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
-DMYSQL_DATADIR=/usr/local/mysql/data
-DWITH_BOOST=/
usD=1 /local/ SYSTEM

Note: If there is an error in the process of CMAKE, after the error is resolved, you need to delete the CMakeCache.txt file in the source directory, and then re-CMAKE, otherwise the error will remain

  1. Compile and install

make && make install

  1. Create mysql user
useradd -M -s /sbin/nologin mysql
Insert picture description here


No password is specified here, set it up later

  1. Modify the mysql configuration file
Insert picture description here


Insert picture description here
  1. Change the owner group of the mysql installation directory
chown -R mysql:mysql /usr/local/mysql/
Insert picture description here
  1. Change the permissions of the mysql configuration file
chown mysql:mysql /etc/my.cnf
Insert picture description here
  1. Set the path environment variable
echo'export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
source /etc/profile
Insert picture description here
  1. Initialize the database
Insert picture description here
  1. Add mysqld system service and modify mysql login password
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
mysqladmin -u root -p password “123456”
Insert picture description here


Insert picture description here
  1. Authorize remote login
mysql -u root -p
grant all privileges on *.* to 'root'@'%' identified by '123456';
Insert picture description here


Configuration complete

PHP source code compilation

  1. Installation environment dependent packages
Insert picture description here
  1. Configuration software module
Insert picture description here
  1. Compile and install

make && make install

  1. Modify the PHP main configuration file, make a backup and modify it
cp /opt/php-7.1.10/php.ini-development /usr/local/php7/php.ini
Insert picture description here


Insert picture description here


Insert picture description here


Insert picture description here
  1. Optimized to put the PHP executable program file into the directory of the path environment variable for easy system identification
ln -s /usr/local/php7/bin/* /usr/local/bin/
Insert picture description here
  1. Modify the configuration file of the httpd service to allow Apache to support PHP
vim /etc/httpd.conf
Insert picture description here


Insert picture description here
  1. Verify PHP test page
Insert picture description here


To verify, remember to restart the service

Insert picture description here


Insert picture description here


Completed