Source code compilation and installation LAMP

catalogue

Foreword

1.LAMP introduction and overview

2.Apache

2.1Apache origin

2.2 introduction to Apache

3.httpd 

3.1 compiling and installing httpd server

3.2 compiling and installing httpd server

4. Install MYSQL

4.1 installing MYSQL

4.2sql_ The common values of mode are as follows:

4.3 setting environment variables

 5. Install PHP

6. Installation Forum

summary

Foreword

1. Do you know Apache website service? MySQL service? PHP services? LAMP architecture application real column?  

1.LAMP introduction and overview

(1) Overview of LAMP platform LAMP architecture is one of the mature enterprise website application modes at present. It refers to a whole system and related software working together, which can provide dynamic web site services and its application development environment
LAMP is an abbreviation, including Linux operating system, Apache Web server, MySQL database server, PHP (or perl, Python) web programming language
(2) . sequence of building LAMP platform when building LAMP platform, the installation sequence of each component is Linux, Apache, MySQL and PHP
There is no strict sequence requirement for the installation of Apache and MySQL, while the installation of PHP environment is generally put at the end, which is responsible for communicating the web server and database system to work together
(2) Advantages of compilation and installation 1. It has a large degree of freedom and customizable functions. 2. It can obtain the latest software version in time. 3. It is generally applicable to most Linux versions and is easy to use all the time
(3) Main functions of components
(platform) Linux: as the basis of LAMP architecture, it provides the operating system used to support the Web site, which can provide better stability and compatibility with the other three components (AMP components also support Windows, UNIX and other platforms).  
(front desk) Apache: as the front end of LAMP architecture, it is a powerful and stable Web server program. The server directly provides users with website access, sending Web pages, pictures and other file contents.  
(background) MySQL: as the back end of LAMP architecture, it is a popular open source relational database system. In enterprise websites, business systems and other applications, various account information, product information, customer information and business data can be stored in MySQL database. Other programs can query and change these information through SQL statements.  
(intermediate connection) PHP/Perl/Python: as three programming languages for developing dynamic Web pages, it is responsible for interpreting dynamic Web page files, communicating the Web server and database system to work together, and providing the development and running environment of Web applications. PHP is a widely used open source multi-purpose scripting language, which can be embedded in HTML, especially suitable for Web application development.

2.Apache

2.1Apache origin

Originated from a patch server, the famous open source Web service software, Apache service program version 1.0 was released in 1995. The Apache Software Foundation (ASF) is responsible for maintaining the latest official website named "Apache HTTP Server": http://httpd.apache.org/  

2.2 introduction to Apache

1. Main features
Open source, cross platform, and timely
Support multiple web programming languages
Modular design, stable operation and good safety
2. Software version
1.X
At present, the highest version is 1.3, which runs stably
Downward compatibility is good, but it lacks some newer functions
2.X
At present, the highest version is 2.4, which has more functional features and 1.4 Compared with X, the configuration management style is quite different
-----------Install Apache - the following two plug-ins are httpd2 Required for versions after 4-----

tar xf apr-1.6.2.tar.gz
tar xf apr-util-1.6.0.tar.gz
tar xf httpd-2.4.29.tar.bz2
mv apr-1.6.2 httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
yum -y install \
gcc \							#C language compiler
gcc-c++ \						#C + + compiler
make \							#Source code compiler (source code to binary file)
pcre \							#pcre is a perl function library, including perl compatible regular expression library
pcre-devel \                    #perl interface development package
expat-devel \                   #It is used to support the website to parse HTML and XML files
perl                            #perl compiler

yum -y install \
gcc \
gcc-c++ \
make \
pcre-devel \
expat-devel \
perl
cd httpd-2.4.29
./configure \
--prefix=/usr/local/httpd \		#Specify the installation path of the httpd service program
--enable-so \					#Enable dynamic loading core module support to enable httpd to further expand its functions
--enable-rewrite \				#Enable the web address rewriting function for website optimization, anti-theft chain and directory migration maintenance
--enable-charset-lite \			#Start character set support to support pages encoded with various character sets
--enable-cgi					#Enable CGI (general Gateway Interface) script program support to facilitate the external expansion of application access capability of the website

cd /opt/httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

make && make install


