Home php教程 php手册 在Ubuntu中使用源码编译安装Apache+MySQL+PHP+phpMyAdmin

在Ubuntu中使用源码编译安装Apache+MySQL+PHP+phpMyAdmin

Jun 06, 2016 pm 07:57 PM
ubuntu use Install Source code compile

操作系统:ubuntu12.04LTS(64位) 编译安装的步骤如下: 检查安装的编译工具 编译过程中需要C的编译器,C的编译器,make,和编译mysql最新版本时需要的cmake。 检查编译器软件是否安装的命令是: dpkg –l | grep filename 依次检查gcc,g,make,cmake是否

操作系统:ubuntu12.04LTS(64位)

编译安装的步骤如下:

检查安装的编译工具

编译过程中需要C的编译器,C++的编译器,make,和编译mysql最新版本时需要的cmake。

检查编译器软件是否安装的命令是:

dpkg –l | grep filename
Copy after login

依次检查gcc,g++,make,cmake是否安装

检查是否已经有默认安装的软件,并卸载

如果已经安装过Apache,mysql,php需要先停止服务,卸载先前的软件后再工作

卸载软件的命令

apt-get remove –purge softname
dpkg –r xxx.deb
Copy after login

编译安装libxml2

下载地址:libxml2-2.9.0.tar.gz

cd /usr/local/src
tar –zvxf libxml2-2.9.0.tar.gz
cd libxml2-2.9.0
./configure –prefix=/usr/local/libxml2
make
sudo make install
Copy after login

编译安装libmcrypt

下载地址:libmcrypt-2.5.7.tar.gz

cd /usr/local/src
tar –zvxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt
make
sudo make install
Copy after login

编译安装zlib

下载地址:zlib-1.2.8.tar.gz

cd /usr/local/src
tar –zvxf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
sudo make install
Copy after login

注意安装zlib库的时候不能指定它的安装路径,否则安装后面库的时候会找不到zlib的位置,手动指定路径也无法解决

安装libpng库

下载地址:libpng-1.6.7.tar.gz

cd /usr/local/src
tar –zvxf libpng-1.6.7.tar.gz
cd libpng-1.6.7
./configure --prefix=/usr/local/libpng
make
sudo make install
Copy after login

如果上一步的zlib库指定了特定的安装路径,在这里configure的时候会提示zlib没有安装问题,此时回到zlib的源代码执行

make clean重新编译安装

安装jpeg6

下载地址:jpegsrc.v6b.tar.gz

需要手动创建安装需要的目录,在安装时不能自动创建

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 /usr/local/src
tar –zvxf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg6 –enable-shared –enable-static
make
sudo make install
Copy after login

可能出现的错误:make: ./libtool:命令未找到(解决办法参考这篇文章:Linux 安装 jpeg-6b 出错:./libtool 命令未找到)

安装freetype

下载地址:freetype-2.4.10.tar.gz

cd /usr/local/src
tar –zvxf freetype-2.4.10.tar.gz
cd freetype-2.4.10
./configure --prefix=/usr/local/freetype
make
sudo make install
Copy after login

出错信息及解决办法参考这篇文章:Linux下编译安装freetype出错信息及解决办法以及这篇文章:编译安装 freetype 报错 make: [install] 错误 1 (忽略) 及解决办法

安装autoconf库

下载地址:autoconf-2.68.tar.gz

安装autoconf需要安装m4软件,不然configure不会通过的,而且最好默认安装,不指定prefix,否则后面安装php扩展会比较麻烦。

cd /usr/local/src
tar –zvxf autoconf-2.68.tar.gz
cd autoconf-2.68
./configure
make
sudo make install
Copy after login

安装gd库

下载地址:gd-2.0.35.tar.gz

cd /usr/local/src
tar –zvxf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
make
sudo make install
Copy after login

在安装gd库的时候会出现找不到png库的情况,这时我们需要手动修改gd_png.c文件,找到

#include "png.h"

修改为真正的png库位置

安装Apache服务器

下载地址:httpd-2.2.26.tar.gz

cd /usr/local/src
tar –zvxf httpd-2.2.26.tar.gz
cd httpd-2.2.26
./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --with-include-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support
make
sudo make install
Copy after login

安装Apache会出现依赖库的问题,需要提前安装apr,apr-util,pcre 安装方法就是正常的编译安装(可参考这篇文章:Ubuntu下使用源代码编译安装apache2.2.26)

启用apache服务

cp /usr/local/apache2/bin/apachectl /sbin/
apachectl start
netstat -tnl | grep 80
vim /etc/rc.loacl
Copy after login

安装mysql数据库

下载地址:mysql-5.5.25a.tar.gz

cd /usr/local/src
tar –zvxf mysql-5.5.25a.tar.gz
cd mysql-5.5.25a
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=bundled -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_DEBUG=0
make
sudo make install
Copy after login

