Linux (vii) LAMP environment construction

Source: Internet
Author: User
Tags gpg install php http authentication mysql client pear unpack phpmyadmin zend

First, the preparatory work

1. Install the compilation tool GCC, gcc-c++
Note To resolve dependencies, it is recommended to use Yum installation, if not networked can use the installation CD as a Yum source--
1) Edit the Yum configuration file:
# Mount/dev/cdrom/mnt/cdrom
# Vi/etc/yum.repos.d/centos-media.repo
[C5-media]
name=centos-$releasever-media
Baseurl=file:///mnt/cdrom * Modify to CD mount point
file:///media/cdrom/
file:///media/cdrecorder/
Gpgcheck=0
Enabled=1 * Change to 1 means enable
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-5
2) Shear/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. Turn off the system RPM installation package Apache, MySQL service
Turn off startup services httpd, mysqld
# Service HTTPD Stop
# Service Mysqld Stop

Determine RPM package installation of httpd and mysqld does not boot from boot
Chkconfig--level 2345 httpd (mysqld) off

3, turn off SELinux, allow firewall 80 port access
Using Setup
Shutting down firewalls and SELinux

1) Turn off SELinux
# Vi/etc/selinux/config
selinux=disabled * If SELinux is not disabled during installation, change enforcing to Disabled
You need to restart Linux after modification to take effect!
2) Turn off firewall netfilter/iptables
Simply shut down all firewall settings by not doing a firewall explanation:
# iptables-f * If the firewall is not disabled, the default 80 port is forbidden
Iptables-z
Iptables-x

4, close unnecessary self-start service
# NTSYSV
The following list of services can be maintained from startup, and services that are not listed are closed:
Atd
Crond # ATD, Crond Scheduled Tasks
Irqbalance
MICROCODE_CTL # System IRQ Port call, system service
Network #网络设置
SendMail #邮件
Sshd #远程管理
Syslog #系统日志

5. Copy source package, unpack and unzip
It is recommended to store the lamp environment installation source package in a directory, such as/lamp
You can write a batch processing script to unpack all. tar.gz packages at once.
# VI tar.sh
Cd/lamp
/bin/ls *.tar.gz > Ls.list
/bin/ls *.tgz >> ls.list
For TAR in ' Cat ls.list '
Do
/BIN/TAR-ZXF $TAR
Done
/bin/rm ls.list

6. Check 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:
1) installation process stopped
2) after stopping, error or warning appears in one page interface

How to determine the installation success:
Enter the installation directory to confirm that the installer appears and is successful

Second, compile and install

* After each source package configuration is compiled and installed, verify that the installation files are generated in the installation directory

# Install LIBXML2
LIBXML2 is an XML C language parser that was originally developed for the GNOME project and is a free open source software based on MIT license. In addition to supporting the C language version, it also supports C + +, PHP, Pascal, Ruby, Tcl and other language bindings, can run on Windows, Linux, Solaris, MACOSX and other platforms. function is still quite strong, I believe that meeting the needs of the general user without any problems. Libxml is a library of functions used to parse XML documents. It is written in C and can be called in many languages, such as C, C++,xsh. C#? Python,kylix/delphi,ruby, and PHP and so on. The Xml::libxml module can also be used in Perl. It was originally developed for GNOME, but can now be used in a variety of ways. LibXML code portability is good because it is based on a standard ANSI C library and employs an MIT license.

#yum install-y libxml2-devel If error, install this package before attempting to install

Yum-y Install python-devel must have

cd/lamp/libxml2-2.9.1
./configure--prefix=/usr/local/libxml2/
Make
Make install

# Install Libmcrypt
Libmcrypt is an extended library of cryptographic 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
* Need to call gcc-c++ compiler, not installed will error

# Install Libltdl, also in the Libmcrypt source directory, non-new software
Cd/lamp/libmcrypt-2.5.8/libltdl
./configure--enable-ltdl-install
Make
Make install


