Oj大致搞好了,但是编译php的时候有莫名其妙的错误,”./”居然不在文件所在目录,而是跑到home下面了,实在是不能忍。user_dirinclude_dir setincludepath 等等方法全都无效,后来看到有人说是版本的问题,php5.3的问题。于是决定升级。
Ubuntu自带php5.3和apache2.4.6,首先要卸载了。
先根据dpkg-l找到相应的包,然后再一个个删除,不要手软。
喜欢用remove命令删除的,可以参考这个页面。
blog.csdn.net/guojing880208/article/details/6592772
要注意的是apache一定要卸载干净,否则新的安装的时候是不会默认覆盖的,于是后面安装php时候,就会怎么也安装不上libphp5.so。
首先编译安装apache2.4.7,到官网上下载下来包。解压,进入文件夹。
容易出现的问题是发现没有apr和apr-uti,参考官网给出的步骤。
进入目录后
./configure --prefix=/usr/local/apr
make
make install
然后安装apr-until,下载解压,进入目录。configure的时候,注意要指定apr的路径。
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install
然后进入apache的文件夹。注意指定apr和apr-net的路径,否则会出错。
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make
make install
参考网页
编译安装后,要注意的重要问题是配置文件的位置问题。和普通安装的不同,有效的httpd.conf再apr目录的conf下面。配置apache/conf下面的httpd.conf是没有效果的。这一点很关键。
进入apache主目录下面的bin,看是否可以启动服务器。
apachectl start
如果可以再浏览器输入locahost后看到Itworks,说明配置成功。
每次启动都要进入这个目录实在麻烦,所以
sudo cp bin/apachectl /etc/init.d/apache
如果做连接文件也是可以的。
为了随时查看版本号
sudo ln -s /usr/local/apache2/bin/httpd apache
让apache每次开机启动,首先进入/etc/rcS.d
sudo ln -s ../init.d/apache S90apache2
考建立开机启动的页面
然后安装PHP
首先下载php5.5.9,解压后,进入目录。
需要安装libxml2
sudo apt-get install libxml2libxml2-dev
./configure 有很多参数,参考
./configure
--prefix=/usr #安装位置
--sysconfdir=/etc #系统配置文件存放位置
--with-config-file-path=/etc #配置文件路径
--without-pear #不安装pera扩展包
--enable-fpm #能够使用fpm模式,nginx必须
--with-fpm-user=www-data #fpm用户,和nginx的用户一致
--with-fpm-group=www-data #fpm用户组,和nginx使用组一致
--enable-opcache #使用php内置opcache缓存
--enable-mbstring #可以使用mbstring相关函数
--enable-mbregex #可以使用mbregex正则
--without-pdo-sqlite #不安装pdo-sqlite扩展
--with-mysql-sock=/var/run/mysqld/mysqld.sock #指定mysql的sock位置
--with-mysql=mysqlnd #支持mysql相关扩展
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--with-openssl #支持https
--with-curl #curl相关
--with-zlib #zlib压缩
--enable-zip #支持zip压缩
--with-gd #安装gd库
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--with-mcrypt #能够使用mcrpt加密库
--enable-sockets #支持sockets
-with-xmlrpc #支持xml解析
--enable-soap
我得安装命令是
sudo ./configure --prefix=/usr --sysconfdir=/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/etc
--without-pear --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --enable-opcache --enable-mbstring
--enable-mbregex --without-pdo-sqlite --with-mysql-sock=/run/mysqld/mysqld.sock --with-mysql=mysqlnd --with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd --with-openssl --with-zlib --enable-zip --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-mcrypt --enable-sockets --with-xmlrpc --enable-soap -enable-mbstring=all
注意你的mysql的路径,如果需要的话,如果不需要,直接删掉上面有关mysql的选项即可。因为几次没有安装上libphp5.so,所以指定了--with-apxs2=/usr/local/apache2/bin/apxs。可以通过find命令查找apxs的位置,如果没有,说明apache安装的不好。
然后
make
make install
与以往版本不同,这个的编译命令不再是php而是php-fpm。
安装过程中,如果是有
/usr/local/src/php-5.4.3/ext/standard/info.c:874: undefined reference to `executor_globals_id'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] 错误 1
是由于使用不同参数重复编译所致,makeclean即可。
如果不能解析php,再httpd.conf后面加入
AddType application/x-httpd-php .php .php3 .php4 .html
LoadModule php5_module /usr/local/apache2/modules/libphp5.so
PHPIniDir /etc/php.ini
AddDefaultCharset UTF-8 #解决mysql乱码
此时就应该可以通过phpinfo看到熟悉的页面了。