#Optimize the configuration file path, and put the executable program file of httpd service into the directory of path environment variable for system identification
ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/ 
#Convenient for service management
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd 
#chkconfig: 35 85 21 //35 level automatic operation 85th startup 21st shutdown
#description: Apache is a World Wide Web server
—>wq 
chkconfig --add httpd / / add httpd to the system manager
#You can use service or systemctl for management
vi /usr/local/httpd/conf/httpd.conf
#– line 52 – modified
#Listen 192.168.200.50:80
– line 197 – uncomment, modify
ServerName 192.168.10.80:80
– line 221 – default home page storage path
DocumentRoot "/usr/local/httpd/htdocs"
– line 255 – default home page file name setting directoryindex html
—>wq
#Check syntax
httpd -t or apachectl -t
cat /usr/local/httpd/htdocs/index.html 
service httpd restart
netstat -anpt | grep 80

 

 

 

 

 

 

 

 

 

3.httpd 

3.1 compiling and installing httpd server

1. The advantages of compilation and installation have a large degree of freedom, the functions can be customized, and the latest software version can be obtained in time. It is generally applicable to most Linux versions and easy to transplant
Source code reference of Apache server: http://httpd.apache.org/download.cgi  

3.2 compiling and installing httpd server

1. Preparation
Uninstall httpd and related dependent packages

[root@www ~]# rpm -e httpd --nodeps
[root@www~]# yum install -y apr-util-devel pcre-devel

2. Source code compilation and installation

[root@www~]# tar zxf httpd-2.4.25.tar.gz -C lusrlsrc
[root@www ~]# cd /usr/src/httpd-2.4.25/
[root@www httpd-2.4.25]# ./configure --prefix=/usr/local/httpd--enable-so --enable-rewrite --enable-charset-lite --enable-cgi
[root@www httpd-2.4.25]# make && make install

4. Install MYSQL

4.1 installing MYSQL

yum -y install \
gcc \
gcc-c++ \
ncurses \				#Dynamic library of graphic interactive function under character terminal
ncurses-devel \			#ncurses development kit
bison \					#Parser
cmake					#mysql needs to be compiled and installed with cmake

yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake

#Create program user management
useradd -s /sbin/nologin mysql

tar zxvf mysql-5.7.17.tar.gz -C /opt
tar zxvf boost_1_59_0.tar.gz -C /usr/local/
mv /usr/local/boost_1_59_0 /usr/local/boost
cd /opt/mysql-5.7.17/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \		#Specify the installation path of mysql
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ #Specify the storage path of mysql process listening socket file (database connection file)
-DSYSCONFDIR=/etc \                             #Specify the storage path of the configuration file
-DSYSTEMD_PID_DIR=/usr/local/mysql \            #Specify the storage path of the process file
-DDEFAULT_CHARSET=utf8  \                       #Specifies the character set encoding used by default, such as utf8
-DDEFAULT_COLLATION=utf8_general_ci \			#Specifies the default character set collation rule to use
-DWITH_EXTRA_CHARSETS=all \						#Specifies that other character set encodings are supported
-DWITH_INNOBASE_STORAGE_ENGINE=1 \              #Install INNOBASE storage engine
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \               #Installing the ARCHIVE storage engine 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \             #Installing the BLACKHOLE storage engine 
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \            #Install FEDERATED storage engine 
-DMYSQL_DATADIR=/usr/local/mysql/data \         #Specify the storage path of the database file
-DWITH_BOOST=/usr/local/boost \          #Specify the path of boost. If MySQL boost integration package is used for installation, - DWITH_BOOST=boost
-DWITH_SYSTEMD=1								#Generate files for systemctl management


Storage engine options:
MYISAM,MERGE,MEMORY and cSv The engine is compiled into the server by default and does not need to be explicitly installed. Statically compile a storage engine to the server, using-DWITH engine STORAGE ENGINE= 1
Available storage engine values are:ARCHIVE,BLACKHOLE,EXAMPLE,FBDERATBD,IMNOBASB(InnoDB),PARTTTON(partitioning support),and PERFSCHEMA(Performance schema)
make && make install

Note: if an error is reported in the process of CMAKE, after the error is solved, you need to put cmakecache in the source directory Txt file is deleted, and then CMAKE is again. Otherwise, the error remains the same

make -j 3 && make install
#Create ordinary user management mysql
useradd -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql/
#Change management master / group
chown mysql:mysql /etc/my.cnf


#Modify profile
vim /etc/my.cnf								#Delete the original configuration item and add the following content again
[client]									#Client settings
port = 3306
socket=/usr/local/mysql/mysql.sock			

