源码编译安装
apache安装
官网下载apache
apache文件目录下编译
./configure --prefix=/usr/local/apache --enable-mods-shared=all
动态加载所有模块:–enable-mods-shared=all
-shared动态加载,去掉则静态加载,推荐–enable-mods-shared=all简单方便,只不过据说动态加载性能要比静态慢5%。
关于加载模块详情推荐一篇博文apache 静态编译和动态编译参考
提示:APR not found. Please read the documentation
apr和apr-util下载 pcre下载
apr编译安装
./configure --prefix=/usr/local/apr
make
make install
apr-util编译安装
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
pcre编译安装
./configure --prefix=/usr/local/pcre
make
make install
编译apache
./configure --prefix=/usr/local/apache --enable-mods-shared=all
提示:APR-util not found. Please read the documentation
添加apr和apr-util以及pcre参数路径
./configure --prefix=/usr/local/apache --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
apache 启动/停止/重启:apache目录下./httpd -k start/stop/restart
或者:sudo /usr/local/apache/bin/httpd -k start/stop/restart
非root用户启动需要给httpd权限:sudo chmod u+s httpd
php安装
xml2-config下载
python-dev安装
sudo apt-get update
sudo apt-get install python-dev
xml2-config编译安装
./configure --prefix=/usr/local/xml2-config
make
make install
php编译安装
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-libxml-dir=/usr/local/xml2-config
make
make install
配置apache支持php
sudo vi /usr/local/apache/conf/httpd.conf
#查找字符串AddType,并增加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#查找字符串
DirectoryIndex
#并修改为
DirectoryIndex index.html index.php default.php
配置php
#查看ini目录
./php --ini
sudo cp /home/liuman/下载/php-7.0.4/php.ini-development /usr/local/php/lib/php.ini
php编译扩展
phpize
m4下载 autoconf下载
先编译安装m4然后编译安装autoconf
./configure
make
make install
开启openssl
sudo apt-get install libssl-dev
#进入到目录etc/openssl
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
php.ini加extension =openssl.so
yum安装
apache安装
yum install httpd -y
apache自启动
chkconfig httpd on
apache服务操作
service httpd start
service httpd stop
service httpd restart
安装php和mysql
yum install php
yum install mariadb
php版本如果太旧,先删除自带的php版本再安装,如果版本够用则直接安装php组件。
yum remove php*
安装第三方源和新版本php
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
yum install php56w
安装php组件
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
重启apache