首页 后端开发 php教程 Linux下PHP开发环境搭建-php,mysql,apache

Linux下PHP开发环境搭建-php,mysql,apache

Jun 23, 2016 pm 02:29 PM
apache mysql

原文url: http://blog.sina.com.cn/s/blog_4b029ef301007xky.html

软件安装列表

zlib.

mysql

php

http

libpng

freetype

jpegsrc

libxml

我都采用源代码安装,因为这样比较灵活,能自己指定安装目录并配置参数,或者进行特性的选取与优化。

说明:所有的包都安装在/data目录下。 

(1):
  安装zlib
  tar zxvf zlib-1.2.3.tar.gz
  cd zlib-1.2.3
  ./configure --prefix=/data/zlib
   make
   make install
   然后在/etc/ld.so.conf中添加
    /data/zlib/lib
  保存,执行ldconfig -v
(2)mysql installing.
 #groupadd mysql
 #useradd -g mysql mysql
 # vi /home/mysql/.bash_profile
 添加
 export PATH=$PATH:/data/mysql/bin
保存后,进入安装包所在目录,先安装Mysql
解压缩:
     tar -zxvf mysql-5.0.45.tar.gz
     cd mysql-5.0.45

接着要进行configure配置,在以前我只是制定了prefix没有设置字体编码,结果PHP后来不支持汉字编码,只好重新安装
才发现这个问题要注意,而且我们已经安装了zlib,就可以给mysql来指明zlib的位置
[root@cme_box mysql-5.0.45]# ./configure --prefix=/data/mysql --with-zlib-dir=/data/zlib/  --with-charset=utf8  --with-extra-charsets=gbk,gb2312,utf8
make
make install
同样,在/etc/ld.so.conf中添加一行
/data/mysql/lib/mysql
保存,执行ldconfig -v
#./scripts/mysql_install_db
         #chown -R root /data/mysql
         #chown -R mysql /data/mysql/var
         #chgrp -R mysql /data/mysql
         # cp support-files/my-medium.cnf /etc/my.cnf
#/data/mysql/bin/mysqld_safe &
下来再init.d中设置mysql的自启动。
# cp support-files/mysql.server /etc/init.d/mysql
 cd /etc/rc3.d
            ln -s ../init.d/mysql S85mysql
            ln -s ../init.d/mysql K85mysql
            cd ../rc5.d/
            ln -s ../init.d/mysql S85mysql
            ln -s ../init.d/mysql K85mysql
            cd ../init.d
            chmod 755 mysql
然后reboot查看mysql是否启动。
(3)安装apache
 tar -zxvf httpd-2.2.6.tar.gz
cd httpd-2.2.6
./configure --prefix=/data/httpd/ --enable-so --enable-cgi --with-z=/data/zlib
make
make install
 cp /data/httpd/bin/apachectl /etc/init.d/httpd
cp: overwrite `/etc/init.d/httpd'? y
cd /etc/rc3.d
rm -fr K15httpd
cd /etc/rc5.d
rm -fr K15httpd
cd /etc/rc3.d
ln -s ../init.d/httpd  K85httpd
ln -s ../init.d/httpd  S85httpd
cd /etc/rc5.d
ln -s ../init.d/httpd  K85httpd
ln -s ../init.d/httpd  S85httpd
chmod 755 /etc/init.d/httpd
(4)安装GD库
 首先,我们要安装各个图形库的支持,包括libpng, libjpeg,ttf等。
  1)libpng
    tar -zxvf libpng-1.2.23.tar.gz
     ./configure --prefix=/data/libpng
     make
      make install
     然后将libpng的路径(/data/libpng/lib)加到/etc/ld.so.conf下,执行ldconfig -v
     能看到
         /data/libpng/lib:
        libpng.so.3 -> libpng.so.3.23.0
        libpng12.so.0 -> libpng12.so.0.23.0
       这一项。说明安装成功。
  2)freetype
     tar -zxvf freetype-2.1.10.tar.gz
     cd freetype-2.1.10
     ./configure --prefix=/data/freetype
      make
      make install
      then add the path of freetype(/data/freetype/lib) to /etc/ld.so.conf and run command "ldconfig -v",we can get
       the output
        /data/freetype/lib:
        libfreetype.so.6 -> libfreetype.so.6.3.8
  3)jpeg
      tar -zxvf jpegsrc.v6b.tar.gz
      ./configure --prefix=/data/jpeg --enable-shared
      make
     make install
    提示:/usr/bin/install: cannot create regular file `/data/jpeg/include/jconfig.h': No such file or directory
   nnd,在CU上查到了,原来是安装程序没有权限在/data下自己创建目录,需要手动创建
        当我创建include目录后,提示lib目录不存在,创建lib目录后,又提示man/man1目录不存在,那就挨个创建吧。
         cd /data/jpeg
         mkdir include lib man bin
         mkdir man/man1
   然后make install就OK了。
   然后在/etc/ld.so.conf中添加一行 /data/jpeg/lib,执行命令 ldconfig -v,可以看到
    /data/jpeg/lib:
        libjpeg.so.62 -> libjpeg.so.62.0.0