[mysqld]									#Service global settings
user = mysql       							#Set management user
basedir=/usr/local/mysql					#Specify the installation directory of the database
datadir=/usr/local/mysql/data				#Specify the storage path of the database file
port = 3306									#Specify port
character-set-server=utf8					#Set the encoding format of the server character set to utf8
pid-file = /usr/local/mysql/mysqld.pid		#Specify pid process file path
socket=/usr/local/mysql/mysql.sock			#Specify database connection file
bind-address = 0.0.0.0						#Set the listening address. 0.0.0.0 means that all IP addresses are allowed. If multiple IP addresses are allowed, they should be separated by spaces
skip-name-resolve							#Disable DNS resolution
max_connections=2048						#Set the maximum number of mysql connections
default-storage-engine=INNODB				#Specify the default storage engine
max_allowed_packet=16M						#Set the maximum packet size received by the database
server-id = 1								#Specify service ID number


[client]									
port = 3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock	

[mysql]									
port = 3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
auto-rehash

[mysqld]
user = mysql 
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306	
character-set-server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

4.2sql_ The common values of mode are as follows:

NO_ENGINE_SUBSTITUTION
 If the required storage engine is disabled or not compiled,Then throw an error. When this value is not set,Replace with default storage engine,And throw an exception

STRICT_TRANS_TABLES
 In this mode,If a value cannot be inserted into a transaction table,Then interrupt the current operation,No restrictions on non transaction tables

NO_AUTO_CREATE_USER
 Ban Zheng GRANT Create a user with a blank password

NO_AUTO_VALUE_ON_ZERO
mysql The self growing column in can be O Start. By default, the self growth column starts from 1. If you insert data with a value of 0, an error will be reported

NO_ZERO_IN_DATE
 Zero date and month are not allowed

NO_ZERO_DATE
mysql Zero date insertion is not allowed in the database,Inserting a zero date throws an error instead of a warning

ERROR_FOR_DIVISION_BY_ZERO
 stay INSERT or UPDATE In the process, if the data is divided by zero, an error is generated instead of a warning. By default, when the data is divided by zero MysQL return NULL

PIPES_As_CONCAT
 take"||"Treat as a concatenation operator of a string rather than an or operator, which is similar to Oracle The database is the same as the string splicing function Concat Similar

ANSI_QUOTES
 Enable ANSI_QUOTES You cannot use double quotation marks to refer to a string after, because it is interpreted as an identifier

4.3 setting environment variables

#Set environment variables and declare / declare mysql commands for system recognition
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile


#Initialize database
cd /usr/local/mysql/bin/
./mysqld \
--initialize-insecure \				#Generation initialization password is null
--user=mysql \                      #Specify administrative users
--basedir=/usr/local/mysql \        #Specify the installation directory of the database
--datadir=/usr/local/mysql/data		#Specify the storage path of the database file

cd /usr/local/mysql/bin/
./mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data

cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload         #Refresh recognition     
systemctl start mysqld.service  #Open service
systemctl enable mysqld         #Power on self start
netstat -anpt | grep 3306       #View port


#Set password for root account
mysqladmin -u root -p password "123456" 
-->Direct enter

 

 

 

 5. Install PHP

yum -y install \
gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
 install GD Library and GD Library Association program, which is used to process and generate pictures
cd /opt
tar zxvf php-7.1.24.tar.gz


cd /opt/php-7.1.24/
./configure \
--prefix=/usr/local/php7 \							#Specify the path where the PHP program will be installed
--with-apxs2=/usr/local/httpd/bin/apxs \			#Specifies the file location of the apxs module support program provided by the Apache httpd service
--with-mysql-sock=/usr/local/mysql/mysql.sock \		#Specify the storage path of mysql database connection file
--with-config-file-path=/usr/local/php7				#Set the configuration file for PHP Where ini will be stored
--with-mysqli \										#add to MySQL Extended support #mysqli extension technology can not only call MySQL stored procedures and handle MySQL transactions, but also make accessing the database more stable
--with-zlib \										#Support zlib function and provide data compression
--with-curl \										#Enable curl extension function to realize HTTP Get download and Post request
--with-gd \											#Activate gd library support
--with-jpeg-dir \									#Activate jpeg support
--with-png-dir \									#Activate png support
--with-freetype-dir \
--with-openssl \
--enable-mbstring \									#Enable multi byte string function to support Chinese and other codes
--enable-xml \										#Open extensible markup language module
--enable-session \									#conversation
--enable-ftp \										#Text transfer protocol
--enable-pdo \										#function library
--enable-tokenizer \								#Token interpreter
--enable-zip										#ZIP compression format
make && make install
#Copy the template file and modify it
cp /opt/php-7.1.10/php.ini-development /usr/local/php7/php.ini
vim /usr/local/php7/php.ini
--1170 that 's ok--modify
mysqli.default_socket = /usr/local/mysql/mysql.sock
--939 that 's ok--Uncomment, modify
date.timezone = Asia/Shanghai

