Home Database Mysql Tutorial MySQL+PHP5+Apache安装手记(Linux版本)

MySQL+PHP5+Apache安装手记(Linux版本)

Jun 07, 2016 pm 04:14 PM
linux Install Notes

以下的文章主要介绍的是在linux操作系统之下对Mysql+php5+apache安装手记的具体描述,我前两天在相关网站看见Mysql+php5+apache安装手记的资料,觉得挺好,于是就拿出来供大家分享。 下载官方推荐的稳定版本httpd-2.2.3.tar.gz, 安装apache2 #./configure p

以下的文章主要介绍的是在linux操作系统之下对Mysql+php5+apache安装手记的具体描述,我前两天在相关网站看见Mysql+php5+apache安装手记的资料,觉得挺好,于是就拿出来供大家分享。

下载官方推荐的稳定版本httpd-2.2.3.tar.gz,

安装apache2

<ol class="dp-xml">
<li class="alt"><span><span>#./configure –</span><span class="attribute">prefix</span><span>=/usr/local/apache2 –</span><span class="attribute">enable-module</span><span>=</span><span class="attribute-value">alias</span><span> –</span><span class="attribute">enable-module</span><span>=</span><span class="attribute-value">most</span><span> \  </span></span></li>
<li>
<span>–</span><span class="attribute">enable-module</span><span>=</span><span class="attribute-value">vhost_alias</span><span> –</span><span class="attribute">enable-shared</span><span>=</span><span class="attribute-value">vhost_alias</span><span> –</span><span class="attribute">enable-module</span><span>=</span><span class="attribute-value">so</span><span> –</span><span class="attribute">enable-shared</span><span>=</span><span class="attribute-value">max</span><span> </span>
</li>
<li class="alt"><span># make;make install </span></li>
</ol>
Copy after login

下载目前最新稳定版本mysql-standard-5.0.27-linux-i686-glibc23.tar.gz

无需安装,解压后移至/usr/local/mysql.

# groupadd mysql #建立mysql组

# useradd mysql -g mysql #建立mysql用户并且加入到mysql组中

# cd /usr/local/mysql

然后设置权限

<ol class="dp-xml">
<li class="alt"><span><span># chown -R root . #设定root能访问/usr/local/mysql  </span></span></li>
<li><span># chown -R mysql data #设定mysql用户能访问/usr/local/mysql/data ,里面存的是mysql的数据库文件  </span></li>
<li class="alt"><span># chown -R mysql data/. #设定mysql用户能访问/usr/local/mysql/data下的所有文件  </span></li>
<li><span># chown -R mysql data/mysql/. #设定mysql用户能访问/usr/local/mysql/data/mysql下的所有文件  </span></li>
<li class="alt"><span># chgrp -R mysql . #设定mysql组能够访问/usr/local/mysql </span></li>
</ol>
Copy after login

运行mysql:

<ol class="dp-xml"><li class="alt"><span><span># /usr/local/mysql/bin/mysqld_safe –</span><span class="attribute">user</span><span>=</span><span class="attribute-value">mysql</span><span> & </span></span></li></ol>
Copy after login

修改root密码,默认为空:

<ol class="dp-xml"><li class="alt"><span><span>/usr/local/mysql/bin/mysqladmin -u root password ‘newpassword’ </span></span></li></ol>
Copy after login

MYSQL+php5+apache安装完成

下载最新稳定版本php-5.1.6.tar.gz,

1. 安装zlib (安装libpng和gd前需要先安装zlib),

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf zlib-1.2.3.tar.gz  </span></span></li>
<li><span># cd zlib-1.2.3  </span></li>
<li class="alt"><span># ./configure  </span></li>
<li><span># make;make install </span></li>
</ol>
Copy after login

2. 安装libpng,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf libpng-1.2.12.tar.gz  </span></span></li>
<li><span># cd libpng-1.2.12  </span></li>
<li class="alt"><span># ./configure  </span></li>
<li><span># make;make install </span></li>
</ol>
Copy after login

3. 安装freetype,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf freetype-2.2.1.tar.gz  </span></span></li>
<li><span># cd freetype-2.1.10  </span></li>
<li class="alt">
<span># ./configure –</span><span class="attribute">prefix</span><span>=/usr/local/freetype  </span>
</li>
<li><span># make;make install </span></li>
</ol>
Copy after login

4. 安装jpeg,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf jpegsrc.v6b.tar.gz  </span></span></li>
<li><span># cd jpeg-6b  </span></li>
<li class="alt"><span># mkdir /usr/local/jpeg  </span></li>
<li><span># mkdir /usr/local/jpeg/bin  </span></li>
<li class="alt"><span># mkdir /usr/local/jpeg/lib  </span></li>
<li><span># mkdir /usr/local/jpeg/include  </span></li>
<li class="alt"><span># mkdir /usr/local/jpeg/man  </span></li>
<li><span># mkdir /usr/local/jpeg/man/man1  </span></li>
<li class="alt">
<span># ./configure –</span><span class="attribute">prefix</span><span>=/usr/local/jpeg –enable-shared –enable-static  </span>
</li>
<li><span># make;make install </span></li>
</ol>
Copy after login

