# yum groupinstall "Development Tools"
# yum -y install libxml2 libxml2-devel bzip2-devel curl curl-devel libjpeg-devel libpng libpng-devel libXpm-devel gcc gcc-c++ freetype-devel glib2-devel cairo-devel postgresql-devel libxslt libxslt-devel mysql-devel
# cd /usr/local/src
# wget http://cn.php.net/distributions/php-5.6.38.tar.bz2
# tar –xjvf php-5.6.38.tar.bz2
# cd php-5.6.38
# ./configure --prefix=/usr/local/php56 --with-config-file-path=/usr/local/php56/etc --with-apxs2=/usr/local/apache24/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libxml-dir --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-sockets --enable-sysvsem --enable-xml --enable-zip
*** libtool: warning: remember to run 'libtool --finish /usr/local/src/php-5.6.38/libs'
【 如果之前的yum groupinstall及yum install相关的准备工作已经完成,下面部分将不会有,如果没有做准备工作,可根据错误提示一次次排错
configure: error: xml2-config not found. Please check your libxml2 installation.
# yum install -y libxml2 libxml2-devel
configure: error: Please reinstall the BZip2 distribution
# yum -y install bzip2-devel
configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
# yum -y install curl curl-devel
configure: error: jpeglib.h not found.
# yum -y install libjpeg-devel
configure: error: png.h not found.
# yum -y install libpng libpng-devel
configure: error: xpm.h not found.
# yum -y install libXpm-devel
configure: error: freetype-config not found.
# yum -y install gcc gcc-c++ freetype-devel glib2-devel cairo-devel
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
# ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/
# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
# yum groupinstall "Development Tools"
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
# yum -y install postgresql-devel
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
# yum -y install libxslt libxslt-devel
# make
In file included from /usr/local/src/php-5.6.38/ext/mysqli/mysqli.c:34:0:
/usr/local/src/php-5.6.38/ext/mysqli/php_mysqli_structs.h:82:21: 致命错误:my_list.h:没有那个文件或目录
#include <my_list.h>
编译中断。
make: *** [ext/mysqli/mysqli.lo] 错误 1
# yum -y install mysql-devel
】
# make
# make install
# cp php.ini-production /usr/local/php/php5.6/etc/php.ini
配置httpd支持PHP
# vim /etc/httpd/httpd.conf
搜索ServerName,把#ServerName www.example.com:80前面的#号删除(此处未做,在安装Apache时在此处添加ServerName localhost:80)
将<Directory />段中的Require all denied改为Require all granted
在AddType application/x-gzip .gz .tgz下面添加一行AddType application/x-httpd-php .php
在<IfModule dir _module>段中添加
AddType application/x-httpd-php .php
在启动httpd之前检验配置文件是否正确
# /usr/local/apache24/bin/apachectl –t
启动apache
# /usr/local/apache24/bin/apachectl start
测试
# curl localhost
测试是否正确解析PHP
# vim /usr/local/apache24/htdocs/1.php
输入PHP代码,然后在浏览器中输入IP/1.php测试
====================================================
默认虚拟主机
# vim /etc/httpd/httpd.conf
# Virtual hosts
Include /etc/httpd/extra/httpd-vhosts.conf ==去掉行首的#
# vim /etc/httpd/extra/httpd-vhosts.conf
默认内容
<VirtualHost *:80> #默认虚拟主机
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com #网站域名,只能有一个
ServerAlias www.dummy-host.example.com #网站第二域名,可以有多个,中间用空格隔开
ErrorLog "logs/dummy-host.example.com-error_log" #错误日志
CustomLog "logs/dummy-host.example.com-access_log" common #访问日志
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/local/apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
修改后
<VirtualHost *:80>
ServerAdmin yangle926@163.com
DocumentRoot "/data/wwwroot/aming.com"
ServerName aming.com
ServerAlias www.aming.com
ErrorLog "logs/aming.com-error_log"
CustomLog "logs/aming.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.123.com"
ServerName www.123.com
</VirtualHost>
测试:
# mkdir -p /data/wwwroot/aming.com /data/wwwroot/www.123.com
# echo "aming.com" > /data/wwwroot/aming.com/index.html
# echo "123.com" > /data/wwwroot/www.123.com/index.html
# /usr/local/apache24/bin/apachectl -t
# /usr/local/apache24/bin/apachectl graceful //这个操作是重新加载httpd服务
# curl -x127.0.0.1:80 aming.com
# curl -x127.0.0.1:80 www.abc.com
如果显示You don't have permission to access /index.html on this server. 则表示权限设置有误,修改httpd.conf将"Deny from all"这行给注释掉就可以了。
分享到:
相关推荐
centos7编译安装php
主要介绍了centos7上编译安装php7以php-fpm方式连接apache的相关知识,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下
Centos6 LAMP编译安装详细说明。包括httpd-2.2.27.tar.gz,mysql-5.1.59.tar.gz,php-5.2.6.tar.gz 等13个安装包的详细编译安装过程说明。
Centos_6.3_编译安装Nginx+php+Mysql,基础文档
64位通过编译方式安装php出现的问题及解决方式
除了编译器使用yum安装,其他全部手动编译。哼~ 看似就Nginx、PHP、MySql三个东东,但是它们太尼玛依赖别人了。 没办法,想用它们就得老老实实给它们提供想要的东西。 首先的一些模块依赖一些lib库, 如果你是懒人,...
编译PHP5配置centos6.4
下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址。 ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/...
Centos7.6源码编译安装HTTP+PHP+Zabbix 5.2.2+PostgreSQL+TimescaleDB+Grafana
CentOS 6.4系统下编译安装LNMP和配置PHP环境.docx
centos 6.0最简化编译安装Nginx+Mysql+PHP+Zend
CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13
PHP7.0正式版也出来了,今天编译安装了一下,写下安装步骤,我是在centos6.6 环境中编译的,下面是详细的安装步骤 环境依赖 yum install gcc gcc-c++ libxml2 libxml2-python libxml2-devel -y 下载 wget ...
CentOS下php安装mcrypt扩展需要的三个安装包,需要重新编译,请大家参考 libmcrypt-2.5.8.tar mcrypt-2.6.7-win32 mcrypt-2.6.8.tar mhash-0.9.9.9.tar
主要介绍了详解Centos7源码编译安装 php7.2之生产篇,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
CentOS 6.2编译安装Apache2.4.1+MySQL5.5.21+PHP5.3.10
CentOS 5.6编译安装Apache2.4.1+MySQL5.5.21+PHP5.3.10
CentOS 6.X 编译安装Nginx1.6.2+MySQL5.6.21+PHP5.6.3 linux CentOS Nginx MySQL PHP 系统运维 所有安装包和说明
Centos 7编译安装php7.1之生产篇,并安装前文开头所提供的依赖包。此依赖组件包适用于Nginx任意版本。 新建web用户和组 $ /usr/sbin/groupadd www $ /usr/sbin/useradd -g www www $ ulimit -SHn 65535 //设置linux...