# Install Mhash
Mhash is a non-reversible PHP encryption extension library based on discrete mathematical principles, which is not turned on by default. Mhash can be used to create checksum values, message summaries, message authentication codes, and key information that does not need to be saved (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. MCrypt Library supports 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
#以上为一条命令. Ld_library_path the location of the library used to specify Libmcrypt and Mhash.
#--with-libmcrypt-prefix for specifying Libmcrypt software location
Make
Make install
#mcrypt没有安装完成, this is a PHP module that needs to be installed after the PHP installation is complete

# Install Zlib
Zlib is a library of functions for data compression, developed by Jean-loup Gailly and Mark Adler, and published on May 1, 1995 in the first edition of version 0.9. Zlib uses the DEFLATE algorithm, originally written for the Libpng function library, and later widely used by many software. This library is free software and uses zlib authorization
cd/lamp/zlib-1.2.3
./configure
Make
Make install >>/root/zlib.log
* zlib specified installation directory may cause libpng installation failure, it is not specified, for uninstall convenience, it is recommended that make install execution results output to the installation log file, easy to uninstall later

# 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
#目录必须手工建立
cd/lamp/jpeg-6b
./configure--prefix=/usr/local/jpeg6/--enable-shared--enable-static
Make
Make install
* The--enable-shared and--enable-static parameters are used for building shared libraries and static libraries, respectively Libtool

# Install FreeType
The FreeType library is a completely free (open source), high quality and portable font engine that provides a unified interface to access multiple font format files, including TrueType, OpenType, Type1, CID, CFF, Windows fon/fnt, X11 PCF and so on. Supports rendering of monochrome bitmaps, anti-aliasing bitmaps. The FreeType library is a highly modular library, and although it is developed using ANSI C, it uses object-oriented thinking, so that freetype users have the flexibility to crop it.
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/.
#如果报错, then:
Tar zxvf apr-1.4.6.tar.gz
Tar zxvf apr-util-1.4.1.tar.gz unzipped.
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
#解压apr和apr-util, copy and cancel the version number

Configure:error:pcre-config for Libpcre not found. PCRE is required and available from
#如果报错, 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 have been requested but can not is built due to prerequisit E Failures
#如果报错, then:
Yum Install Openssl-devel

Installing 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 in the previous configuration zlib, do not add the--with-z=/usr/local/zlib/parameter when configuring Apache

To launch the Apache test:
/usr/local/apache2/bin/apachectl start
PS aux | grep httpd
Netstat–tlun | Grep:80
* If prompted/usr/local/apache2/modules/mod_deflate.so no permission at startup, you can turn SELinux off or execute the command chcon-t texrel_shlib_t/usr/local/apache2/ Modules/mod_deflate.so, similar to such. so file can not load or do not have permissions issues, are selinux issues, using the command: "chcon-t texrel_shlib_t file name" can be resolved, MySQL and Apache may also have similar problems.
Access via browser input address: Http://Apache server address, if "It works" shows that Apache is working properly

Set the Apache system to boot when booting:
echo "/usr/local/apache2/bin/apachectl start" >>/etc/rc.d/rc.local

# Install Ncurses
Ncurses provides a library of character terminal processing, including panels and menus. It provides a set of control cursors, create windows, change the foreground background color, and handle the function of the mouse operation. Allows the user to write applications under the character terminal, bypassing those annoying underlying mechanisms. In short, he is a library of functions that enables the application to directly control the display of the terminal screen.
1.
Yum-y Install Ncurses-devel
Note: If the error, the package can not be found, is * wildcard characters are not recognized, the file name with double quotation marks "ncurses*"
2. Source code Compilation:
cd/lamp/ncurses-5.9
./configure--with-shared--without-debug--without-ada--enable-overwrite
Make
Make install
* ERROR when compiling mysql without installing ncurses
* The--without-ada parameter is not compiled for the ADA binding, because access to the CHROOT environment can not use the ADA;--enable-overwrite parameter for defining the head file is installed under/tools/include instead of/tools/include /ncurses Directory
*--with-shared Generating a shared library

#安装cmake和bison
MySQL after 5.5, no longer use the./configure tool to compile the installation. Instead, use the CMake tool instead of the./configure tool. The specific usage of CMake reference document CMake description.
Bison is a free software for automatic generation of parser programs that can be used for all common operating systems
Yum-y Install CMake
Yum-y Install Bison

# install MySQL
Groupadd MySQL
useradd-g MySQL MySQL
* Add user group MySQL, set MySQL user default group to MySQL user group

cd/lamp/mysql-5.5.23
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 Mounting Position
-dmysql_unix_addr=/tmp/mysql.sock Specify socket (socket) file location
-dextra_charsets=all Extended character support
-ddefault_charset=utf8 Default Character Set
-ddefault_collation=utf8_general_ci Default character Proofing
-dwith_myisam_storage_engine=1 Installing the MYISAM storage engine
-dwith_innobase_storage_engine=1 Installing the InnoDB storage engine
-dwith_memory_storage_engine=1 Installing the Memory storage engine
-dwith_readline=1 Support READLINE Library
-denabled_local_infile=1 enable loading of local data
-dmysql_user=mysql specifying MySQL running user
-dmysql_tcp_port=3306 specifying the MySQL port


Make
Make install

Make clean
RM CMakeCache.txt
#如果报错, clear the cache, use the command above

cd/usr/local/mysql/
Chown-r MySQL.
Chgrp-r MySQL.
#修改mysql目录权限
/usr/local/mysql/scripts/mysql_install_db--user=mysql
#创建数据库授权表, initialize the database
Chown-r Root.
Chown-r MySQL Data
#修改mysql目录权限

CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
#复制mysql配置文件

Two authorizations:
/usr/local/mysql/scripts/mysql_install_db--user=mysql

Start the MySQL service:
1. Use and start the MySQL
/usr/local/mysql/bin/mysqld_safe--user=mysql & using the original source code;
2. Reboot will also take effect:
vi/etc/rc.local
/usr/local/mysql/bin/mysqld_safe--user=mysql &
3. Set MySQL password
/usr/local/mys Ql/bin/mysqladmin-uroot Password 123
Empty history command history-c
* Give MySQL user root password 123
* 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# to see if the character set is changed to UTF8
* Use set to change password after entering MySQL
mysql> exit
* Login to MySQL client console settings specify root password

# Install PHP
before compiling to make sure the system already has Libtool and Libtool-ltdl packages installed:
yum-y Install "libtool*"
yum-y Install "Libtool-ltd l* "

cd/lamp/php-5.6.15
./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-jpeg-dir=/usr/local/jpeg6/--with-png-dir=/usr/local/libpng/--with-freetype-dir=/usr/local/freetype/-- WITH-GD--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--without-pear


? If the installation directory is not specified in the previous configuration of zlib, do not add the--with-zlib-dir=/usr/local/zlib/parameter
option when you configure PHP:
--with-config-file-path=/usr /local/php/etc/Specify the configuration file directory
--with-apxs2=/usr/local/apache2/bin/apxs specify Apache dynamic module location
--with-mysql=/usr/local/m ysql/Specify the MySQL location
--with-libxml-dir=/usr/local/libxml2/specify libxml location
--with-jpeg-dir=/usr/local/jpeg6/Specify the JPEG bit      
--with-png-dir=/usr/local/libpng/Specify libpng location
--with-freetype-dir=/usr/local/freetype/Specify FreeType location
--with-mcrypt=/usr/local/libmcrypt/Specify the libmcrypt location
--with-mysqli=/usr/local/mysql/bin/mysql_config Specify the mysqli location br>--with-gd enable GD library
--enable-soap Support SOAP Service
--enable-mbstring=all support multibyte, string
--enable-sockets Support Socket
--with-pdo-mysql=/usr/local/mysql enable MySQL for PDO module support
--without-pear do not install pear (Installation pear requires Internet connection. Pear is a php extension and application Library)
make
make install

Generate PHP.ini
Cp/lamp/php-5.6.15/php.ini-production/usr/local/php/etc/php.ini
# mkdir/usr/local/php/etc/

Test the connectivity between Apache and PHP to see if Apache can parse PHP files
Vi/usr/local/apache2/etc/httpd.conf
AddType application/x-httpd-php. php. phtml
AddType Application/x-httpd-php-source. Phps
(Note case)
*. phtml syntax highlighting for the. Phps as a php source file
Restart Apache service:/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start

* Apache cannot start, prompt cannot restore segment prot after reloc:permission denied error, for selinux problem, can turn selinux off or execute command chcon-t texrel_ Shlib_t/usr/local/apache2/modules/libphp5.so
Test: vi/usr/local/apache2/htdocs/test.php
<?php
Phpinfo ();
?>
Access via browser input address: Http://Apache server address/test.php
RPM Package installed Web page default directory/var/www/html/
* Sometimes the first browser test will fail, close the browser restart and try again, non-compile error


Adding environment variables
Whereis PHP
Echo $PATH
#/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Export Path=/usr/local/php/bin: $PATH
Echo $PATH
#/usr/local/php/bin:/usr/local/php/bin:/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin :/usr/bin:/root/bin
#php-V
PHP 5.6.15 (CLI) (Built:nov 3 2015 03:04:34)
Copyright (c) 1997-2015 the PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
#vim/etc/profile
Add Export path= "/usr/local/php/bin: $PATH" on the last line

#source/etc/profile

# Install OpenSSL
OpenSSL is a strong Secure Sockets Layer cipher library that includes key cryptographic algorithms, common key and certificate encapsulation management functions, and SSL protocols, and provides a rich set of applications for testing or other purposes.

Yum-y Install Openssl-devel? Must be installed
Cd/lamp/php-5.6.15/ext/openssl
MV CONFIG0.M4 CONFIG.M4 Otherwise error: Could not find CONFIG.M4
/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 memory object caching system that can be used to store data in a variety of formats, including images, videos, files, and database retrieval results, by maintaining a unified, huge hash table in memory. The simple thing is to call the data into memory and then read it from memory, which greatly improves the reading speed.

Yum-y Install Zlib-devel
CD memcache-3.0.8
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make&&make Install

#编译安装mcrypt
cd/lamp/php-5.6.15/ext/mcrypt/
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config--with-mcrypt=/usr/local/libmcrypt/

Make
Make install
#php安装完成后, install the MCrypt module with these commands


Modify/usr/local/php/etc/php.ini
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20131226/"
#打开注释, and modify
Extension= "memcache.so";
Extension= "openssl.so";
Extension= "mcrypt.so";
#添加
#重启apache, these three modules can be found in the Phpinfo


#安装memcache源代码
First install the dependency package libevent
Yum-y Install "libevent*"
#在CentOS 6.3 On the second disc, please change the disc
Umount/mnt/cdrom
#放入CentOS 6.3 Second Disc
#mount/dev/sr0/mnt/cdrom

cd/lamp/memcached-1.4.17
./configure--prefix=/usr/local/memcache
Make && make install

Useradd memcache
#添加memcache用户, this user does not have to log on and does not set a password
/usr/local/memcache/bin/memcached-umemcache &
Netstat-an | grep:11211
Write from Startup:
Vi/etc/rc.d/rc.local
/usr/local/memcache/bin/memcached-umemcache &

# Install phpMyAdmin
Cp-r 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
VI config.inc.php
$cfg [' Servers '] [$i] [' auth_type '] = ' cookie ';
$cfg [' Servers '] [$i] [' auth_type '] = ' http ';
* Set Auth_type to HTTP, which is set to HTTP authentication mode
Access via browser input address: Http://Apache server address/phpmyadmin/index.php
Username root, password is the root password specified when MySQL is set 123 (Lampbrother)

Most errors during installation are input errors, which can be viewed through the history command.

GRANT all privileges on * * to ' root ' @ '% ' identified by ' 123 ' with GRANT OPTION;
SQL statements, not Linux commands

Linux (vii) LAMP environment construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.