linux 安装apache 2.4.9+php 7.0.28
安装准备工作yum install -y apr-gcc-libpcre- pcre-openssl-*
由于系统包中的curl版本低不支持,所以需要手动下载安装
wget https://curl.haxx.se/download/curl-7.59.0.tar.gz
tar -xf curl-7.59.0.tar.gz
cd curl-7.59.0
./configure
make && make install
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.3.tar.gz
tar -xf libmcrypt-2.5.3.tar.gz
cd libmcrypt-2.5.3
./configure
make && make install
wget http://mirrors.shu.edu.cn/apache//apr/apr-1.6.3.tar.gz
mkdir /usr/local/apr
tar -xf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix= /usr/local/apr
make && make install
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
mkdir /usr/local/apr-util
tar -xf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix= /usr/local/apr-util
make && make install
安装apache
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.29.tar.gz
tar -xf httpd-2.4.29.tar.gz
mv httpd-2.4.29 httpd
cd httpd
./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-so --enable-deflate --enable-expires --enable-headers --enable-ssl --enable-rewrite --enable-mpms-shared=all --with-mpm=prefork --enable-mods-shared=most
make && make install
安装php
wget http://cn2.php.net/distributions/php-7.0.28.tar.gz
tar -xf php-7.0.28.tar.gz
mv php-7.0.28 php
cd php
./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache2/bin/apxs--enable-pdo --with-pdo-mysql --with-mysql-sock --enable-xml --with-libxml-dir --enable-sockets --with-curl --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-mcrypt --with-openssl --with-mhash --enable-zip --enable-mbstring --enable-mbregex --with-iconv --enable-static
make && make install
修改配置:
修改apache httpd.conf
在195行去除“#” 修改为:ServerName localhost:80
在253行中添加index.php
DirectoryIndex index.php index.html
在390行后面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
配置php 首页index.php
在/usr/local/apache2/htdocs 中创建index.php
vim index.php
将以下内容输入文件中
保存退出。
启动httpd服务
/usr/local/apache2/bin/apachectl start
设置apache开启启动
cp -p /usr/local/apache2/bin/apachectl /etc/init.d/httpd
由于新的apache不支持chkconfig命令,所以我们需修改httpd文件
在/etc/init.d/httpd文件中的 #!/bin/sh下添加两行代码
#!/bin/sh
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server
添加完后在执行chkconfig命令进行服务自启动添加
chkconfig --add httpd
chkconfig --level 345 httpd on
查看下服务设置情况
chkconfig --list | grep httpd
或者
在/etc/rc.d/rc.local中增加启动apache的命令,例如:/usr/local/apache2/bin/apachectl start
测试
在本地测试,
PHP就配置好了。
页:
[1]