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

LAMP environment building

2025-04-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Build Lamp environment: (move the extracted lamp directory to the "/" directory)

I. preparatory work

1. Install the compilation tools gcc and gcc-c++

Pay attention to solving the dependency, it is recommended to use yum installation, if you can not connect to the network, you can use the installation CD as the yum source--

1) Edit the yum configuration file:

# mount / dev/cdrom / mnt/cdrom

# vim / etc/yum.repos.d/CentOS-Media.repo

[c6-media]

Name=CentOS-$releasever-Media

Baseurl= file:///mnt/cdrom * modified to CD mount point

Gpgcheck=0

Enabled=1 * changed to 1 means to enable

Gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

2) cut / etc/yum.repos.d/CentOS-Base.repo

# mv / etc/yum.repos.d/CentOS-Base.repo / backup

3) install gcc and gcc-c++ in turn

# yum-y install gcc

# yum-y install gcc-c++

2. Disable the Apache and MySQL services of the system RPM installation package

Shut down the started services httpd and mysqld

# service httpd stop

# service mysqld stop

Make sure that the httpd and mysqld installed in the rpm package cannot be booted automatically

Chkconfig-level 2345 httpd (mysqld) off

3. Close SELinux and allow firewall port 80 to access.

1) close SELinux

# vim / etc/selinux/config

SELINUX=disabled * if SELinux is not disabled during installation, change enforcing to disabled

After modification, you need to restart Linux to take effect!

2) turn off the firewall Netfilter/iptables

As the firewall has not yet been explained, simply turn off all firewall settings:

# iptables-F * if the firewall is not disabled, access to port 80 is prohibited by default

Iptables-An INPUT-p tcp-dport 80-j ACCEPT

Iptables-Z

Iptables-X

4. Turn off unnecessary self-starting service

# ntsysv

The following list of services can remain self-starting, and unlisted services can be turned off:

Atd

Crond # atd, crond scheduling tasks

Irqbalance

Microcode_ctl # system irq port invocation, system service

Network # Network Settings

Sendmail # Mail

Sshd # remote Management

Syslog # Syslog

5. Copy the source package, unpack and decompress (pay attention to whether the unzip software is installed on the system)

It is recommended to store the LAMP environment installation source code package in one directory, such as / lamp

You can write a batch processing script to unpack all .tar.gz installation packages at once.

# vim tar-for-if.sh

#! / bin/bash

Ls * >. / list.txt

For an in $(cat list.txt)

Do

If [["$a" = ~ "tar"]]

Then

Tar-xf $a

Elif [["$a" = ~ "tgz"]]

Then

Tar-xf $a

Elif [["$a" = ~ "gz"]]

Then

Gunzip $a

Elif [["$a" = ~ "bz"]]

Then

Bunzip2 $a

Elif [["$a" = ~ "zip"]]

Then

Unzip $a

Else

Echo "$an is not a zip file."

Fi

Done

6. Check to confirm that the disk space is not full.

Df-h

* if / partition is full, you can move the installation package to another partition or delete other useless files

How to determine the error report:

1) the installation process stops

2) after stopping, error or warning appears in the one-page interface

How to determine the success of the installation:

Enter the installation directory and confirm that the installer appears, which is a success.

II. Compilation and installation

* after the compilation and installation of each source package configuration is completed, confirm whether the installation files are generated in the installation directory

# install libxml2

Libxml2 is a xml c language parser, originally developed for the Gnome project tool, is a MIT License-based free and open source software. It not only supports the c language version, but also supports the binding of C++, PHP, Pascal, Ruby, Tcl and other languages, and can run on Windows, Linux, Solaris, MacOsX and other platforms. The function is still quite powerful, and I believe there is no problem in meeting the needs of general users.

Libxml is a library for parsing XML documents. It is written in C language, and can be called by many languages, such as C language, C language. Che, Python,Kylix/Delphi,Ruby, and PHP, etc. The XML::LibXML module can also be used in Perl. It was originally developed for GNOME, but now it can be used in a variety of ways. LibXML code is very portable because it is based on the standard ANSI C library and is licensed under the MIT license.

