search
HomeBackend DevelopmentPHP TutorialLamp 安装(CentOS6.6, php-5.4.39, httpd-2.4.12, mysql-5.6.24)

软件版本:

pcre-8.36.tar.gz
apr-1.5.1.tar.gz
apr-util-1.5.4.tar.gz
httpd-2.4.12.tar.bz2

mysql-5.6.24.tar.gz

libxml2-2.7.8.tar.gz
libpng-1.5.12.tar.gz
freetype-2.4.10.tar.gz
jpegsrc.v7.tar.gz
gd-2.0.35.tar.gz
php-5.4.39.tar.gz

 

百度云下载地址:http://pan.baidu.com/s/1dDGT9KH

步骤概要:

1、apache

2、mysql

3、php

4、验证

 

备注

所有操作(未特殊说明)都是以:/usr/local/src 为操作目录, 且所有软件包均在此目录下。

 

具体步骤:

安装apache

软件包依赖:pcre, apr, apr-util

1、prce 安装(安装目录,以将来安装httpd 的目录(/usr/local/services/httpd-2.4.12/)为基准,并且安装到plugins目录下,方便将来同型号机器移植

tar zxf pcre-8.36.tar.gzcd pcre-8.36 ./configure --prefix=/usr/local/services/httpd-2.4.12/plugins/pcre-8.36 make make install

 

2、apr, apr-util 在apache的安装文档中有具体操作说明,如下

tar zxf apr-1.5.1.tar.gz -C ./httpd-2.4.12/srclib/tar zxf apr-util-1.5.4.tar.gz -C ./httpd-2.4.12/srclib/cd httpd-2.4.12/srclib/ln -s apr-util-1.5.4/ apr-util ln -s apr-1.5.1 apr

3、安装apache

tar zxf httpd-2.4.12.tar.gzcd httpd-2.4.12 ./configure \ --prefix=/usr/local/services/httpd-2.4.12 \ --with-pcre=/usr/local/services/httpd-2.4.12/plugins/pcre-8.36 \ --with-included-apr \ --enable-rewrite=shared \ --enable-somakemake install

 

安装mysql

准备条件:cmake, ncurses-devel, bison, 如果未安装直接yum install xxx

tar zxf mysql-5.6.24.tar.gzcd mysql-5.6.24 cmake \ -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/services/mysql-5.6.24 \ -DMYSQL_DATADIR:PATH=/data/mysql \ -DEXTRA_CHARSETS=all \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DMYSQL_USER=mysql \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_SSL=yes make make install #添加软连接 ln -s /usr/local/services/mysql-5.6.24/ mysql #添加PATH echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile #修改目录权限 mkdir -p /data/mysql chown -R mysql:mysql /usr/local/mysql chown -R mysql:mysql /data/mysql #拷贝配置文件 cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf # 添加用户 groupadd mysql useradd -g mysql mysql #设置my.conf 在[mysqld]中设置 datadir=/data/mysql #初始化 /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql #设置mysql服务 cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld chkconfig --add mysqld service mysql start #空密码登陆mysql mysql #mysql 设置权限,同一个用户在不同机器上的密码可能不同。 grant all privileges on *.* to root@'localhost' identified by '123456'; grant all privileges on *.* to root@'%' identified by '123456'; # root密码登陆 mysql -uroot -p123456

 

注意:

安装完成后首次登陆,报错 Segmentation fault
这是一个bug: https://bugs.launchpad.net/percona-server/+bug/1201123
解决:
1、源码包里,编辑文件 cmd-line-utils/libedit/terminal.c, 找到代码段(869行) char buf[TC_BUFSIZE]; 将其注释,找到下面的变量(879行) area = buf; ,更改为 area = NULL; 
2、重新编译即可

安装php

分为3步

1、libxml2

2、gd2

3、php

 

安装libxml2

tar zxf libxml2-2.7.8.tar.gzcd libxml2-2.7.8 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/libxml2-2.7.8

 

安装gd

包括:libpng , freetype,  jpeg, gd

安装libpng

tar zxf libpng-1.5.12.tar.gzcd libpng-1.5.12 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/libpng-1.5.12

安装freetype

tar zxf freetype-2.4.10.tar.gz cd freetype-2.4.10 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/freetype-2.4.10

 

安装jpeg

tar zxf jpegsrc.v7.tar.gz cd jpeg-7 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/jpeg-7

 

安装gd

tar zxf gd-2.0.35.tar.gzcd gd-2.0.35 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/gd-2.0.35 \ --with-freetype=/usr/local/services/php-5.4.39/plugins/freetype-2.4.10 \ --with-png=/usr/local/services/php-5.4.39/plugins/libpng-1.5.12 \ --with-jpeg=/usr/local/services/php-5.4.39/plugins/jpeg-7

 

安装php

./configure \--prefix=/usr/local/services/php-5.4.39 \ --with-mysql=/usr/local/services/mysql-5.6.24 \ --with-mysqli=/usr/local/services/mysql-5.6.24/bin/mysql_config \ --with-apxs2=/usr/local/services/httpd-2.4.12/bin/apxs \ --with-libxml-dir=/usr/local/services/php-5.4.39/plugins/libxml2-2.7.8 \ --with-gd=/usr/local/services/php-5.4.39/plugins/gd-2.0.35 \ --with-freetype-dir=/usr/local/services/php-5.4.39/plugins/freetype-2.4.10 \ --with-png-dir=/usr/local/services/php-5.4.39/plugins/libpng-1.5.12 \ --with-jpeg-dir=/usr/local/services/php-5.4.39/plugins/jpeg-7 \ --enable-mbstring \ --enable-maintainer-zts \ --enable-sockets \ --enable-pcntl \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-soap \ --enable-shmop \ --enable-bcmath \ --enable-zip \ --enable-calendar \ --enable-ctype \ --enable-dom \ --enable-filter \ --enable-gd-native-ttf \ --enable-hash \ --enable-json \ --enable-posix \ --enable-shared \ --enable-simplexml \ --enable-static \ --enable-tokenizer \ --enable-xml \ --enable-xmlwriter \ --enable-pdo \ --enable-inline-optimization \ --enable-mysqlnd \ --enable-exif \ --enable-sigchild \ --enable-fpmmakemake install

 

编译遇到错误:

In file included from /kk/php-5.4.0/ext/gd/gd.c:103:/kk/php-5.4.0/ext/gd/gd_ctx.c: In function ‘_php_image_stream_putc’:

解决(google后, bug: https://bugs.php.net/bug.php?id=55224):

vim /usr/local/services/php-5.4.39/plugins/gd-2.0.35/include/gd_io.h中(14行) typedef struct gdIOCtx  结构体中添加:void (*data); 修改后如下: typedef struct gdIOCtx { int (*getC) (struct gdIOCtx *); int (*getBuf) (struct gdIOCtx *, void *, int); void (*putC) (struct gdIOCtx *, int); int (*putBuf) (struct gdIOCtx *, const void *, int); /* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */ int (*seek) (struct gdIOCtx *, const int); long (*tell) (struct gdIOCtx *); void (*gd_free) (struct gdIOCtx *); void (*data); }

重新编译,编译成功

配置与测试

1、创建软连接与添加PATH

ln -s /usr/local/services/php-5.4.39 phpln -s /usr/local/services/httpd-2.4.12 apache ln -s /usr/local/services/mysql-5.6.24 mysql echo "PATH=$PATH:/usr/local/php/bin:/usr/local/mysql/bin" >> /etc/profile source profile

 

2、设置php.ini

cp php.ini-development /usr/local/php/lib/php.ini

 

3、配置apache httpd.conf 支持php文件解析

echo "AddType application/x-httpd-php .php" >> /usr/local/apache/conf/httpd.conf

4、构建文件测试

vim /usr/local/apache/htdocs/phpinfo.php<?php phpinfo();

5、重启apache

/usr/local/apache/bin/apachectl restart

6、访问验证

浏览器访问: http://127.0.0.1/phpinfo.php

显示如下:

 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software