4)安装fontconfig

tar -zxvf fontconfig-2.5.0.tar.gz

 cd fontconfig-2.5.0
./configure --prefix=/data/fontconfig --with-freetype-config=/data/freetype/bin/freetype-config

make

make install

cd /data/fontconfig/lib

pwd >> /etc/ld.so.conf

ldconfig -v | grep fontconfig

安装GD
   tar -zxvf gd-2.0.33.tar.gz
   ./configure --prefix=/data/gd --with-png=/data/libpng --with-freetype=/data/freetype --with-jpeg=/data/jpeg --with-fontconfig=/data/fontconfig
  

(在以前没有加fontconfig的时候,会报这个错,但是2008-12-15日加了fontconfig后,却没有报错,一路make,make install很顺利,不过还是要写上,以防再遇到:make时系统提示找不到png.h,手动修改makefile
   在CPPFLAGS = 行末加上  -I/data/libpng/include
   在CFLAGS = -g -O2  行末加上
    -DHAVE_JPEG -DHAVE_LIBTTF -DHAVE_PNG
    修改为
   CFLAGS = -g -O2  -DHAVE_JPEG -DHAVE_LIBTTF -DHAVE_PNG
  )

然后
   make
   make install
(4)安装libxml
    tar -zxvf libxml2-2.6.11.tar.gz
    ./configure --prefix=/data/xml --with-zlib=/data/zlib
    make
   make install
   然后把xml的库路径【 /data/xml/lib/】添加到/etc/ld.so.conf文件中保存后执行ldconfig -v
   看到
     /data/xml/lib:
        libxml2.so.2 -> libxml2.so.2.6.11
添加gd的库路径[/data/gd/lib]到etc/ld.so.conf文件,执行ldconfig -v
(5)安装php
     tar -zxvf php-5.2.4.tar.gz
      ./configure --prefix=/data/php --with-zlib-dir=/data/zlib --with-mysql=/data/mysql --with-apxs2=/data/httpd/bin/apxs  --with-config-file-path=/data/php --with-gd --enable-sysvmsg --enable-sockets --enable-sysvshm --enable-sysvsem --enable-gd-native-ttf --with-ttf=/usr/lib  --with-jpeg-dir=/data/jpeg --with-png-dir=/data/libpng --with-iconv --with-libxml-dir=/data/xml
make
make install

cp php.ini-dist /data/php/php.ini


(6)在http.conf中设置php支持。
vi /data/httpd/conf/http.conf

# Example:
# LoadModule foo_module modules/mod_foo.so
LoadModule php5_module        modules/libphp5.so
下添加一行
AddType application/x-httpd-php .php
并将

    DirectoryIndex index.html

修改为

    DirectoryIndex index.php index.html

