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 pure source compilation and installation log

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

Share

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

Lamp framework installation and experience skills (source code installation benefits. It is easy to manage, you can select parameters, you can use the new version)

List of related software:

# ls / soft/ | grep-E "* .gz | * .zip | * .xz | * .bz2"

Apr-1.4.5.tar.gz

Apr-util-1.3.12.tar.gz

Autoconf-2.61.tar.gz

Freetype-2.3.12.tar.gz

Httpd-2.4.18.tar.bz2

Jpegsrc.v6b.tar.gz

Libgd-2.1.1.tar.xz

Libmcrypt-2.5.8.tar.gz

Libpng-1.4.1.tar.gz

Libxml2-2.7.6.tar.gz

Mysql-5.6.17.tar.gz

Pcre-8.10.zip

Php-5.6.18.tar.gz

Zlib-1.2.5.tar.gz

Refer to the decompression method: for n in * .tar.gz; do tar zxf $nten done

Other uses: tar xf filename

Experience in installation and use of apache

Dynamic compilation and static compilation (loaded every time the service is started)

(apache's extensions are extended through the module mechanism. Apache supports PHP by compiling the module and then loading the module. )

(1) the related library file apr apr-util pcre required by apache (supports rewrite function)

Cd apr-1.4.5

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

Make & & make instal

Cd apr-util-1.3.12

. / configure-prefix=/usr/local/apr-util-with-apr=/usr/local/apr/bin/apr-1-config

Make & & make install

Cd pcre-8.10

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

Make&&make install

Here are the functional modules (to enable apache support to strengthen apache)

(2) install libxml2

Cd libxml2-2.7.6

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

Make & & make install

(3) install libmcrypt

Cd libmcrypt-2.5.8

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

Make & & make install

(4) install zlib

Cd zlib-1.2.5

. / configure

Make & & make install

(5) install libpng

Cd libpng-1.4.1

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

Make & & make install

(6) install jpeg6

This installation package cannot automatically create a directory that needs to be added manually

Mkdir / usr/local/jpeg6

Mkdir-p / usr/local/jpeg6/ {lib,bin,include}

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

Cd jpeg-6b

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

Make & & make install

Error checking host system type... Invalid configuration `x86q64muri unknownMutual LinuxMeignufang: machine `x86q64muri unknown' not recognized

Or make:. / libtool: Command not found appears

The general reason is that the version of the libtool library file since is low or missing.

Solution: install a higher version of libtool and copy 2 files

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

Cp / usr/share/libtool/config/config.guess.

Continue make & & make install

(7) install freetype

Cd freetype-2.3.12

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

Make & & make install

(8) install autoconf

Cd autoconf-2.61

. / configure

Make & & make install

(9) install GD library

Cd libgd-2.1.1

. / configure\

-- prefix=/usr/local/gd2/\

-- enable-m4_pattern_allow\

-- with-zlib=/usr/local/zlib/\

-- with-jpeg=/usr/local/jpeg6/\

-- with-png=/usr/local/libpng/\

-- with-freetype=/usr/local/freetype/

Make & & make install

Topic (1) apache source code compilation and installation

Cd httpd-2.4.18

. / configure-- prefix=/usr/local/apache2\

-- enable-mods-shared=all\

-- enable-so\

-- enable-proxy-ajp\

-- enable-rewrite\

-- with-apr=/usr/local/apr\

-- with-apr-util=/usr/local/apr-util\

-- with-pcre=/usr/local/pcre

Make & & make install

# / usr/local/apache2/bin/apachectl start

# curl 127.0.0.1

It works!

Main directories under apache

Bin build cgi-bin conf error htdocs icons include logs man manual modules

(1) bin is the location where some commands are stored. Such as httpd provides apache service management such as startup and shutdown.

Use:. / bin/httpd-k {start | restart | stop}

Apxs is the command related to the compilation module (PHP module)

Apachectl is a script that invokes the httpd service.

For example, view statically compiled modules

#. / bin/apachectl-l

Compiled in modules:

Core.c

Mod_so.c

Http_core.c

Worker.c

#. / bin/httpd-l (further confirm the relationship between http and apachectl)

Compiled in modules:

Core.c

Mod_so.c

Http_core.c

Worker.c)

(2) the htdocs directory is the directory where programmers write programs.

(3) the directory where modules places the apache compilation module. .so (suffix name of the module)

(4) the directory of logs log files contains pid files (including apache parent processes)

* ps-ef | grep httpd****

Check that if the child process is discontinuous, it may be a problem with apache. Reboot occurs.