# yum install-y libxml2-devel if there is an error, install this package and then try to install it

Yum-y install python-devel must be installed

Cd / lamp/libxml2-2.9.1

. / configure-- prefix=/usr/local/libxml2/

Make

Make install

# install libmcrypt

Libmcrypt is an extended library of encryption algorithms. Support DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+ and other algorithms.

Cd / lamp/libmcrypt-2.5.8

. / configure-- prefix=/usr/local/libmcrypt/

Make

Make install

* gcc-c++ compiler needs to be called. Error will be reported if it is not installed.

# install libltdl, also in the libmcrypt source directory, not new software

Cd / lamp/libmcrypt-2.5.8/libltdl

. / configure-- enable-ltdl-install

Make

Make install

# install mhash

Mhash is an irreversible php encryption extension library based on discrete mathematics, which is not turned on by default. Mhash can be used to create check values, message digests, message authentication codes, and save key information without the original text (such as passwords).

Cd / lamp/mhash-0.9.9.9

. / configure

Make

Make install

# install mcrypt

Mcrypt is an important encryption support extension library in php. The Mcrypt library supports more than 20 encryption algorithms and 8 encryption modes

Cd / lamp/mcrypt-2.6.8

LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib\

. / configure-- with-libmcrypt-prefix=/usr/local/libmcrypt

# the above is a command. LD_LIBRARY_PATH is used to specify the location of libraries for libmcrypt and mhash.

-- with-libmcrypt-prefix is used to specify the libmcrypt software location

Make

Make install

# install zlib

Zlib is a function library for data compression, developed by Jean-loup Gailly and Mark Adler. The first version 0.9 was released on May 1st, 1995. Zlib uses the DEFLATE algorithm, which was originally written for the libpng library and has since been widely used by many software. This function library is free software and uses zlib license

Cd / lamp/zlib-1.2.3

. / configure

Vi Makefile

# find CFLAGS=-O3-DUSE_MMAP

# add after-fPIC becomes

CFLAGS=-O3-DUSE_MMAP-fPIC

Make & & make install

Cd / lamp/zlib-1.2.3

. / configure

Make

Make install > > / root/zlib.log (32-bit operating system uses this command)

* the installation directory specified by zlib may cause the installation of libpng to fail, so it is not specified. For the convenience of uninstallation, it is recommended that the execution result of make install be output to the installation log file for later uninstallation.

# install libpng

The libpng package contains the libpng library. These libraries are used by other programs to decode png images.

Cd / lamp/libpng-1.2.31

. / configure-- prefix=/usr/local/libpng

Make

Make install

# install jpeg6

Used to decode .jpg and .jpeg pictures

Mkdir / usr/local/jpeg6

Mkdir / usr/local/jpeg6/bin

Mkdir / usr/local/jpeg6/lib

Mkdir / usr/local/jpeg6/include

Mkdir-p / usr/local/jpeg6/man/man1

# directories must be created manually

Yum-y install "libtool*"

Cd / lamp/jpeg-6b

[root@localhost jpeg-6b] # cp / usr/share/libtool/config/config.sub.

[root@localhost jpeg-6b] # cp / usr/share/libtool/config/config.guess.

# copy files in libtool and overwrite files in jpeg-6b (problem in 64-bit, 32-bit does not report this error)

Cd / lamp/jpeg-6b

. / configure-- prefix=/usr/local/jpeg6/-- enable-shared-- enable-static

Make

Make install

*-- enable-shared and-- enable-static parameters are the libtool used to build shared libraries and static libraries, respectively.

# install freetype

FreeType library is a completely free (open source), high-quality and portable font engine, it provides a unified interface to access a variety of font format files, including TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF and so on. Support monochrome bitmap, anti-aliasing bitmap rendering. FreeType library is a highly modular library. Although it is developed in ANSI C, it adopts object-oriented idea, so users of FreeType can tailor it flexibly.