5. 安装gd,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf gd-2.0.33.tar.gz  </span></span></li>
<li><span># cd gd-2.0.33  </span></li>
<li class="alt">
<span># ./configure –</span><span class="attribute">prefix</span><span>=/usr/local/gd –</span><span class="attribute">with-jpeg</span><span>=/usr/local/jpeg –</span><span class="attribute">with-freetype</span><span>=/usr/local/freetype –with-png –with-zlib </span>
</li>
</ol>
Copy after login

Mysql+php5+apache编译过程中会看到如下信息

** Configuration summary for gd 2.0.33:

<ol class="dp-xml">
<li class="alt"><span><span>Support for PNG library: yes  </span></span></li>
<li><span>Support for JPEG library: yes  </span></li>
<li class="alt"><span>Support for Freetype 2.x library: yes  </span></li>
<li><span>Support for Fontconfig library: no  </span></li>
<li class="alt"><span>Support for Xpm library: no  </span></li>
<li><span>Support for pthreads: yes </span></li>
</ol>
Copy after login

可以看到png 、 jpeg 、 freetype都已经安装上了

<ol class="dp-xml">
<li class="alt"><span><span># make  </span></span></li>
<li><span># make install  </span></li>
</ol>
Copy after login

6. 正式安装php

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf php-5.1.6.tar.gz  </span></span></li>
<li><span># cd php-5.1.6  </span></li>
<li class="alt">
<span># ./configure –</span><span class="attribute">prefix</span><span>=/usr/local/php5 –</span><span class="attribute">with-apxs2</span><span>=/usr/local/apache2/bin/apxs –</span><span class="attribute">with-mysql</span><span>=<br>/usr/local/mysql –with-gd –with-zlib –with-png –with-jpeg –with-freetype <br>–enable-sockets –with-iconv –enable-mbstring –enable-track-vars –enable-force-cgi-redirect –</span><span class="attribute">with-config-file-path</span><span>=/usr/local/php5/etc </span>
</li>
</ol>
Copy after login

7.整合php和apache

<ol class="dp-xml">
<li class="alt"><span><span>cp php.ini-dist /usr/local/php5/etc/php.ini  </span></span></li>
<li><span>vi /usr/local/php5/etc/php.ini </span></li>
</ol>
Copy after login

将extension=php_mysql.dll前面的#去掉

8. 安装ZendOptimizer,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz  </span></span></li>
<li><span># cd ZendOptimizer-3.0.1-linux-glibc21-i386  </span></li>
<li class="alt"><span># ./install.sh </span></li>
</ol>
Copy after login

安装操作: [ok] -> [EXIT] -> [YES] -> [/httpd/zend] -> [/httpd/apache/conf] -> [yes] -> [OK] -> [OK] -> [NO]

遇到的一些错误解决:

1.php5在configure时提示:configure: error: mysql configure failed.,只用–with-mysql参数提示:Cannot find MySQL header files under yes,去掉–with-mysql参数可以安装,php5将无法连接mysql+php5+apache,页面提示为:Fatal error: Call to undefined function mysql_connect()。

查阅了一下,发现是mysql5对应的版本不对导致的,换个版本就可以了。
我用mysql-standard-5.0.27-linux-i686.tar.gz时会提示,换了mysql-standard-5.0.27-linux-i686-glibc23.tar.gz后就正常了。

2.重装mysql后启动出错,提示:

<ol class="dp-xml">
<li class="alt"><span><span>Starting mysqld daemon with databases from /usr/local/mysql/data  </span></span></li>
<li><span>STOPPING server from pid file /usr/local/mysql/data/xmcncn.pid  </span></li>
<li class="alt"><span>061103 15:25:32 mysqld ended </span></li>
</ol>
Copy after login

请教高手gump,解决方法:

<ol class="dp-xml">
<li class="alt"><span><span>touch /tmp/mysql.sock  </span></span></li>
<li><span>killall -9 mysqld  </span></li>
<li class="alt">
<span>/usr/local/mysql/bin/mysqld_safe </span><span class="attribute">-user</span><span>=</span><span class="attribute-value">mysql</span><span> & </span>
</li>
</ol>
Copy after login

成功启动

PS:偶是新手,当初找齐这些软件都化了一整天时间,特别是几个小软件比较难找,现在全部列出来了。测试装的时候也遇到了不少问题,在gump同志的帮助下解决了不少。我站上本来转载了好几篇安装的文章,有的版本较旧,有的不太全面,所以把这次安装过程写出来,以后安装也就方便了:)希望也对一些新手有帮助。


 


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

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

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)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

See all articles