Linux under the specified version to compile and install lamp

Source: Internet
Author: User
Tags gettext mcrypt

Description

Operating system: CentOS 6.5 64-bit

Demand:

Compile and install lamp operating environment

The software versions are as follows:

mysql:mysql-5.1.73

apache:httpd-2.2.31

php:php-5.2.17

Specific operation:

Prepare the article

First, configure the firewall, open 80 port, 3306 port

Vi/etc/sysconfig/iptables #编辑防火墙配置文件

# Firewall configuration written by System-config-firewall

# Manual Customization of this file are not recommended.

*filter

: INPUT ACCEPT [0:0]

: FORWARD ACCEPT [0:0]

: OUTPUT ACCEPT [0:0]

-A input-m state--state established,related-j ACCEPT

-A input-p icmp-j ACCEPT

-A input-i lo-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT

-A input-j REJECT--reject-with icmp-host-prohibited

-A forward-j REJECT--reject-with icmp-host-prohibited

COMMIT

: wq! #保存退出

Service iptables restart #最后重启防火墙使配置生效

Second, to close SELinux

Vi/etc/selinux/config

#SELINUX =enforcing #注释掉

#SELINUXTYPE =targeted #注释掉

selinux=disabled #增加

: wq! #保存退出

Setenforce 0 #使配置立即生效

Third, the system contract

Software source code Package storage location:/USR/LOCAL/SRC

Source Package Compilation Installation location:/usr/local/software Name

Iv. Download the Package

1. Download Apache

Http://www.apache.org/dist/httpd/httpd-2.2.31.tar.gz

2. Download MySQL

Http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73.tar.gz

3. Download PHP

Http://museum.php.net/php5/php-5.2.17.tar.gz

4. Download libmcrypt (PHP extension)

Http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

5. Download yasm (PHP extension)

Http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

6, T1lib (PHP extension)

Ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz

7. Download GD Library installation package

Https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz

8, LIBVPX (GD library required)

https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2

9, TIFF (GD library required)

Http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz

10, libpng (GD library required)

Ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.18.tar.gz

11, FreeType (GD library required)

Http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.4.tar.gz

12, JPEGSRC (GD library required)

Http://www.ijg.org/files/jpegsrc.v9a.tar.gz

13. Curl (PHP extension)

Http://curl.haxx.se/download/curl-7.44.0.tar.gz

Upload the above package to the/USR/LOCAL/SRC directory

Install the compilation tools and library files (install using the yum command)

Yum install-y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp Curl Curl-devel fontconfig Fontconfig-devel FreeType freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils ke Yutils-libs-devel krb5-devel libcom_err-devel libpng libpng* libpng-devel libjpeg* libsepol-devel libselinux-devel Libstdc++-devel libtool* libgomp libxml2 libxml2-devel libxpm* libx* libtiff libtiff* make MPFR ncurses* ntp OpenSSL nasm nasm* openssl-devel Patch pcre-devel perl php-common php-gd policycoreutils ppl telnet t1lib t1lib* wget zlib-devel

Installation article

First, install MySQL

Cd/usr/local/src

Tar zxvf mysql-5.1.73.tar.gz

CD mysql-5.1.73

./configure--prefix=/usr/local/mysql--localstatedir=/usr/local/mysql/data/--with-mysqld-ldflags=-all-static-- With-client-ldflags=-all-static--with-unix-socket-path=/tmp/mysql.sock--without-debug--with-extra-charsets=all --without-embedded-server--enable-profiling--enable-assembler--enable-thread-safe-client--enable-shared-- With-server-suffix=-community--with-plugins=innobase--with-extra-charsets=all

Make

Make install

Note: In the process of executing make install compile, if you see the following line appears on the screen, the card is there, for a long time, do not think it is a compilation error, or the server stuck, just insist, patiently wait a few minutes, will compile successfully!

MAKE[4]: Entering directory '/usr/local/src/mysql-5.1.73/mysql-test '

Groupadd MySQL #添加mysql组

useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, does not allow MySQL users to log in directly to the system

Chown-r root/usr/local/mysql/ #允许root访问

Chgrp-r mysql/usr/local/mysql/ #允许mysql组访问

cd/usr/local/mysql/ #进入mysql安装目录

CP share/mysql/my-huge.cnf/etc/my.cnf #拷贝配置文件 (Note:/etc directory with MY.CNF, directly covered by default)

CP share/mysql/mysql.server/etc/init.d/mysqld #把Mysql加入系统启动

