1.apr包的安装
apr简介:
The mission of the Apache Portable Runtime (APR) project is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementations.
The primary goal is to provide an API to which software developers may code and be assured of predictable if not identical behaviour regardless of the platform on which their software is built, relieving them of the need to code special-case conditions to work around or take advantage of platform-specific deficiencies or features.
下载地址:
wget http://labs.mop.com/apache-mirror//apr/apr-1.4.6.tar.gz
wget http://labs.mop.com/apache-mirror//apr/apr-util-1.4.1.tar.gz
tar xvf apr-1.4.6.tar.gz
tar xvf apr-util-1.4.1.tar.gz
cd apr-1.4.6
./configure
make
make install
在编译时有可能会出现以下问题
cannot remove `libtoolT': No such file or directory
解决方法:
vim configure
把RM='$RM'改为RM='$RM -f',在configure里面 RM='$RM -f' 这里的$RM后面一定有一个空格。 如果后面没有空格,直接连接减号,就依然会报错。
cd apr-util-1.4.1
./configure --with-apr=/usr/local/apr
make
make install
./configure --prefix=/usr/local/apache2 --enable-modules=shared --enable-so --enable-deflate --enable-expires --enable-headers --enable-rewrite --with-included-apr=/usr/local/apr --with-included-apr-util
make
make install
编译过程中可能遇到
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
解决方法:apt-get install libpcre3-dev
checking for zlib location... not found
checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
解决方法:apt-get install zlib1g-dev
初始化mysql数据库时可能会遇到:
./bin/mysqld: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory
解决方法:apt-get install libstdc++5
checking if we should use cURL for url streams... no
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解决方法:apt-get install libcurl4-openssl-dev
configure: error: jpeglib.h not found.
解决方法:apt-get install libjpeg62-dev
configure: error: png.h not found.
解决方法:apt-get install libpng-dev
php 5.4.6 make 时在apprentice.c -o ext/fileinfo/libmagic/apprentice.lo 没反应了
在网上查了查是内存不足,这一步要编译过去至少要有1G内存,我只有300M的内存。
把该虚拟机内存调到1.2G,这一步就ok了
以上编译过程中产生的编译错误,当然如果你搭建过n边LAMP环境就可以直接以下操作,是不是省事很多
apt-get install -y curl libxml2 libxml2-dev libssl-dev sendmail libcurl4-openssl-dev libjpeg-dev libpng-dev libmcrypt-dev
不知道大家发现规律没有,一般在ubuntu下编译通过不了,根椐报错找到XXXX-dev的包安装即可。如果你人品差,apt-get 安装的包版本太低
那就需要下载更新的软件包编译安装了。
make
make test
make install
cp php.ini-production /usr/local/php/lib/php.ini
vim /etc/profile
PATH=$PATH:/usr/local/php/bin/
source /etc/profile
验证一下php是否正确安装:
apachectl -k restart
cd /usr/local/apache2/htdocs
vim index.php
<?php
phpinfo();
?>
通过浏览器访问:http://yourhostip/index.php
如果能正确访问说明php安装ok了
测试php与mysql的链接性
设置mysql的权限:允许通过本机或同一网段的主机链接mysql server,同一网段(192.168.12.0)如:192.168.12.%
mysql -uroot -predhat
mysql>grant all privileges on *.* to 'root'@'yourhostip_in_network';
测试链接脚本:
vim /usr/local/apache2/htdocs/index.php
<?php
$link=mysql_connect('yourhostip','root','redhat');
if(!$link)
echo "connect mysql failing...";
else
echo "connect mysql successful...";
mysql_close();
?>
./configure --with-php-config=/usr/local/php/bin/php-config --with-mysql=/usr/local/mysql
make
make install
在/usr/local/php/lib/php/extensions/no-debug-zts-20100525/目录下自动生成mysql.so文件
修改配置文件:vim /usr/local/php/lib/php.ini
去掉注释并修改extension=mysql.so
数据库的设置:
mysql -uroot -predhat
mysql>create database wordpress;
mysql>grant all privileges on wordpress.* to 'wpuser'@'10.48.255.%' identified by "redhat";
mysql>flush privileges;
修改wordpress的配置文件:
cp /usr/local/apache2/htdocs/wordpress/wp-config-sample.php /usr/local/apache2/htdocs/wordpress/wp-config.php
vim /usr/local/apache2/htdocs/wordpress/wp-config.php
#修改一下几行
define('DB_NAME', 'wordpress');
/** MySQL 数据库用户名 */
define('DB_USER', 'wpuser');
/** MySQL 数据库密码 */
define('DB_PASSWORD', 'redhat');
/** MySQL 主机 */
define('DB_HOST', '10.48.255.244');