Cd / lamp/freetype-2.3.5

. / configure-- prefix=/usr/local/freetype/

Make

Make install

# install Apache

Configure: error: Bundled APR requested but not found at. / srclib/. Download and unpack the corresponding apr and apr-util packages to. / srclib/.

# if an error is reported, then:

Tar zxvf apr-1.4.6.tar.gz

Tar zxvf apr-util-1.4.1.tar.gz decompressed.

Cp-r / lamp/apr-1.4.6 / lamp/httpd-2.4.7/srclib/apr

Cp-r / lamp/apr-util-1.4.1 / lamp/httpd-2.4.7/srclib/apr-util

# decompress apr and apr-util, copy and cancel the version number

Configure: error: pcre-config for libpcre not found. PCRE is required and available from

# if an error is reported, then:

Tar zxvf pcre-8.34.tar.gz

Cd / lamp/pcre-8.34

. / configure & & make & & make install

Checking whether to enable mod_ssl... Configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

# if an error is reported, then:

Yum install openssl-devel

Install apache

Cd / lamp/httpd-2.4.7

/ configure-- prefix=/usr/local/apache2-- sysconfdir=/usr/local/apache2/etc-- with-included-apr-- enable-so-- enable-deflate=shared-- enable-expires=shared-- enable-rewrite=shared

Make

Make install

* if the installation directory is not specified when configuring zlib, do not add the-- with-z=/usr/local/zlib/ parameter when configuring Apache.

Start the Apache test:

/ usr/local/apache2/bin/apachectl start

Ps aux | grep httpd

Netstat-tlun | grep: 80

* if you prompt / usr/local/apache2/modules/mod_deflate.so to have no permission at startup, you can close SELinux or execute the command chcon-t texrel_shlib_t / usr/local/apache2/modules/mod_deflate.so. The problem that the .so file cannot be loaded or has no permission is a SELinux problem, which can be solved by using the command: "chcon-t texrel_shlib_t file name". MySQL and Apache may also have similar problems.

Enter the address through the browser to access: http://Apache server address. If "It works" is displayed, it means that Apache is working properly.

Start when setting up the Apache system boot:

Echo "/ usr/local/apache2/bin/apachectl start" > > / etc/rc.d/rc.local

# install ncurses

Ncurses provides a character terminal processing library, including panels and menus. It provides a set of functions that control the cursor, create windows, change the background color of the foreground, and handle mouse operations. Enables users to bypass those annoying underlying mechanisms when writing applications under character terminals. In short, it is a function library that enables applications to directly control the display of the terminal screen.

1. Yum-y install ncurses-devel

Note: if an error is reported and the package cannot be found, the * wildcard is not recognized. Put double quotation marks "ncurses*" on the file name.

2. Source code compilation:

Cd / lamp/ncurses-5.9

. / configure-with-shared-without-debug-without-ada-enable-overwrite

Make

Make install

* error will be reported when compiling MySQL without installing ncurses

*-- without-ada parameter is set not to compile to ada binding, ada cannot be used to enter chroot environment;-- enable-overwrite parameter installs header files to / tools/include instead of / tools/include/ncurses directory for definition

*-- with-shared generates shared libraries

# install cmake and bison

After mysql 5.5, the. / configure tool is no longer used for compilation and installation. Instead of the. / configure tool, the cmake tool is used. The specific use of cmake is described in the document cmake.

Bison is free software for automatically generating parser programs that can be used in all common operating systems

Yum-y install cmake

Yum-y install bison

# install MySQL

Groupadd mysql

Useradd-g mysql mysql

* add user group mysql, and set mysql user default group to mysql user group

Cd / lamp/mysql-5.5.48

Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DEXTRA_CHARSETS=all-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DMYSQL_USER=mysql-DMYSQL_TCP_PORT=3306

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql installation location

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock specifies the socket (socket) file location

