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

Build LAMP environment with source code package

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

The first step

1. Install the compilation tool gcc*

Install the database compilation tool cmake bison

Yum-y install gcc* cmake bison

2. Download the LAMP package: lamp.zip, and use the script to extract tar.sh in batches.

3. Turn off firewall and Selinux

Step two

Compile and install each source package separately (a total of 17 packages)

1. Source packages that can be installed directly

2.1and # install libxml2

Install yum-yinstall python-devel first

Mkdir / usr/local/libxml2/

Cd / lamp/libxml2-2.9.1

. / configure--prefix=/usr/local/libxml2/ & & make&& make install

2.2and # install libmcrypt

Mkdir / usr/local/libmcrypt/

Cd / lamp/libmcrypt-2.5.8

. / configure-- prefix=/usr/local/libmcrypt/ & & make & & make install

2.3, # install libltdl

Also in the libmcrypt source directory

Cd/lamp/libmcrypt-2.5.8/libltdl

. / configure--enable-ltdl-install & & make & & make install

2.4and # install mhash

Cd / lamp/mhash-0.9.9.9

. / configure & & make & & make install

# install mcrypt

Cd/lamp/mcrypt-2.6.8

LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib. / configure

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

Make & & make install

# install zlib

Cd / lamp/zlib-1.2.3

. / configure

Vi Makefile

CFLAGS=-O3-DUSE_MMAP

Modify to CFLAGS=-O3-DUSE_MMAP-fPIC

Make&& make install

2.7and # install libpng

Mkdir / usr/local/libpng/

Cd / lamp/libpng-1.2.31

. / configure--prefix=/usr/local/libpng/ & & make&& make install

2.8and # install jpeg6

Yum-y install "libtool*" must be installed first

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

Cd / lamp/jpeg-6b

Cp / usr/share/libtool/config/config.sub.

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

2.9, # install freetype

Cd/lamp/freetype-2.3.5

. / configure--prefix=/usr/local/freetype/ & & make & & make install

2.10 # install ncurses

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.

Cd/lamp/ncurses-5.9

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

Make & & make install

2. Heavyweight source package

2.11 # 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 isrequired 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 enablemod_ssl... Configure: error: mod_ssl has been requested but can not be builtdue 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/apachectlstart

Ps aux | grep httpd

Netstat-antp | grep: 80

You can use a script to start apache like httpd

Cat apache.sh

#! / bin/bash

# chkconfig manages apache service

# chkconfig:- 82 15

# discription:

Path=/usr/local/apache2/bin/apachectl

Case $1 in

Start)

$path start

Stop)

$path stop

Restart)

$path stop

Sleep 3s

$path start

Configtest)

$path-t

*)

Echo "pleas input start | stop | restart | configtest."

Esac

Mv apache.sh / etc/init.d/httpd

Chmod 755 httpd

Service httpd start

* 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.

Boot when setting up the Apache system: boot automatically

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

Note: after the installation is complete, start apache to verify whether the installation is successful and whether the home page is accessible.

Note: found startup service error: AH00558: httpd: Could not reliably determine the server's fullyqualified domain name, using localhost.localdomain. Set the 'ServerName' directiveglobally to suppress this message

Solution: open the main configuration file / usr/local/apache/etc/httpd.conf

Search for ServerName (about 200 lines)

Change to ServerName localhost:80 (and remove the previous # comment)

2.12 # install MySQL

Useradd-r-s / sbin/nologin mysql

Mkdir / usr/lo cal/mysql-p

* create a system user mysql

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 extended 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

Makeclean

RmCMakeCache.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 &

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-urootpassword 123456

Clear history command history-c

* add password 123 to mysql user root

* pay attention to the password can not be written too simple, do experiments casually

/ 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

2.13 # install PHP

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

Yum-yinstall "libtool*"

Mkdir/usr/local/php/etc/-p

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.

Make

Make install

Generate php.ini

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. It prompts cannot restore segmentprot after reloc: Permission denied error. For SELinux problem, you can close SELinux or execute the command chcon-ttexrel_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

2.14 # 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

Mvconfig0.m4 config.m4 otherwise error: config.m4 not found

PATH=$PATH:/usr/local/php/bin/ (temporary) vi / etc/profile

Cd/lamp/php-7.0.7/

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

Make

Makeinstall

2.15 # compile and install pecl

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 this is a command to generate a configuration directory

. / 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"

Modify location

# add

# restart apache. You can find this module in phpinfo

2.16 # install the memcache source code

First install the dependency package libevent

Yum-yinstall 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

Mkdir / usr/local/memcache

Cd/lamp/memcached-1.4.17

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

Make & & makeinstall

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 &

The third step, 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.

Step 4, install phpMyAdmin (add users to php management)

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

Cd/usr/local/apache2/htdocs/phpmyadmin

Cpconfig.sample.inc.php config.inc.php

Vim config.inc.php

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

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

Both of the above lines have

* 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