chmod 755/etc/init.d/mysqld #执行权限

Vi/etc/profile #把mysql服务加入系统环境变量:

Add the following line at the end

Export path= $PATH:/usr/local/mysql/bin

Source/etc/profile #使配置立刻生效

The following two lines link the MYSLQ library file to the default location of the system, and you can compile software like PHP without specifying the MySQL library file address.

Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql

Ln-s/usr/local/mysql/include/mysql/usr/include/mysql

/usr/local/mysql/bin/mysql_install_db--user=mysql--datadir=/usr/local/mysql/data #生成mysql系统数据库

/usr/local/mysql/bin/mysqld_safe--user=mysql &--datadir=/usr/local/mysql/data #启动mysql

/etc/rc.d/init.d/mysqld Start #启动

Chkconfig mysqld on #加入开机启动

Mysql_secure_installation #设置Mysql密码

Press Y to enter the password 2 times as prompted

or modify the password directly/usr/local/mysql/bin/mysqladmin-u root-p password "123456" #修改密码

Service mysqld Restart #重启

To this, MySQL installation is complete!

Second, install Apache

Cd/usr/local/src

Tar zxvf httpd-2.2.31.tar.gz

CD httpd-2.2.31

./configure--prefix=/usr/local/apache--with-included-apr--enable-module=so--enable-deflate--enable-expires-- Enable-ssl--enable-headers--enable-module=rewrite--enable-static-support--enable-mods-shared=all

Make #编译

Make install #安装

/usr/local/apache/bin/apachectl-k Start #启动

vi/usr/local/apache/conf/httpd.conf #编辑配置文件

Found: #ServerName www.example.com:80

Modified to: ServerName www.osyunwei.com:80

Found: DirectoryIndex index.html

Modified to: DirectoryIndex index.html index.php

Found: Options Indexes followsymlinks

Modified to: Options followsymlinks #不显示目录结构

Find AllowOverride None

Modified to: allowoverride all #开启apache支持伪静态, modified in three places

LoadModule rewrite_module modules/mod_rewrite.so #取消前面的注释, open Apache support pseudo-static

Vi/etc/profile #添加apache服务系统环境变量, add the following line at the end

Export path= $PATH:/usr/local/apache/bin

: wq! #保存退出

CP/USR/LOCAL/APACHE/BIN/APACHECTL/ETC/RC.D/INIT.D/HTTPD #把apache加入到系统启动

VI/ETC/INIT.D/HTTPD #编辑文件, add the following two lines below the #!/bin/sh

#chkconfig: 2345 10 90

#description: activates/deactivates Apache Web Server

: wq! #保存退出

Chown daemon.daemon-r/usr/local/apache/htdocs #更改目录所有者

chmod 700/usr/local/apache/htdocs-r #更改apache网站目录权限

Chkconfig httpd on #设置开机启动

/ETC/INIT.D/HTTPD start

Service httpd Restart

System operation and maintenance www.osyunwei.com warm reminder: system operation and maintenance of original content © Copyright, reproduced please indicate the source and the original link

Third, install PHP

1, installation Yasm

Cd/usr/local/src

Tar zxvf yasm-1.3.0.tar.gz

CD yasm-1.3.0

./configure

Make

Make install

2, Installation Libmcrypt

Cd/usr/local/src

Tar zxvf libmcrypt-2.5.8.tar.gz

CD libmcrypt-2.5.8

./configure

Make

Make install

3, Installation LIBVPX

Cd/usr/local/src

Tar xvf libvpx-v1.3.0.tar.bz2

CD libvpx-v1.3.0

./configure--PREFIX=/USR/LOCAL/LIBVPX--enable-shared--ENABLE-VP9

Make

Make install

4. Installing TIFF

Cd/usr/local/src

Tar zxvf tiff-4.0.3.tar.gz

CD tiff-4.0.3

./configure--prefix=/usr/local/tiff--enable-shared

Make

Make install

5, installation Libpng

Cd/usr/local/src

Tar zxvf libpng-1.6.18.tar.gz

CD libpng-1.6.18

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

Make

Make install

6, Installation FreeType

Cd/usr/local/src

Tar zxvf freetype-2.5.4.tar.gz

CD freetype-2.5.4

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

Make #编译

Make install #安装

7. Install JPEG

Cd/usr/local/src

Tar zxvf jpegsrc.v9a.tar.gz