-DEXTRA_CHARSETS=all character support

-DDEFAULT_CHARSET=utf8 default character set

-DDEFAULT_COLLATION=utf8_general_ci default character proofreading

-DWITH_MYISAM_STORAGE_ENGINE=1 installs the myisam storage engine

-DWITH_INNOBASE_STORAGE_ENGINE=1 installs the innodb storage engine

-DWITH_MEMORY_STORAGE_ENGINE=1 installs the memory storage engine

-DWITH_READLINE=1 supports readline libraries

-DENABLED_LOCAL_INFILE=1 enables loading of local data

-DMYSQL_USER=mysql specifies the mysql running user

-DMYSQL_TCP_PORT=3306 specifies the mysql port

Make

Make install

Make clean

Rm CMakeCache.txt

# if an error is reported, clear the cache, please use the above command

Cd / usr/local/mysql/

Chown-R root.

Chown-R mysql data

# modify mysql directory permissions

Cp support-files/my-medium.cnf / etc/my.cnf

# copy mysql configuration file

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

# create database authorization table and initialize database

Start the MySQL service:

1. Use and start mysql in the same way as the original source code

/ usr/local/mysql/bin/mysqld_safe-- user=mysql & after executing the command, enter the car after a while

two。 It will take effect after the restart:

Vim / etc/rc.local

/ usr/local/mysql/bin/mysqld_safe-user=mysql &

3. Set mysql password

/ usr/local/mysql/bin/mysqladmin-uroot password 123

Clear history command history-c

* add password 123 to mysql user root

* Note that the password cannot be written as "123"

/ usr/local/mysql/bin/mysql-u root-p

Mysql > show databases

Mysql > use test

Mysql > show tables

Mysql >\ s # check whether the character set has been changed to utf8

* use set to change your password after entering mysql

Mysql > exit

* Log in to the MySQL client console to set the specified root password

# install PHP

Before compilation, make sure that the libtool and libtool-ltdl packages are installed on the system. Install:

Yum-y install "libtool*"

Cd / lamp/php-7.0.7

/ configure-- prefix=/usr/local/php/-- with-config-file-path=/usr/local/php/etc/-- with-apxs2=/usr/local/apache2/bin/apxs-- with-libxml-dir=/usr/local/libxml2/-- with-jpeg-dir=/usr/local/jpeg6/-- with-png-dir=/usr/local/libpng/-- with-freetype-dir=/usr/local/freetype/-- with-mcrypt=/usr/local/libmcrypt/ -with-mysqli=/usr/local/mysql/bin/mysql_config-enable-soap-enable-mbstring=all-enable-sockets-with-pdo-mysql=/usr/local/mysql-with-gd-without-pear

If you did not specify the installation directory when configuring zlib, do not add the-- with-zlib-dir=/usr/local/zlib/ parameter when configuring PHP.

Options:

-- with-config-file-path=/usr/local/php/etc/ specifies the configuration file directory

-- with-apxs2=/usr/local/apache2/bin/apxs specifies the location of apache dynamic module

-- with-libxml-dir=/usr/local/libxml2/ specifies the libxml location

-- with-jpeg-dir=/usr/local/jpeg6/ specifies the jpeg location

-- with-png-dir=/usr/local/libpng/ specifies the libpng location

-- with-freetype-dir=/usr/local/freetype/ specifies the freetype location

-- with-mcrypt=/usr/local/libmcrypt/ specifies the libmcrypt location

-- with-mysqli=/usr/local/mysql/bin/mysql_config specifies the mysqli location

-- with-gd enables gd libraries

-- enable-soap supports soap services

-- enable-mbstring=all supports multibyte and string

-enable-sockets supports sockets

-- with-pdo-mysql=/usr/local/mysql mysql-enabled pdo module support

-- without-pear does not install pear (Internet connection is required to install pear. PEAR is a PHP extension and application library)