设置默认主页为index.php
然后在/data/php/php.ini中添加一行
default_charset = "gb2312"
保存
service httpd restart
进行测试
在 /data/httpd/htdocs/下建立index.php
写入内容为 保存
打开页面输入url地址
http://192.168.x.x/
就能看到phpinfo的输出了。
如果想修改http的默认根目录,或者说你不想把自己的文件放在/data/httpd/htdoc目录下
可以修改httpd.conf中的
DocumentRoot "/data/httpd/htdoc"为
DocumentRoot   "/cme/web"


然后还要给新的目录加上能执行的权限
chmod +x /cme
chmod +x /cme/web
重启服务 service httpd restart
就OK了。

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

apache中cgi目录怎么设置 apache中cgi目录怎么设置 Apr 13, 2025 pm 01:18 PM

要在 Apache 中设置 CGI 目录,需要执行以下步骤:创建 CGI 目录,如 "cgi-bin",并授予 Apache 写入权限。在 Apache 配置文件中添加 "ScriptAlias" 指令块,将 CGI 目录映射到 "/cgi-bin" URL。重启 Apache。

apache怎么启动 apache怎么启动 Apr 13, 2025 pm 01:06 PM

启动 Apache 的步骤如下:安装 Apache(命令:sudo apt-get install apache2 或从官网下载)启动 Apache(Linux:sudo systemctl start apache2;Windows:右键“Apache2.4”服务并选择“启动”)检查是否已启动(Linux:sudo systemctl status apache2;Windows:查看服务管理器中“Apache2.4”服务的状态)启用开机自动启动(可选,Linux:sudo systemctl

apache怎么删除多于的服务器名 apache怎么删除多于的服务器名 Apr 13, 2025 pm 01:09 PM

要从 Apache 中删除多余的 ServerName 指令,可以采取以下步骤:识别并删除多余的 ServerName 指令。重新启动 Apache 使更改生效。检查配置文件验证更改。测试服务器确保问题已解决。

apache怎么连接数据库 apache怎么连接数据库 Apr 13, 2025 pm 01:03 PM

Apache 连接数据库需要以下步骤:安装数据库驱动程序。配置 web.xml 文件以创建连接池。创建 JDBC 数据源,指定连接设置。从 Java 代码中使用 JDBC API 访问数据库,包括获取连接、创建语句、绑定参数、执行查询或更新以及处理结果。

怎么查看自己的apache版本 怎么查看自己的apache版本 Apr 13, 2025 pm 01:15 PM

有 3 种方法可在 Apache 服务器上查看版本:通过命令行(apachectl -v 或 apache2ctl -v)、检查服务器状态页(http://<服务器IP或域名>/server-status)或查看 Apache 配置文件(ServerVersion: Apache/<版本号>)。

apache80端口被占用怎么办 apache80端口被占用怎么办 Apr 13, 2025 pm 01:24 PM

当 Apache 80 端口被占用时,解决方法如下:找出占用该端口的进程并关闭它。检查防火墙设置以确保 Apache 未被阻止。如果以上方法无效,请重新配置 Apache 使用不同的端口。重启 Apache 服务。

怎么查看apache版本 怎么查看apache版本 Apr 13, 2025 pm 01:00 PM

如何查看 Apache 版本?启动 Apache 服务器:使用 sudo service apache2 start 启动服务器。查看版本号:使用以下方法之一查看版本:命令行:运行 apache2 -v 命令。服务器状态页面:在 Web 浏览器中访问 Apache 服务器的默认端口(通常为 80),版本信息显示在页面底部。

Debian如何提升Hadoop数据处理速度 Debian如何提升Hadoop数据处理速度 Apr 13, 2025 am 11:54 AM

本文探讨如何在Debian系统上提升Hadoop数据处理效率。优化策略涵盖硬件升级、操作系统参数调整、Hadoop配置修改以及高效算法和工具的运用。一、硬件资源强化确保所有节点硬件配置一致,尤其关注CPU、内存和网络设备性能。选择高性能硬件组件对于提升整体处理速度至关重要。二、操作系统调优文件描述符和网络连接数:修改/etc/security/limits.conf文件,增加系统允许同时打开的文件描述符和网络连接数上限。JVM参数调整:在hadoop-env.sh文件中调整

See all articles