Sorted installation package
Link: https://pan.baidu.com/s/1J8hVp-9p5yIMMc2jBUu5XA
Extraction code: 123b
1, Introduction to LAMP
1. Concept of LAMP
LAMP platform is a complete set of systems and related software for collaborative work. It can provide dynamic Wen site services and application development environment. It is the most mature and traditional enterprise website application mode at present.
50: Linux system support
A: Apache requires the source code to install http, specify the path and set the configuration, and the front end of LAMP architecture to provide users with website services, send web pages, pictures and other file contents, and support static
M: mysql, the database for installing mysql and the back end of LAMP architecture, stores various account information, product information, customer information, business data, etc. other programs can query and change through SQL statements
P: Install php, be responsible for interpreting dynamic Web page files, and provide Web application development and running environment
2. Installation sequence
Linux system - Apache server - Mysql database - PHP environment
2, Installation of Apache
1. Move the dependent package to httpd and rename it
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
2. Installation and compilation environment support
yum -y install \ gcc \ gcc-c++ \ make \ pcre-devel \ expat-devel \ perl
explain:
gcc #C compiler
gcc-c++ #C + + compiler
make # source code compiler (convert source code to binary file)
pcre #pcre is a perl function library, including perl compatible regular expression library
Interface development package of PCRE devel #perl
Expat devel # is used to support websites to parse HTML and XML files
perl #perl compiler
3. Set path and configuration
cd /opt/httpd-2.4.29/ ./configure \ --prefix=/usr/local/httpd \ --enable-so \ --enable-rewrite \ --enable-charset-lite \ --enable-cgi make && make install
– prefix=/usr/local/httpd ## specify the installation path
– enable so ## starts dynamic loading core support for network optimization
– enable rewrite # starts the support of web page rewriting function, which is convenient for rewriting, anti-theft chain and directory migration
– enable charset Lite # enables character set support and supports various character set encodings
– enable CGI # enables scripting support for the CGI gateway interface
#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/
4. service management optimization
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd \# /etc/init.d / the services in this directory can be started and managed by using service, and systemctl is the directory location of the service startup script recognized by / usr/lib/systemd/system / systemctl command
vim /etc/init.d/httpd #!/bin/bash #chkconfig:35 82 21 #Level 35 refers to the self start of the service, 85 refers to start and 21 refers to shutdown #description:Apache is a World Wide Web server #Insert these two lines at the beginning #Although it is#In front, but chkconfig Commands can be recognized automatically#Content after
chkconfig --add httpd #Type httpd into the system manager to make the previous configuration take effect. Now you can use service and systemctl for management
5. Set listening port and ip
vim /usr/local/http/conf/httpd.conf Listen 192.68.100.7:80 #Line 52 modified ServerName www.mayu.com:80 #Line 197 uncomment and modify DocumenRoot "/usr/local/httpd/htdocs" #Row 221 default home page storage location Directorylndex index.html #255 the setting of the file name of the home page. These two lines do not need to be modified
httpd -d # check syntax
6. Start httpd and check the port
service httpd restart netstat -anpt | grep 80
2, MYSQL installation
1. Installation and compilation environment support
yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake autoconf
gcc \ # compiler language, translator
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
autoconf # is a shell script tool for generating software source code packages that can be automatically configured to adapt to a variety of unix like systems.
2. Compile and install
tar xzvf mysql-5.6.26.tar.gz -C /opt cd /opt/mysql-5.6.26/ cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DSYSCONFIDIR=/etc \ -DMYSQL_DATADIR=/home/mysql/ \ -DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock make && make install
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \ # specifies the character set encoding used by default, such as utf-8
-DDEFAULT_COLLATION=utf8_general_ci \ # specifies the character set collation rules to be used by default
-DEXTRA_CHARSETS=all \ # specifies that other character set encodings are supported
-DSYSCONFIDIR=/etc \ #/etc/mysql - > there is a default configuration in the system, / etc / my cnf
-DMYSQL_DATADIR=/home/mysql / \ # data file
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock # specifies the communication file to connect to the database (it will be generated when starting the database)
(if an error is reported in the process of CMAKE, after the error is solved, you need to delete the CMakeCache.txt file in the source directory, and then restart CMAKE)
3. Optimize server management
cp support-files/my-default.cnf /etc/my.cnf # cp support-files/mysql.server /etc/init.d/mysqld #Enable systemctl support chmod 755 /etc/init.d/mysqld #Give other users certain permissions chkconfig --add /etc/init.d/mysqld #Join system manager chkconfig mysqld --level 35 on #Set startup and self startup, which is equivalent to systemctl enable mysqld
4. Create users and user groups
useradd -s /sbin/nologin mysql # chown -R mysql:mysql /usr/local/mysql #-R recursion, change the owner of / usr/local/mysql to mysql and mysql (the first mysql is the user and the second mysql is the user group) chown mysq:mysql /etc/my.cnf
5. Set the environment variable and declare the mysql command
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile #Is to append > >, and pay attention to backing up / etc/profile before operation source /etc/profile # Activate the modified environment variable
6. Initialize database
/usr/local/mysql/scripts/mysql_install_db \ --user=mysql \ --ldata=/var/lib/mysql \ --basedir=/usr/local/mysql \ --datadir=/home/mysql vim /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/home/mysql #Modify lines 46 and 47
7. Start and check ports
service mysqld start netstat -anpt | grep 3306
4, Install PHP
1. Installation and compilation environment support
yum -y install \ gd \ libpng \ libpng-devel \ pcre \ pcre-devel \ libxml2-devel \ libjpeg-devel
gd \ # image processing library
libpng \ #png format picture library
libpng-devel
pcre \ #PCRE library supports regular expressions
PCRE devel \ #pcre devel is a development library required for secondary development using PCRE, and is also required for compilation and installation
Libxml2 devel \ # parse xml markup language library
Libjpeg devel #jpeg format picture library
2. Installation and compilation
tar xjvf php-5.6.11.tar.bz2 -C /opt cd /opt/php-5.6.11 ./configure \ --prefix=/usr/local/php5 \ --with-gd \ #Provide gd library support --with-zlib \ #Provide zlib function and function library with data compression function --with-apxs2=/usr/local/httpd/bin/apxs \ #Specify the apxs module provided by httpd --with-mysql=/usr/local/mysql \ #Associated database --with-config-file-path=/usr/local/php5 \ #Specify profile --enable-mbstring #Turn on the multi byte string function to support Chinese and other characters make && make install
3. Optimize sever management
ln -s /usr/local/php5/bin/* /usr/local/bin/
4. Modify Apache files
To make Apache support PHP services
vim /etc/httpd.conf <IfModule dir_module> DirectoryIndex index.html index.php #Add index. In line 256 php </IfModule> AddType application/x-httpd-php .php #Insert two lines below line 392 to support hph's web file AddType application/x-httpd-php-source .phps #At the same time, check whether the module of php5 in line 156 is in or not
5. Create web pages and start services
establish php pagefile vim /usr/local/httpd/htdocs/index.php <?php phpinfo(); ?> ------------------------- service httpd stop service httpd start ##Restart the service in this way, because restart sometimes gets stuck Test on Web“ http://192.168.100.7/index.php"
Test successful
5, Installation Forum
1. Set the password to log in to mysql
#Set password for root account
mysqladmin -u root -p password "123456"
————>Direct enter
2. Log in and refresh the database
mysql -u root -p ----123456(Enter the password without displaying) CREATE DATABASE bbs; #Create a database GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123'; # Grant the permissions of all tables in the bbs database to bbsuser and set the password flush privileges; #Refresh database
//Create database
create database [database name];
//View database
show databases;
//Delete database
drop database [database name];
3. Install Discuz
unzip /opt/Discuz_X2.5_SC_UTF8.zip -d /opt/dis cd /opt/dis cp -r upload/ /usr/local/httpd/htdocs/bbs cd /usr/local/httpd/htdocs/bbs
chown -R daemon ./config
chown -R daemon ./data
chown -R daemon ./uc_client
chown -R daemon ./uc_server/data