Make

Make install

Generate php.ini

# mkdir / usr/local/php/etc/

Cp / lamp/php-7.0.7/php.ini-production / usr/local/php/etc/php.ini

Test the connectivity between Apache and PHP to see if Apache can parse php files

Vim / usr/local/apache2/etc/httpd.conf

AddType application/x-httpd-php .php .phtml

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

(pay attention to case)

* .phtml syntax highlighting for .phps as a PHP source file

Restart the Apache service: / usr/local/apache2/bin/apachectl stop

/ usr/local/apache2/bin/apachectl start

* Apache cannot be started, prompting cannot restore segment prot after reloc: Permission denied error. For SELinux problem, you can close SELinux or execute the command chcon-t texrel_shlib_t / usr/local/apache2/modules/libphp5.so.

Test: vim / usr/local/apache2/htdocs/test.php

Enter the address through the browser to access: http://Apache server address / test.php

Default directory of web pages for Rpm package installation / var/www/html/

* sometimes the first browser test will fail. Just close the browser and restart and try again. Non-compilation error

# install openssl

OpenSSL is a powerful secure socket layer cipher library that includes major cryptographic algorithms, commonly used key and certificate encapsulation management functions, and SSL protocols, and provides rich applications for testing or other purposes.

Yum-y install openssl-devel must be installed

Cd / lamp/php-7.0.7/ext/openssl

Mv config0.m4 config.m4 otherwise error: config.m4 not found

/ usr/local/php/bin/phpize

. / configure-with-openssl-with-php-config=/usr/local/php/bin/php-config

Make

Make install

# compile and install memcache

Memcache is a high-performance distributed in-memory object caching system. By maintaining a unified huge hash table in memory, it can be used to store data in various formats, including images, videos, files and database retrieval results. To put it simply, the data is called into memory and then read from memory, thus greatly improving the reading speed.

Https://github.com/websupport-sk/pecl-memcache/archive/php7.zip

Unzip pecl-memcache-php7.zip

Cd pecl-memcache-php7

/ usr/local/php/bin/phpize

. / configure-- with-php-config=/usr/local/php/bin/php-config

Make & & make install

Modify / usr/local/php/etc/php.ini

Extension_dir = "/ usr/local/php/lib/php/extensions/no-debug-zts-20151012/"

# Open comments and modify

Extension= "openssl.so"

Extension= "memcache.so"

# add

# restart apache. You can find this module in phpinfo

# install memcache source code

First install the dependency package libevent

Yum-y install "libevent-devel"

# in the second CD of CentOS 6.3Please change the disk

Umount / mnt/cdrom

# insert the second CD of CentOS 6.3

# mount / dev/sr0 / mnt/cdrom

Cd / lamp/memcached-1.4.17

. / configure-- prefix=/usr/local/memcache

Make & & make install

Useradd memcache

# add a memcache user who does not need to log in or set a password

/ usr/local/memcache/bin/memcached-umemcache &

Netstat-an | grep: 11211

Write self-starting:

Vi / etc/rc.d/rc.local

/ usr/local/memcache/bin/memcached-umemcache &

Project Migration:

1. Copy the php project to the default directory of the website: / usr/local/apache2/htdocs/

2. Establish the database table structure manually.

# install phpMyAdmin

Cp-r / lamp/phpMyAdmin-4.1.4-all-languages / usr/local/apache2/htdocs/phpmyadmin

Cd / usr/local/apache2/htdocs/phpmyadmin

Cp config.sample.inc.php config.inc.php

Vim config.inc.php

$cfg ['Servers'] [$I] [' auth_type'] = 'cookie'

$cfg ['Servers'] [$I] [' auth_type'] = 'http'

* set auth_type to http, that is, to HTTP authentication mode

Enter the address through the browser to access: http://Apache server address / phpmyadmin/index.php

The user name is root, and the password is the root password 123456 (lampbrother) specified when MySQL is set.

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