Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ultra-detailed LAMP environment manually compiles and installs the instance (PHP works as a module)

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

LAMP compilation and installation example:

One: HTTPD compilation and installation:

Download the software package:

# wget http://mirrors.hust.edu.cn/apache//apr/apr-1.6.3.tar.gz http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.1.tar.gz http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.29.tar.gz

Need to rely on the latest versions of apr and apr-util

Apr:Apache Porttable Runtime:

Portable Apache runtime environment, which is used to run Apache programs written in C language on different operating systems, that is, both Windows and Linux versions

Apr-util:apr tool

Install the development environment to ensure that Development tools

# yum grouplist # check whether to install # yum groupinstall "Development Tools"

Install apr:

# tar xf apr-1.6.3.tar.gz # cd apr-1.6.3#. / configure-- prefix=/usr/local/apr# make# make install

Install apr-util:

# tar xf apr-util-1.5.1.tar.gz # 1.6 will report an error With # cd apr-util-1.5.1#. / configure-- prefix=/usr/local/apr-util-- with-apr=/usr/local/apr # of 1.5.1, you need to specify the path of the apr you just installed # makemake [1]: * * [xml/apr_xml.lo] Error 1make [1]: Leaving directory `/ lee/software/apr-util-1.5.1'make: * * [all-recursive] Error 1

If you report the above error, install the following devel package

# yum install expat-devel# make&make install

Install httpd:

#. / configure-- hlep to view common options:

-- sysconfdir=DIR// specifies the configuration file path

-- enable-so// supports dynamic sharing modules, which must be added to make php and apache work in a modular manner.

-- enable-proxy-fcgi// is used to make php and apache work together in the way of fcgi (fastcgi)

-- enable-cgi / / is used to make php and apache work together in the way of cgi

There are several ways in which apache and php work together:

Module: php is integrated into httpd in the form of module, httpd and php are a process

CGI:httpd uses CGI to interact with php, php creates processes independently (like tcp9000), and httpd creates and manages php processes.

FCGI:php is completely independent, has its own separate server, creates its own processes in advance, and manages its own processes.

-- enable-ssl// supports ssl for sites that need to enable https

-- enable-deflate// supports compression, that is, it is compressed and sent to the client browser, and the browser decompresses it to save traffic.

-- enable-mpms-shared=MPM-LIST// defines the MPM mode (multiprocessing module) event supported by httpd to be enabled | worker | prefork | winnt | all

-- with-mpm=MPM / / set the default MPM mode after defining MPM (MPM= {event | worker | prefork | winnt}), 2.4 default event

Several modes of MPM:

Event: a process (internally generated multiple threads) responds to multiple requests, and the process determines the processing state of the internal thread through event-driven (polling and notification) mechanisms

Worker: a process generates multiple child processes (threads) to respond to multiple requests

Prefork: a process responds to a request

-- enable-cgid//CGI scripts. Enabled by default with threaded MPMs (threaded event | MPM mode of worker must be enabled)

-- enable-rewrite// supports URL rewriting, which means redirection

#. / configure-- prefix=/usr/local/apache-- sysconfdir=/etc/httpd-- enable-so-- enable-rewirte-- enable-ssl-- enable-cgi-- enable-cgid-- enable-modules=most-- enable-mods-shared=most-- enable-mpms-shared=all-- with-mpm=event-- with-apr=/usr/local/apr-- with-apr-util=/usr/local/apr-util error: configure: error: pcre-config for libpcre not found. PCRE is required and available from # is missing pcre-devel# yum-y install pcre-devel# make# make install

Default directory for Apache compilation and installation:

Bin: binary file (startup script is apachectl in this directory)

The storage directory of the cgi-bin:CGI program

Htdocs: the directory where the web page is stored

Man: help documentation

Modules: module directory

Error: error messa

Icons: icon

Logs: log fil

Manual: official manual

The default pid file for compilation and installation is placed under / usr/local/apache/logs. It is best to change the location:

# vim / etc/httpd/httpd.confPidFile "/ var/run/httpd.pid" # add this line # / usr/local/apache/apachectl start # start the service

Optional configuration:

Let the service command recognize the startup script:

# ln-s / usr/local/apache/bin/apachectl / etc/init.d/httpd

Enables the system to directly recognize commands under / usr/local/apache/bin/:

Method 1:

# ln-s / usr/local/apache/bin/* / usr/bin # soft link to a directory of PATH variables

Method 2:

# vim / etc/profile.d/httpd.shexport PATH=$PATH:/usr/local/apache/bin # Edit a boot script and append the PATH variable

Join Boot Auto Boot:

Method 1:

# vim / etc/rc.d/rc.local/usr/local/apache/bin/apachectl start # Boot

Method 2: let chkconfig identify (abbreviated)

Two: MYSQL (universal binary package) installation:

Download the software package:

# wget https://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.58-linux-glibc2.12-i686.tar.gz

Decompress:

# tar xf mysql-5.5.58-linux-glibc2.12-i686.tar.gz

Copy to the directory you want to install and rename:

# cp-rf mysql-5.5.58-linux-glibc2.12-i686/* / usr/local/mysql/# cd / usr/local/mysql/

The specific installation method is described in this file:

# more INSTALL-BINARY

Create the system user mysql:

# useradd-r mysql

Change all files in the mysql directory from owner and group to mysql

# chown-R mysql.mysql / usr/local/mysql/

Execute the initialization script manually:

# / usr/local/mysql/scripts/mysql_install_db-- help # main options for initializing script configuration files

-- user=user_name: initialize as which user

-- datadir=path: data storage directory. By default, it is located in the data directory under the installation directory.

# / usr/local/mysql/scripts/mysql_install_db-- user=mysql # initialization

Service startup script:

# cp support-files/mysql.server / etc/init.d/mysqld # copy to the service management directory and rename # chkconfig-- add mysqld# chkconfig mysqld on

MYSQL profile:

There are several configuration files available for actual hardware conditions in the mysql/support-files/ directory:

# ls / usr/local/mysql/support-files/my-huge.cnfmy-large.cnfmy-small.cnf# more my-large.cnf # Example MySQL config file for large systems.## This is for a large system with memory = 512m where the system runs mainly # this configuration file can be selected around 512m memory # MySQL.datadir=YOURPATH # Note, if the data directory is specified during initialization Add this parameter # cp support-files/my-large.cnf / etc/my.cnf # to copy the configuration file and rename it. By default, mysql looks for the configuration file of my.cnf in this directory.

Start the mysqld service:

# service mysqld start

Append mysql/bin to PATH as usual to let the system recognize the command:

# vim / etc/profile.d/mysql.shexport PATH=$PATH:/usr/local/mysql/bin # append variables

Optional options:

# vim / etc/ld.so.conf.d/mysql.conf/usr/local/mysql/lib # output the library file, let the system read the mysql library file # ldconfig-v # reread the library file # ln-sv / usr/local/mysql/include / usr/include/mysql # output the header file, and let the system read the mysql header file

Third, compile and install PHP:

Download the package and extract it:

# wget http://cn2.php.net/distributions/php-5.6.33.tar.gz# tar xf php-5.6.33.tar.gz# cd / lee/software/php-5.6.33

Compile:

# / configure-- prefix=/usr/local/php-- with-mysql=/usr/local/mysql-- with-openssl-- with-mysqli=/usr/local/mysql/bin/mysql_config-- enable-mbstring-- with-freetype-dir-- with-jpeg-dir-- with-png-dir-- with-zlib-- with-libxml-dir=/usr-- enable-xml-- enable-sockets-- with-apxs2=/usr/local/apache/bin/apxs-- with-mcrypt- -with-config-file-path=/etc-with-config-file-scan-dir=/etc/php.d-with-bz2-enable-maintainer-zts

#-- with-apxs2=/usr/local/apache/bin/apxs: this item works with apche as a module. If you want to use fcgi, use:-- enable-fpm (note that the two items cannot coexist)

. / configure Times wrong yum installation of the corresponding software package and devel package can generally be solved, but some packages yum is not available, you need to manually download the rpm package to install:

# wget http://rpmfind.net/linux/dag/redhat/el6/en/i386/dag/RPMS/libmcrypt-2.5.7-1.2.el6.rf.i686.rpm# rpm-ivh libmcrypt-2.5.7-1.2.el6.rf.i686.rpm # wget http://rpmfind.net/linux/dag/redhat/el6/en/i386/dag/RPMS/libmcrypt-devel-2.5.7-1.2.el6.rf.i686.rpm# rpm-ivh libmcrypt -devel-2.5.7-1.2.el6.rf.i686.rpm # make# make install

Copy the configuration file to the profile directory you specified when you just configure:

# cp php.ini-production / etc/php.ini

Edit the configuration file for Apache so that apache can support php (PHP works as an apache module):

# vim / etc/httpd/httpd.conf

1. Add the following two lines

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

2. Navigate to DirectoryIndex index.html

Modified to:

DirectoryIndex index.php index.html

# httpd-t # check the syntax after modification # service httpd restart # restart service reread configuration file

Fourth, test the work of PHP and Apache:

# mv index.html index.html.bak// invalidates the default html home page # vim index.php EC Wang Sicong PHP Test PHP TEST # this is a PHP built-in function to test PHP

When you are finished, you can open the test in the browser.

Fifth, test the work of MYSQL and PHP:

# vim mysql.php EC Wang Sicong MYSQL Test MYSQL TEST

After the completion, open the mysql.php test in the browser and display SUCCESS to indicate success.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report