CD jpeg-9a

./configure--prefix=/usr/local/jpeg--enable-shared

Make #编译

Make install #安装

8, installation LIBGD

Cd/usr/local/src

Tar zxvf libgd-2.1.0.tar.gz #解压

CD libgd-2.1.0 #进入目录

./configure--PREFIX=/USR/LOCAL/LIBGD--enable-shared--with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng-- With-freetype=/usr/local/freetype--with-fontconfig=/usr/local/freetype--with-xpm=/usr/--with-tiff=/usr/local/ TIFF--with-vpx=/usr/local/libvpx #配置

Make #编译

Make install #安装

9, installation T1lib

Cd/usr/local/src

Tar zxvf t1lib-5.1.2.tar.gz

CD t1lib-5.1.2

./configure--prefix=/usr/local/t1lib--enable-shared

Make Without_doc

Make install

10. Install Curl

Cd/usr/local/src

Tar zxvf curl-7.44.0.tar.gz

CD curl-7.44.0

./configure--prefix=/usr/local/curl--with-gssapi--ENABLE-TLS-SRP--with-libmetalink

Make

Make install

11. Install PHP

Note: If the system is 64-bit, please execute the following two commands, otherwise the installation of PHP will be wrong (32-bit system does not need to do)

\cp-frp/usr/lib64/libltdl.so*/usr/lib/

\cp-frp/usr/lib64/libxpm.so*/usr/lib/

Cd/usr/local/src

TAR-ZVXF php-5.2.17.tar.gz

CD php-5.2.17

Export Ld_library_path=/usr/local/libgd/lib

./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache/bin /apxs--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/ Mysql.sock--with-pdo-mysql=/usr/local/mysql--with-gd--with-png-dir=/usr/local/libpng--with-jpeg-dir=/usr/local /jpeg--with-freetype-dir=/usr/local/freetype--with-xpm-dir=/usr/--with-vpx-dir=/usr/local/libvpx/-- With-zlib-dir=/usr/local/zlib--with-t1lib=/usr/local/t1lib--with-curl=/usr/local/curl--with-iconv-- Enable-libxml--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization-- Enable-mbregex--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets- -with-xmlrpc--enable-zip--enable-soap--without-pear--with-gettext--enable-session--with-mcrypt--enable-ctype

Make #编译

Make install #安装

CP Php.ini-production/usr/local/php/etc/php.ini #复制php配置文件到安装目录

Rm-rf/etc/php.ini #删除系统自带配置文件

Ln-s/usr/local/php/etc/php.ini/etc/php.ini #添加软链接到/etc directory

Vi/usr/local/php/etc/php.ini #编辑

Found in:; Open_basedir =

Modified to: Open_basedir =.:/ tmp/ #防止php木马跨站, Important!

Found: Disable_functions =

Modified to: Disable_functions = Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini _alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server, Escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space, POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_getegid,posix_geteuid,posix_getgid, Posix_getgrgid,posix_ Getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, Posix_getppid,posix_getpwnam, Posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid, Posix_seteuid,posix_setgid, Posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname, Posix_uname

#列出PHP可以禁用的函数, if some programs need to use this function, you can delete, cancel disable.

Found:;d Ate.timezone =

Modified to: Date.timezone = PRC

Found: expose_php = On

Modified to: expose_php = OFF #禁止显示php版本的信息

Found: Display_errors = On

Modified to: display_errors = OFF #关闭错误提示

: wq! #保存退出

Iv. configuring Apache to support PHP

Vi/usr/local/apache/conf/httpd.conf #编辑apache配置文件, in addtype application/x-gzip gz. tgz This line is added below

AddType application/x-httpd-php php (Note: PHP. php This dot is preceded by a space)

: wq! #保存退出

Service httpd restart #重启apache

Service mysqld Restart #重启mysql

V. Testing

Cd/usr/local/apache/htdocs

VI index.php #输入下面内容

<?php

Phpinfo ();

?>

: wq! #保存

In the client browser enter the server IP address, you can see the relevant configuration information!

Site program uploaded to the/usr/local/apache/htdocs directory, if there is a problem with the installation, please check the directory permissions, to ensure that the directory is the following permissions

Chown Daemon.daemon-r/usr/local/apache/htdocs

Chmod-r 700/usr/local/apache/htdocs

At this point, Linux under the specified version of the compiler installation lamp tutorial completed!

Linux under the specified version to compile and install lamp

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.