(5) conf contains all configuration files of apache

(6) cgi-bin provides some functions of online tables. If you do not need to empty the files in this directory (reduce security risks)

Apache parses the main parameters in the PHP statement http.conf

DirectoryIndex index.html index.php

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php

Topic (2) mysql source code compilation and installation

Cd mysql-5.6.17

Cmake\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DMYSQL_DATADIR=/usr/local/mysql/data\

-DSYSCONFDIR=/etc\

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_MEMORY_STORAGE_ENGINE=1\

-DWITH_READLINE=1\

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock\

-DMYSQL_TCP_PORT=3306\

-DENABLED_LOCAL_INFILE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DEXTRA_CHARSETS=all\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci

Analysis of attribute values of Mysql compilation and installation

# cmake\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

# specify the installation path

-DMYSQL_DATADIR=/usr/local/mysql/data\

# specify the storage path of mysql data (library) files

-DSYSCONFDIR=/etc\

# configuration file

-DWITH_MYISAM_STORAGE_ENGINE=1\

# engine supports myisam

-DWITH_INNOBASE_STORAGE_ENGINE=1\

# engine supports innodb

-DWITH_MEMORY_STORAGE_ENGINE=1\

# engine supports memory-storage

-DWITH_READLINE=1\

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock\

# specify the sock file path of mysql

-DMYSQL_TCP_PORT=3306\

# specify the MySQL port number

-DENABLED_LOCAL_INFILE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DEXTRA_CHARSETS=all\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci

# specify character set

Error:

CMake Error at cmake/readline.cmake:85 (MESSAGE):

Curses library not found. Please install appropriate package

Remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev

On Redhat and derivates it is ncurses-devel.

Solution: yum install ncurses-devel-y

\ mv\ mv CMakeCache.txt / tmp

Then re-cmake (if there is no error in the above instruction)

Make & & make install

Check to see if any mysql users and groups are not created.

Useradd mysql-s / sbin/nologin-M

Modify mysql permissions:

Chown-R mysql.mysql / usr/local/mysql

Enter the mysql installation directory, execute the initialization configuration script, and create the database and table that comes with the system.

#. / scripts/mysql_install_db-basedir=/usr/local/mysql/-datadir=/usr/local/mysql/data-user=mysql

Start the mysql service: #. / support-files/mysql.server start

Error prompt:

Starting MySQL.... ERROR! The server quit without updating PID file (/ usr/local/mysql/data/swallow.pid)

Possible causes and solutions:

(1)。 If this is the first time to install. Maybe the initialization was not successful. When executing the initialization command. The prompt contains 2 OK (for success. This situation is reinitialized.

(2) mysql may have been installed in the original system. You can use ps-ef | grep msyql to view. Then end the process: pkill mysql

(3) the permissions of the data directory may be incorrect. Chmod 755 data

(4) chown-R mysql:mysql / usr/local/mysql usually occurs after the owner or group is created (this is unlikely).

Start the mysql program:

. / bin/mysql

You can see the mysql status:

Mysql > status

-

. / bin/mysql Ver 14.14 Distrib 5.6.17, for Linux (x86 / 64) using EditLine wrapper

Connection id: 1

Current database:

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile:''

Using delimiter:

Server version: 5.6.17 Source distribution

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8

Db characterset: utf8

Client characterset: utf8

Conn. Characterset: utf8

UNIX socket: / var/lib/mysql/mysql.sock

Uptime: 7 min 7 sec

Threads: 1 Questions: 5 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.011

-

Topic (3) PHP source code compilation and installation

Cd php-5.6.18

. / configure\

-- prefix=/usr/local/php\

-- with-config-file-path=/usr/local/php/etc\

-- with-apxs2=/usr/local/apache2/bin/apxs\

-- with-mysql=/usr/local/mysql/\

-- with-libxml-dir=/usr/local/libxml2/\

-- with-png-dir=/usr/local/libpng/\

-- with-jpeg-dir=/usr/local/jpeg6/\

-- with-freetype-dir=/usr/local/freetype/\

-- with-gd=/usr/local/gd2/\

-- with-zlib-dir=/usr/local/zlib/\

-- with-mcrypt=/usr/local/libmcrypt/\

-- with-mysqli=/usr/local/mysql/bin/mysql_config\

-- with-xpm-dir=/usr/lib64/\

-- enable-soap\

-- enable-mbstring=all\

-- enable-sockets

Detailed explanation of parameters

. / configure\

-- prefix=/usr/local/php\

# installation path

-- with-config-file-path=/usr/local/php/etc\

# configuration file path of PHP

-- with-apxs2=/usr/local/apache2/bin/apxs\

# support modules (tools) required to connect with apache

-- with-mysql=/usr/local/mysql/\

-- with-libxml-dir=/usr/local/libxml2/\

-- with-png-dir=/usr/local/libpng/\

-- with-jpeg-dir=/usr/local/jpeg6/\

-- with-freetype-dir=/usr/local/freetype/\

-- with-gd=/usr/local/gd2/\

-- with-zlib-dir=/usr/local/zlib/\

-- with-mcrypt=/usr/local/libmcrypt/\

# all previously installed connection modules required by PHP

-- with-mysqli=/usr/local/mysql/bin/mysql_config\

# specify how the PHP program connects to mysql

# PHP5.3 . 3. Mysqlnd was developed later. It is a new driver configuration method for PHP to connect to mysql:

-- with-mysql=mysqlnd\

-- with-mysqli=mysqlnd\

-- with-pdo-mysql=mysqlnd\

If you want to load all three, you can load the

-- with-mysqli=/usr/local/mysql/bin/mysql_config\

Replace this sentence with the above three sentences.

# it should be noted that there are three ways to connect mysql to mysql. Are: mysql,mysqli and pdo

# there are two things to pay attention to here: mysqli and pdo. (they are mainstream ones that support higher versions.)

-- with-xpm-dir=/usr/lib64/\

-- enable-soap\

-- enable-mbstring=all\

-- enable-sockets

Error: configure: error: xpm.h not found.

Solution: yum install libXpm-devel-y

Make & & make install

The method of PHP dynamic loading module: if the module is not compiled in static compilation, it can be loaded dynamically.

For example: check the module directory under the source code

Cd / soft/php-5.6.18/ext/

The following modules can be dynamically loaded and compiled. Take ftp as an example

Cd ftp

/ usr/local/php/bin/phpize (use this command to generate a series of installation files such as configure, etc.)

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

Make & & make install

At this point, the compilation and installation of the ftp module is complete. Then, you need to load the file (modify php.ini)

Cd / usr/local/php/etc/

Vim php.ini (without this file in the initial installation, you can copy it in the / soft/php-5.6.18/ source directory.

Php.ini-development php.ini-production generally these two files are commonly used by operation and maintenance staff (the second)

Find the comments related to extension

Add the following two sentences: (the position of the module under the PHP program {generally prompted after compiling the dynamic module} and the name of the module)

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

Extension = ftp.so

Restart the apache server if you want to load the module.

/ usr/local/apache2/bin/httpd-k restart

Check whether the PHP module is loaded successfully; you can use the php command to display it to see if it has been added

/ usr/local/php/bin/php-m

Test whether the lamp is built successfully:

Create a new .php file in the htdocs directory of apach3

Vim. / htdocs/info.php

Browser test: http://192.168.1.140/info.php

The result is blank.

Solution: check to see if / usr/local/apache2/modules/ contains the libphp5.so module.

(this module is responsible for PHP parsing by apache.)

Modify the configuration file: http.conf

ServerName loacalhost:80

(imitate this line to add AddType application/x-gzip .gz .tgz)

AddType application/x-httpd-php .php

Error loading pdo-mysql: make error

/ soft/php-5.6.18/ext/pdo_mysql/php_pdo_mysql_int.h:27:34: error: ext/mysqlnd/mysqlnd.h: No such file or directory

Solution: cp-a / soft/php-5.6.18/ext/pdo_mysql / usr/local/php/include/php/ext/

The idea here is: make operates in the installation directory. Does not operate in the source directory. You need to place the dependent files under the installation path. Easy to use.

However: unfortunately, after the installation is complete, it cannot be loaded. In a conventional way:

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

Extension = pdo_mysql.so

A lot of httpd was restarted and did not load successfully. I haven't seen it with bin/php-m. I can make sure that the modified php.ini file takes effect, after commenting out that ftp module

You can't see that module show up. So, it had to be recompiled.

Replace the compiled-- with-mysqli=/usr/local/mysql/bin/mysql_config\ statement with:

-- with-mysql=mysqlnd\

-- with-mysqli=mysqlnd\

-- with-pdo-mysql=mysqlnd\

These words. There are 3 ways to connect to mysql. Here mysqlnd is the default engine above PHP5.3 to connect to mysql

When PHP does not support extended mysql (mysqli) compilation, it can be:-- with-pdo-mysql=mysqlnd\

Attach 3 scripts for PHP connection

Cat mysqli.php mysql-pdo.php mysql.php

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