#Optimization: put PHP executable program files into the directory of path environment variables for system identification
ln -s /usr/local/php7/bin/* /usr/local/bin/
#Modify Apache configuration file to make Apache support PHP
vi /etc/httpd.conf 
#Add index php
255 <IfModule dir_module>
256     DirectoryIndex index.html index.php
257 </IfModule>
#Insert something below line 392 so that Apache can support it php web page file
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
##Check whether the module supporting php7 by default exists in line 156
LoadModule php7_module	   modules/libphp7.so



---->wq
#Create and edit php page files
rm -rf /usr/local/httpd/htdocs/index.html
vim /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>

systemctl restart httpd.service

Test on Web“ http://192.168.10.80/index.php"

 

6. Installation Forum

.Create a database
mysql -u root -p 

mysql> CREATE DATABASE bbs;
  
#Grant the permissions of all tables in the bbs database to bbsuser and set the password

mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';

#Refresh database
mysql>flush privileges; 


#Unzip the forum zip
unzip Discuz_X2.5_SC_UTF8.zip -d /opt/dis

cd /opt/dis
#Upload site update package
cp -r upload/ /usr/local/httpd/htdocs/bbs

#Switch forum directory
cd /usr/local/httpd/htdocs/bbs

#Change forum directory owner
chown -R daemon ./config
chown -R daemon ./data
chown -R daemon ./uc_client
chown -R daemon ./uc_server/data

Database server: localhost # is used for local erection. How to fill in the IP address and port number instead of on the local machine
Database name: bbs
Database user name: bbsuser
Database password: admin123
Administrator account: admin
Administrator password: admin123

In case of error, the information is as follows
Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /data/www/install/index.php:12 Stack trace: #0 {main} thrown in /data/www/install/index.php on line 12
 resolvent
#Fatal error: uncapped error: call set of undefined function_ magic_ quotes_ Runtime (), in the 12th line of this file, find the index PHP open this file and find set_magic_quotes_runtime

#Switch directory
cd /usr/local/httpd/htdocs/bbs/install
vim index.php Edit

//hold 
  
@set_magic_quotes_runtime(0); 
  
//Substitute into 
  
@ini_set("magic_quotes_runtime",0);

The problem has been solved

The test results are normal and the forum website can be opened normally

 

 

 

 

grant all on bbs.* to 'bbsuser'@' %' identified by 'admin123 ' ;

grant It refers to the permission range (including operation permission) that can be used in the database:Add, delete, modify and query+Database objects that can be managed)
all:Refers to all operation permissions
on bbs.* :Refers to manageable"database.Scope of data table
to 'bbsuser' @'$' : to Endowed"User object@Source ", the user logging in the database@Source restrictions for this user
identified by 'admin123'; :The user interaction mode is password, and the password is specified as admin123

 

lamp
#attend to each one 's own duties
L  linux Distribution centos 7  #Host operating system
A  Apache   #Processing static requests
M  Mysql 5.7  #data storage 
P  php-7.1.10  #Processing dynamic requests


#Docking
L->base
Apache ->Docking PHP ->php Docking Mysql

apache So fpm/fast cGⅠ Interface form docking and compatible php Static page processing completed by module+Forward dynamic pages php And Apache After docking, docking is required MySQL database﹐The core is the use of mysql.sock Communication document as carrier MysQL:provide mysql.sock Communication documents+ mysql_modules (mysql.cnf )

 

summary

1.Apache website service
2.MySQL service
3.PHP services
4.LAMP architecture application example
5. Find the correct docking method, find the right version, and be able to use Baidu, Google, csdn and blog park

Keywords: Linux MySQL Apache

Added by busnut on Thu, 24 Feb 2022 14:19:56 +0200