In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Build LAMP service by compiling source code
# LAMP introduction #
LAMP architecture is one of the current mature enterprise website application models, which refers to a complete set of systems and systems that work together.
Related software, can provide dynamic Web site services and application development environment. LAMP is an acronym with
The body includes Linux operating system, Apache website server, MySQL database server, PHP (or Perl,
Python) web programming language. This chapter will build a LAMP environment by compiling source code, which can meet the requirements of enterprises.
The need for institutionalization.
When building the LAMP platform, the installation order of each component is Linux, Apache, MySQL, PHP.
Among them, the installation of Apache and MySQL is not in strict order, while the installation of PHP environment is generally placed at the end.
Responsible for communicating with Web server and database system to work together.
# introduction to Apache #
"Apache HTTP Server" is an outstanding representative of open source software projects, provided by the standards-based HTTP network protocol.
Web browsing services have long maintained more than half of the share in the field of Web servers. Apache server can transport
Line in Linux, UNIX, Windows and other operating system platforms.
Apache server is a software formed by the integration and improvement of several Web server programs that appeared before.
Item, whose name comes from "A Patchy Server", which means "to modify based on the code of the original Web service program."
D) after the formation of the server program.
In 1995, the Apache service released version 1.0, and "Apache Group" has been in charge of the project ever since.
Until 1999, the Apache Software Foundation was established on the basis of "Apache Group"
(Apache Software Foundation,ASF). At present, the Apache project has been managed and maintained by ASF.
ASF is a non-profit organization, initially only responsible for the management of the "Apache Web" server project, with Web
With the continuous expansion of application requirements, ASF has gradually increased many open source software projects related to Web technology, so Apache
Now it represents not only the Web server, but also many open source software projects managed by ASF. ASF base
The official website of Jinhui is http://www.apache.org/.
"Apache HTTP Server" is one of ASF's famous software projects, and its official name is "httpd", that is,
Is the historical Apache website server. In the following content, use "Apache" or "httpd" unless otherwise specified
They all mean "Apache HTTP Server".
# main features of Apache #
1. Open source: this is one of the important features of the Apache server and the basis for other features.
Apache service programs are jointly maintained by many developers around the world, and anyone is free to use
Use, which fully embodies the spirit of open source software.
2. Cross-platform applications: this feature benefits from the open source code of Apache. Apache server can transport
On most hardware and software platforms, all UNIX operating systems can run Apache services
And even Apache servers run well on most Windows system platforms.
The cross-platform characteristic of Apache server makes it have the condition of being widely used.
3. Support a variety of Web programming languages: the web programming languages supported by Apache servers include Perl, PHP,
Python, Java, and even Microsoft's ASP technology can also be used in Apache servers. Branch
With a variety of commonly used Web programming languages, Apache has a wider range of applications.
4. Modular design: Apache does not centralize all functions within a single service program, but
Implement proprietary functions through standard modules as much as possible, which brings a good
Scalability. Other software developers can write standard module programs to add Apache itself
Other functions that you don't have.
5. The operation is very stable: the Apache server can be used to build Web sites with heavy traffic, very
Many well-known corporate websites use Apache as the Web service software.
6. Good security: Apache server has relatively good security, which is common to open source software.
There are some characteristics. In addition, the Apache maintenance team will provide timely patches for the vulnerabilities that have been discovered.
Provide server programs as secure as possible for all users of Apache.
× × × LAMP experiment
Experimental environment:
1. Virtual machine ip 192.168.32.20-vm1 is connected to the host. Memory 3G (not less than 2G)
Turn off the core protection, turn off the firewall, and build a yum warehouse with CD as the source.
two。 Several packages that need to be installed:
Apache
Mysql
Php
Lab planning:
1. Set up apache service
two。 Set up mysql service
3. Build a PHP running environment
4. Deploy phpmyadmin system
The steps of the experiment:
1. Preliminary setup of experimental environment
[root@localhost ~] # systemctl stop firewalld # turn off the firewall at 00:00
[root@localhost ~] # systemctl disable firewalld # permanently turn off the firewall
Removed symlink / etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink / etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~] # setenforce 0 # 00:00 disable core protection
[root@localhost yum.repos.d] # sed-I'/ SELINUX/s/= [a Murz] / = disabled/g' / etc/sysconfig/selinux
# permanently disable core protection
Build a yum warehouse.
[root@localhost ~] # mount / dev/cdrom / mnt # Mount the CD
Mount: / dev/sr0 write protection, which will be mounted as read-only
[root@localhost ~] # cd / etc/yum.repos.d/
[root@localhost yum.repos.d] # mkdir jlh
[root@localhost yum.repos.d] # mv C jlh # move the configuration files to the jlh folder
[root@localhost yum.repos.d] # cp jlh/CentOS-Base.repo local.repo
[root@localhost yum.repos.d] # vi local.repo
[centos]
Name=centos
Baseurl= file:///mnt # its yum download source is not under mnt
Gpgcheck=0
Enabled=1
# gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
two。 Set up apache service
(1) upload three packages of apache services to the opt directory
(2) decompress the compressed package
[root@localhost opt] # tar xf apr-1.6.2.tar.gz # extract the compressed file to the current directory
[root@localhost opt] # tar xf apr-util-1.6.0.tar.gz # extract the compressed file to the current directory
[root@localhost opt] # tar xf httpd-2.4.29.tar.bz2 # extract the compressed file to the current directory
View
(3) move the plug-ins needed to install http to the http/scrlib directory
[root@localhost opt] # mv apr-1.6.2 httpd-2.4.29/srclib/apr
# move the extracted apr-1.6.2 plug-in to the / apr file in the httpd-2.4.29/srclib directory for compilation and installation
[root@localhost opt] # mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
# move the extracted apr-util-1.6.0 plug-in to the / apr-util file in the httpd-2.4.29/srclib directory
(4) configuration (custom personalized configuration)
[root@localhost httpd-2.4.29] #. / configure\
-- prefix=/usr/local/httpd\
-- enable-so\
-- enable-rewrite\
-- enable-charset-lite\
-- enable-cgi
. / configure\ # configure your installation options to generate the Makefile files required for compilation
-- prefix=/usr/local/httpd\ # specify that the httpd program be installed in the / usr/local/httpd directory
-- enable-so\ # # enable the dynamic loading module function, so that httpd has the ability to further expand its functions.
-- enable-rewrite\ # enable web address rewriting for website optimization and directory migration
-- enable-charset-lite\ # enable character set support to support web pages encoded with various character sets
-- enable-cgi # # enable CGI script support to expand the application access capability of the website
(5) compilation and installation
[root@localhost httpd-2.4.29] # make-j2 # # compile,-j2, double-threaded compilation, faster installation.
[root@localhost httpd-2.4.29] # make install # install
(6) optimize the execution path
The original path of the execution program file is not in the PATH environment variable. Make a soft link so that it can be executed.
[root@localhost httpd-2.4.29] # ln-s / usr/local/httpd/conf/httpd.conf / etc/
[root@localhost httpd-2.4.29] # ln-s / usr/local/httpd/bin/* / usr/local/bin/
[root@localhost httpd-2.4.29] # httpd- v # View version
Server version: Apache/2.4.29 (Unix)
Server built: Feb 21 2019 06:12:43
(7) add the httpd service to the system service
[root@localhost httpd-2.4.29] # cp / usr/local/httpd/bin/apachectl / etc/init.d/httpd
[root@localhost httpd-2.4.29] # vi / etc/init.d/httpd # Edit configuration file
[root@localhost httpd-2.4.29] # chkconfig-- add httpd # add httpd to SERVICE Manager as a system service
[root@localhost httpd-2.4.29] # chkconfig-- list httpd
# check the self-startup status of http service. The output only shows Sysv service.
Does not include native systemd services. SysV configuration data may be overwritten by native systemd configuration
(8) set up [service] .service profile to add a system to the service
In the / lib/systemd/system/ directory, create a unit (unit) configuration file that ends with. Service
Used to control httpd services managed or monitored by systemd
[root@localhost httpd-2.4.29] # cd / lib/systemd/system/ # enter / lib/systemd/system/
[root@localhost system] # vim httpd.service # Editing management files
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart= / usr/local/bin/apachectl $OPTIONS
ExecrReload= / bin/kill-HUP $MAINPID
[Install]
WantedBy=multi-user.target
(9) start the httpd.service service
[root@localhost system] # systemctl start httpd.service # temporary launch
[root@localhost system] # systemctl enable httpd.service # permanent launch
[root@localhost system] # systemctl is-enabled httpd.service # check whether the HTTP unit is started
Enabled
(10) Edit the httpd main configuration file
[root@localhost system] # vi / usr/local/httpd/conf/httpd.conf
(11) restart the service
[root@localhost system] # systemctl restart httpd
[root@localhost system] # httpd-t # check the status of the http service for syntax errors
Syntax OK
[root@localhost system] # apachectl-t # check the status of the apachectl service for syntax errors
Syntax OK
[root@localhost system] # netstat-anpt | grep 80 # check the running status of httpd service
Tcp6 0 0: 80: * LISTEN 67327Zero h
[root@localhost system] # vi / usr/local/httpd/htdocs/index.html
# the default display content of a web page is / usr/local/httpd/htdocs/index.html
Yum is installed in / var/www/html/index.htmll
(12) browser verification
3. Set up mysql service
(1) install compilation tools and plug-ins
[root@localhost system] # yum-y install\
Ncurses\
Ncurses-devel\
Bison\
Cmake
(2) set up database program users
[root@localhost system] # useradd-s / sbin/nologin mysql
(3) upload mysql-boost-5.7.20.tar.gz to opt directory
(4) decompress the mysql installation package
[root@localhost system] # cd / opt # enter the opt directory
[root@localhost opt] # tar xf mysql-boost-5.7.20.tar.gz # decompression package
[root@localhost opt] # cd / opt/mysql-5.7.20/ # enter into / opt/mysql-5.7.20/
(5) configuration (personalized configuration and optimization project)
[root@localhost mysql-5.7.20] # 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_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=boost\
-DWITH_SYSTEMD=1
# meaning of configuration options #
# 1. DCMAKE_INSTALL_PREFIX: specify that the mysql database program is installed in a directory
Such as directory / usr/local/ mysql.
# 2. DSYSCONFDIR: specify the initialization parameter file directory
# 3. DDEFAULT_CHARSET: specify the character set encoding used by default, such as utf8.
# 4. DDEFAULT_COLLATION: specify the default character set proofreading rules, utf8_general_ci
Is a general rule applicable to the UTF-8 character set.
# 5. DWITH_EXTRA_CHARSETS: specify additional supported character set encodings.
-Note: if there is an error in the process of CMAKE, when 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-
(6) compile, compile and install
[root@localhost mysql-5.7.20] # make-j2 # compile
[root@localhost mysql-5.7.20] # make install # install
[root@localhost mysql-5.7.20] # chown-R mysql:mysql / usr/local/mysql/
# set permissions on the database directory
(7) Edit the mysql master configuration document (do not delete or append the contents. If deleted, root cannot log in during browser access and re-authorization is required)
[root@localhost mysql-5.7.20] # vi / etc/my.cnf
[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
[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
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
[root@localhost mysql-5.7.20] # chown mysql:mysql / etc/my.cnf # change to group
(8) set environment variables
[root@localhost mysql-5.7.20] # echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' > > / etc/profile
# add these two paths to the environment variable and put them in the profile file to make them boot and run automatically, otherwise they will not take effect.
[root@localhost mysql-5.7.20] # echo 'export PATH' > > / etc/profile
# set it as a global variable to make it use more widely
[root@localhost mysql-5.7.20] # source / etc/profile
# effective immediately
(9) configuration initialization
[root@localhost mysql-5.7.20] # cd / usr/local/mysql/
[root@localhost mysql] # [root@localhost mysql] # bin/mysqld\
-- initialize-insecure\
-- user=mysql\
-- basedir=/usr/local/mysql\
-- datadir=/usr/local/mysql/data
(10) add system services
[root@localhost mysql] # cp usr/lib/systemd/system/mysqld.service / usr/lib/systemd/system/
[root@localhost mysql] # systemctl daemon-reload
(11) View the running status of the service
[root@localhost mysql] # systemctl start mysqld # start the service
[root@localhost mysql] # netstat-anpt | grep 3306 # View status
Tcp6 0 0: 3306: * LISTEN 86794/mysqld
[root@localhost mysql] # systemctl enable mysqld # set boot
(12) access database operation
[root@localhost mysql] # mysqladmin-u root-p password
At first, enter directly if the password is empty, then enter the password abc123, and confirm abc123 here, which runs under the root account.
[root@localhost mysql] # mysqladmin-u root-p password # log in to the database
4. Build a PHP running environment
(1) upload the php-7.1.10.tar.bz2 package to the opt directory
(2) install the necessary tools
[root@localhost php-7.1.10] # yum-y install\
Libjpeg\
Libjpeg-devel\
Libpng libpng-devel\
Freetype freetype-devel\
Libxml2\
Libxml2-devel\
Zlib zlib-devel\
Curl curl-devel\
Openssl openssl-devel
(3) decompress the compressed package
[root@localhost opt] # tar xf php-7.1.10.tar.bz2
(4) configure personalized configuration
[root@localhost opt] # cd php-7.1.10
[root@localhost php-7.1.10] #. / configure\
-- prefix=/usr/local/php\
-- with-apxs2=/usr/local/httpd/bin/apxs\
-- with-mysql-sock=/usr/local/mysql/mysql.sock\
-- with-mysqli\
-- with-zlib\
-- with-curl\
-- with-gd\
-- with-jpeg-dir\
-- with-png-dir\
-- with-freetype-dir\
-- with-openssl\
-- enable-mbstring\
-- enable-xml\
-- enable-session\
-- enable-ftp\
-- enable-pdo\
-- enable-tokenizer\
-- enable-zip
(5) compilation and installation
[root@localhost php-7.1.10] # make-j3 # compile
[root@localhost php-7.1.10] # make install # install
(6) copy php configuration file
[root@localhost php-7.1.10] # cp php.ini-development / usr/local/php/lib/php.ini
# copy php.ini--development from php source code to lib directory of php installation directory and rename it to php.ini
[root@localhost php-7.1.10] # vi / usr/local/php/lib/php.ini # Edit the configuration file
# the local database is generally connected through the socket file, and if the socket file of the local database is not in the default path, you must tell php where to read the socket file. Associate php with mysql.
[root@localhost php-7.1.10] # / usr/local/php/bin/php-m # verify the installation module
(6) modify apache configuration file and associate php with apache service
[root@localhost php-7.1.10] # vi / etc/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Add index.php to the default home page and put it in front of index.html to support the home page file of php.
[root@localhost php-7.1.10] # rm-f / usr/local/httpd/htdocs/index.html
# the default home file of the deleter
(7) write php test page in the directory of the website
[root@localhost php-7.1.10] # vi / usr/local/httpd/htdocs/index.php
[root@localhost php-7.1.10] # systemctl restart httpd # restart the http service
(8) browser test, enter http://192.168.32.20
(10) modify and set mysql password, create users, and set permissions
[root@localhost php-7.1.10] # mysqladmin-uroot-p password
Enter into the database
Create a database mantis and assign permissions to the corresponding user
CREATE DATABASE myadm; # create a database myadm
GRANT all ON myadm. TO 'myadm'@'%' IDENTIFIED BY' admin123'; # Authorization
GRANT all ON myadm. TO 'myadm'@'localhost' IDENTIFIED BY' admin123'
Flush privileges; # refresh permissions
Configuration file
Mysql > exit exit
Bye
(11) Edit / usr/local/httpd/htdocs/index.php file
[root@localhost php-7.1.10] # systemctl restart httpd is starting the http service
(13) testing
5. Deploy phpmyadmin system phpMyAdmin is a Web application system written in PHP language to manage MYSQL database
(1) upload the software package phpMyAdmin-4.7.6-all-languages.zip
! [] (https://s1.51cto.com/images/blog/201902/23/cbb46543155818aee4b1f1d7fe27b166.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk
(2) decompress the compressed package
[root@localhost opt] # unzip phpMyAdmin-4.7.6-all-languages.zip-d / opt/
# Note the format of the software package, which is zip format and decompressed with unzip
[root@localhost opt] # mv phpMyAdmin-4.7.6-all-languages / usr/local/httpd/htdocs/myadm
# move the extracted plug-in to the apache directory
[root@localhost opt] # cd / usr/local/httpd/htdocs/myadm
(3) create and edit the configuration file for phpMyadmin
[root@localhost opt] # cd / usr/local/httpd/htdocs/myadm
[root@localhost myadm] # cp config.sample.inc.php config.inc.php
# copy the contents of the configuration file to config.inc.php
[root@localhost myadm] # vi config.inc.php edit the configuration file
(4) restart the apache service
[root@localhost myadm] # systemctl stop httpd
[root@localhost myadm] # systemctl start httpd
6. Login test
Access http://192.168.32.20/myadm in a browser
As a solution, root authorization is available in the database.
[root@localhost myadm] # mysql-u root-p
Mysql > GRANT ALL PRIVILEGES ON. TO 'root'@'%' IDENTIFIED BY' 123456 license; # add root authorization agreement.
Query OK, 0 rows affected, 1 warning (0.01 sec)
Mysql > flush privileges; # Refresh
Query OK, 0 rows affected (0.00 sec)
Test again
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.