当前位置:网站首页>Lamp compilation and installation

Lamp compilation and installation

2022-06-26 13:22:00 C chord~

Catalog

introduction :

One . structure LAMP Platform sequence

Two . Advantages of compiling and installing

3、 ... and .Apache

Installation steps :

test

Four .mysql

install :

verification

5、 ... and .php

install

test :

  6、 ... and . Forum

test :

summary :


introduction :

LAMP Architecture is one of the mature enterprise website application modes , It refers to a whole set of systems and related software that work together , Can provide dynamic Web Site service and its application development environment .LAMP It's an abbreviation , Specific include Linux operating system 、Apache Web server 、MySQL database server 、PHP( or Perl、Python) Web programming language .

One . structure LAMP Platform sequence


In the build LAMP Platform time , The installation sequence of each component is Linux,Apache,MySQL,PHP

among Apache and MySQL There is no strict sequence requirement for the installation of , and PHP The installation of the environment is usually at the end of the day , Responsible for communication web Servers and database systems to work together

Two . Advantages of compiling and installing


1、 With a large degree of freedom , Features can be customized
2、 Timely access to the latest software version
3、 Generally applicable to most Linux edition , Easy to use all the time

3、 ... and .Apache

Static processing + Deliver dynamic requests to PHP

Installation steps :

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 Compiler of language 
gcc-c++ \						#C++ The compiler 
make \							# Source code compiler ( Convert source code to binary file )
pcre \							#pcre It's a Perl function library , Include perl  Compatible regular expression library 
pcre-devel \                    #perl Interface development package for 
expat-devel \                   # Used to support website parsing HTML、XML file 
perl                            #perl Language compiler 

cd /opt/httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \		# Appoint  httpd  The installation path of the service program 
--enable-so \					# Enable dynamic load core module support , send  httpd  With the ability to further expand functions 
--enable-rewrite \				# Enable Web address rewriting , For website optimization 、 Security chain and directory migration maintenance 
--enable-charset-lite \			# Start character set support , To support pages encoded with various character sets 
--enable-cgi					# Enable CGI( Universal gateway interface ) Scripting support , It is convenient for the external expansion of the website and the application access ability 
make && make install


# Optimize the configuration file path , And put httpd The executable program file of the service is put into the directory of the path environment variable to facilitate system identification 
ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/

# Easy service management 
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd

# chkconfig: 35 85 21  //35 Level auto run    The first 85 Start up   The first 21 Closed 
# description: Apache is a World Wide Web server
---》wq

chkconfig --add httpd // take httpd Add to system manager 

# You can use service perhaps systemctl Conduct management 


vi /usr/local/httpd/conf/httpd.conf
#--52 That's ok -- modify 
#Listen 192.168.200.50:80
--197 That's ok -- uncomment , modify 
ServerName 192.168.10.80:80
--221 That's ok -- Default home page storage path 
DocumentRoot "/usr/local/httpd/htdocs"
--255 That's ok -- Default home page file name setting 
DirectoryIndex index.html
---》wq

test

Four .mysql

  For storing data : The contents of the database are stored in the database in the form of tables

install :

yum -y install \
gcc \
gcc-c++ \
ncurses \				# Dynamic library of graphic interaction function under character terminal 
ncurses-devel \			#ncurses Development kit 
bison \					# parsers 
cmake					#mysql Need to use cmake Compilation and installation 
# 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 \		# Appoint mysql Installation path for 
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ # Appoint mysql The process listens to socket files ( Database connection file ) Storage path for 
-DSYSCONFDIR=/etc \                             # Specify the storage path of the configuration file 
-DSYSTEMD_PID_DIR=/usr/local/mysql \            # Specifies the storage path of the process file 
-DDEFAULT_CHARSET=utf8  \                       # Specifies the default character set encoding , Such as  utf8
-DDEFAULT_COLLATION=utf8_general_ci \			# Specifies the character set collation rules to be used by default 
-DWITH_EXTRA_CHARSETS=all \						# Specify support for other character set encoding 
-DWITH_INNOBASE_STORAGE_ENGINE=1 \              # install INNOBASE Storage engine 
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \               # install ARCHIVE Storage engine  
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \             # install 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 \          # Appoint boost The path of , If you use mysql-boost Integration package installation is -DWITH_BOOST=boost
-DWITH_SYSTEMD=1								# Generation facilitates systemctl Administrative document 
make && make install
 Be careful : If in CMAKE There are errors in the process of , When the error is resolved , Need to put the source directory of CMakeCache.txt File deletion , And then... Again CMAKE, Otherwise, the mistake remains 
# Create common 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 the configuration file 
vim /etc/my.cnf								# Delete the original configuration item , Add the following again 
[client]									# Client side Settings 
port = 3306
socket=/usr/local/mysql/mysql.sock			

[mysqld]									# Service global settings 
user = mysql       							# Set up 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 
port = 3306									# Designated port 
character-set-server=utf8					# Set the server character set encoding format to utf8
pid-file = /usr/local/mysql/mysqld.pid		# Appoint pid  Process file path 
socket=/usr/local/mysql/mysql.sock			# Specify the database connection file 
bind-address = 0.0.0.0						# Set listening address ,0.0.0.0 The representative allows all , If multiple IP It needs to be separated by spaces 
skip-name-resolve							# Ban DNS analysis 
max_connections=2048						# Set up mysql Is the maximum number of 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								# Designated Services ID Number 
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 the 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 columns in can be derived from O Start . By default, self growing columns are generated from 1 At the beginning , If you insert a value of 0 The data will report an error 