安装过程会出现的错误及解决办法参考这篇文章:Ubuntu12.04编译安装MySQL 5可能出现的错误及解决办法

创建mysql 用户

groupadd mysql
useradd -r -g mysql mysql
Copy after login

权限设置及授权表的安装

cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
Copy after login

创建配置文件

cp support-files/my-medium.cnf /etc/my.cnf
Copy after login

启动mysql服务

bin/mysql_safe --user=mysql&
netstat -tnl | grep 3306
Copy after login

配置mysql服务

cp support-files/mysql.server /etc/init.d/mysql
sudo update-rc.d mysql defaults
chkconfig --add mysql
chkconfig mysql on
Copy after login

用户账户控制

bin/mysql -uroot
mysql> DELETE mysql.user WHERE Host='localhost'AND User='';
mysql>SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123456');
Copy after login

启动报错:无法启动Couldn't find MySQL server (/usr/bin/mysqld_safe)”

sudo rm /etc/mysql/my.cnf
Copy after login

即可。

安装PHP5.3

下载地址:php-5.3.28.tar.gz

cd /usr/local/src
tar –zvxf php-5.3.28.tar.gz
cd php-5.3.28
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-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-mcrypt=/usr/local/libmcrypt --enable-soap --enable-mbstring=all --enable-sockets
make
sudo make install
Copy after login

在PHP5.4 make会出现一个问题

我们需要修改gd库目录下的include/gd_io.h

vi <gd_dir>/include/gd_io.h</gd_dir>
Copy after login

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);
}
gdIOCtx;
Copy after login

创建PHP配置文件

cp php.ini-development /usr/local/php/etc/php.ini
Copy after login

添加apache对PHP的支持

vi /etc/httpd/httpd.conf
Addtype application/x-httpd-php .php .phtml
sudo apachectl stop
sudo apachectl start
Copy after login

在Apache的web根目录下创建phpinfo.php

<?php phpinfo();
?>
Copy after login

测试环境是否安装成功

基本上就装完了。

安装配置phpMyAdmin:

下载地址:phpMyAdmin-4.1.1-all-languages.zip

unzip phpMyAdmin-4.1.1-all-languages.zip
mv phpMyAdmin-4.1.1-all-languages.zip phpmyadmin
mv phpmyadmin /var/www/(假设/var/www为web根目录)
cd /var/www/phpmyadmin
cp config.sample.inc.php config.inc.php
vi config.inc.php
Copy after login

将其中的

$cfg['Servers'][$i]['extension'] = 'mysqli';
Copy after login

修改为:

$cfg['Servers'][$i]['extension'] = 'mysql';
Copy after login

保存退出,然后在浏览器中就可以通过http://localhost/phpmyadmin来访问phpMyAdmin了。


Statement of this Website
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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Log in to Ubuntu as superuser Log in to Ubuntu as superuser Mar 20, 2024 am 10:55 AM

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su- command to log in as root. The root user is a user with unrestricted system administrative rights. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes. There are obvious differences between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do. In this guide, I'll explore the Ubuntu root user, how to log in as root, and how it differs from a normal user. Notice

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

How to download foobar2000? -How to use foobar2000 How to download foobar2000? -How to use foobar2000 Mar 18, 2024 am 10:58 AM

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

How to install Angular on Ubuntu 24.04 How to install Angular on Ubuntu 24.04 Mar 23, 2024 pm 12:20 PM

Angular.js is a freely accessible JavaScript platform for creating dynamic applications. It allows you to express various aspects of your application quickly and clearly by extending the syntax of HTML as a template language. Angular.js provides a range of tools to help you write, update and test your code. Additionally, it provides many features such as routing and form management. This guide will discuss how to install Angular on Ubuntu24. First, you need to install Node.js. Node.js is a JavaScript running environment based on the ChromeV8 engine that allows you to run JavaScript code on the server side. To be in Ub

How to install Android apps on Linux? How to install Android apps on Linux? Mar 19, 2024 am 11:15 AM

Installing Android applications on Linux has always been a concern for many users. Especially for Linux users who like to use Android applications, it is very important to master how to install Android applications on Linux systems. Although running Android applications directly on Linux is not as simple as on the Android platform, by using emulators or third-party tools, we can still happily enjoy Android applications on Linux. The following will introduce how to install Android applications on Linux systems.

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

Android TV Box gets unofficial Ubuntu 24.04 upgrade Android TV Box gets unofficial Ubuntu 24.04 upgrade Sep 05, 2024 am 06:33 AM

For many users, hacking an Android TV box sounds daunting. However, developer Murray R. Van Luyn faced the challenge of looking for suitable alternatives to the Raspberry Pi during the Broadcom chip shortage. His collaborative efforts with the Armbia

See all articles