Home  >  Article  >  Backend Development  >  apache mysql php 源码编译使用方法_php实例

apache mysql php 源码编译使用方法_php实例

WBOY
WBOYOriginal
2016-06-07 17:25:28701browse

linux 版本 : ubuntu 12.04
今天完成了 php mysql 和apache 的配置
主要是源码配置,
apache 主要是 2.4.2 版本
php 主要是 5.3.11 版本
mysql 主要是 5.1.62 版本

前几天试了好几次,出现了软件的源冲突,我放了两个源在同一个source里,后修改后,安装没出现大的问题。
总的情况如下.

我完成的过程如下 :
apache 配置:
./configure --prefix=/usr/local/apache/ --with-libxml2 --enable-modules
=most --enable-mods-shared=all

看这apache 经典实例写的。
在ubuntu上加上libxml2最新的版本,然后一切ok
make
make install
然后 输入127.0.0.1 可以看见it‘s work!
mysql配置:
cd mysql
sudo ./configure –prefix=/usr/local/mysql –with-mysqld-user=mysql
–with-extra-charsets=all –enable-thread-safe-client
在./configure 配置中小心点,并且小心其中的提示
我便是在小中度过那个./configure 的,然后就是顺利的
make
make install
由于要配置文件复制到etc目录下
sudo cp /mypath/mysql /etc/my.cnf
[mysqld]# 设置默认为INNODB表,支持事务:default-storage-engine=INNODB
# 设置默认的字符集UTF-8:
character-set-server=utf8
collation-server=utf8_general_ci
default-character-set=utf8
# mysql启动用户
user=mysql
[client]
default-character-set=utf8
为了让普通的用户启动mysql 赋予mysql目录如下权限
sudo chown -R mysql:mysql /usr/local/mysql
然后,切换到mysql的用户下,发现mysql启动了
ps aux | grep mysqld
如果有 /usr/local/mysql/bin/ 。。。 说明启动了mysql,mysql配置ok


Php 配置:
最复杂的属php的配置,关键在于那个模块有点多

配置和安装的时间有点长,有时候 我还认为是死机呢?

./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql-dir=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-pdo-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-mod-charset \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-curlwrappers \
--enable-exif \
--enable-ftp \
--with-gdbm \
--with-gd=shared \
--with-ttf \
--enable-gd-native-ttf \
--with-gettext \
--with-gmp \
--enable-mbstring=all \
--enable-zend-multibyte \
--with-ming=shared \
--enable-sqlite-utf8 \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-xmlrpc \
--with-xsl \
--enable-zip \
--with-zlib \
--enable-discard-path \
--enable-force-cgi-redirect \
--enable-magic-quotes \
--enable-sigchild \
--with-ncurses \
--enable-pcntl
然后configure中报出缺少好多组件,唉。。 一个一个填上 例如 bz2 和zlib 和ncurses 三个组件添加完后
configure 立即成功了,然后呢? make ok make test 出问题。。。。。?? 无语了但是 make install
ok

就需要对php 配置了
建立 php.ini 文件。
写入如下的配置:
error_log = /usr/local/php/php_error.log
date.timezone = "Asia/ShangHai"
session.save_path = "/tmp"



对conf/httpd.conf 修改在 LoadModules php5_modules modules/libphp5.so 填上
AddType application/x-httpd-php .php .html
AddType application/x-httpd-php-source .phps

apache其他配置信息也写在httpd.conf文件里。例如 主目录位置:

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