NO_ZERO_IN_DATE
 Zero days and months are not allowed 

NO_ZERO_DATE
mysql Database is not allowed to insert zero date , 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 , It's a mistake, not a warning . By default, when data is divided by zero MysQL return NULL

PIPES_As_CONCAT
 take "||" Treat as the concatenation operator of a string, not as the or operator , This sum Oracle The database is the same , And string concatenation function Concat Similar 

ANSI_QUOTES
 Enable ANSI_QUOTES after , You can't use double quotes to refer to strings , Because it's interpreted as an identifier 
# Set the environment variable , Affirming / Declare mysql The command is easy for the system to recognize 
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile


# Initialize database 
cd /usr/local/mysql/bin/
./mysqld \
--initialize-insecure \				# Generate initialization password is empty 
--user=mysql \                      # Specify the administrative 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 
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload         # Refresh recognition      
systemctl start mysqld.service  # Opening service 
systemctl enable mysqld         # Boot up 
netstat -anpt | grep 3306       # Check the port 


# to root Account setup password 
mysqladmin -u root -p password "123456" 

verification

5、 ... and .php

Dynamic processing

install

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 Kuhe GD Library correlator , Used to process and generate images 
cd /opt
tar zxvf php-7.1.24.tar.gz
cd /opt/php-7.1.24/
./configure \
--prefix=/usr/local/php7 \							# Specify the  PHP  The installation path of the program 
--with-apxs2=/usr/local/httpd/bin/apxs \			# Appoint Apache httpd service-provided apxs  The file location of the module support program 
--with-mysql-sock=/usr/local/mysql/mysql.sock \		# Appoint mysql  The storage path of the database connection file 
--with-config-file-path=/usr/local/php7				# Set up  PHP  Configuration file for  php.ini  Where will it be stored 
--with-mysqli \										# add to  MySQL  Extended support  #mysqli Extension technology can not only call MySQL Stored procedure 、 Handle MySQL Business , It can also make the work of accessing database more stable 
--with-zlib \										# Support zlib function , Provides data compression 
--with-curl \										# Turn on curl Extend the functionality , Realization HTTP Of Get To download and Post Requested method 
--with-gd \											# Activate gd  Library support 
--with-jpeg-dir \									# Activate jpeg  Support for 
--with-png-dir \									# Activate png  Support for 
--with-freetype-dir \
--with-openssl \
--enable-mbstring \									# Enable multi byte string function , In order to support Chinese and other codes 
--enable-xml \										# Open the extensible markup language module 
--enable-session \									# conversation 
--enable-ftp \										# Text transfer protocol 
--enable-pdo \										# function library 
--enable-tokenizer \								# Token interpreter 
--enable-zip										#ZIP Compressed format 
make && make install
# Copy template file , And make changes 
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

# Optimize PHP  The executable program file of is put into the directory of path environment variable to facilitate system identification 
ln -s /usr/local/php7/bin/* /usr/local/bin/
# modify Apache Configuration files let Apache Support PHP
vi /etc/httpd.conf 
# add to index.php
255 <IfModule dir_module>
256     DirectoryIndex index.html index.php
257 </IfModule>
# stay 392 Insert something below the line , Give Way Apache Can support .php The web file 
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
## Check 156 Line default support php7 Is there a module for 
LoadModule php7_module   modules/libphp7.so
# establish 、 edit php pagefile 
rm -rf /usr/local/httpd/htdocs/index.html
vim /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>

systemctl restart httpd

test :

  6、 ... and . Forum

 Create a database 
mysql -u root -p 

mysql> CREATE DATABASE bbs;
  
# hold bbs The permissions of all tables in the database are granted to bbsuser, And set the password 

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

# Refresh database 
mysql>flush privileges; 


# Unzip the forum package 
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 ownership 
chown -R daemon ./config
chown -R daemon ./data
chown -R daemon ./uc_client
chown -R daemon ./uc_server/data
 If an error is reported, 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 : Error not caught : Call of undefined function set_magic_quotes_runtime(), At the end of this document 12 That's ok , Find... Under this path index.php This file opens , lookup set_magic_quotes_runtime

# Toggle directory 
cd /usr/local/httpd/htdocs/bbs/install
vim index.php Editing 

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

database server : localhost   # It's built locally localhost, How not to fill in on this machine IP Address and port number
Database name : bbs
Database user name : bbsuser
Database password : admin123
Administrator account : admin
Administrator password : admin123

test :

summary :

 APache docking PHP

PHP docking mysql

apache In order to fpm.fast CGI Interface form: docking and compatible PHP Static page processing completed by the module + Dynamic page delivery

 PHP And apache After docking , Need to dock MYsql database , Its core is the use of mysql.sock Communication documents as the carrier

mysql: Provide mysql.sock Communication files +mysql_modules

原网站

版权声明
本文为[C chord~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261227385763.html