PHP服务器搭建二

三、         Apache安装

  安装包:httpd-2.4.18.tar.gz

  依赖安装包apr-1.5.2.tar.gz       apr-util-1.5.4.tar.gz       pcre-8.30.tar.gz     

  pcre安装依赖gcc-g++,确保你机器上已安装。

(注:对于依赖包,在保证根目录磁盘空间充足的情况下,可以使用yum从内源下载)

  安装:

1、安装APR  apr-1.5.2.tar.gz

# tar -zxf apr-1.5.2.tar.gz

# cd apr-1.5.2

# ./configure --prefix=/usr/local/apr

# make

# make install

2、安装APR-util  apr-util-1.5.4.tar.gz

# tar -zxf apr-util-1.5.4.tar.gz

# cd apr-util-1.5.4

# ./configure --prefix=/usr/local/apr-util --with-apr = /usr/local/apr/bin/apr-1-config

# make

# make install

3、安装PCRE  pcre-8.30.tar.gz

# tar -zxf pcre-8.30.tar.gz

# cd pcre-8.30

# ./configure --prefix=/usr/local/pcre

# make

# make install

4、安装Apache2 httpd-2.4.18.tar.gz

# tar -zvxf httpd-2.4.18.tar.gz

# cd httpd-2.4.18

# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/

# make

# make install

 

  配置:

配置文件/usr/local/apache2/conf/httpd.cnf

Listen 80#侦听端口号,使用netstate –anp|grep 80查看端口号有没有被占用

DocumentRoot "Your sites’ location"#默认的服务器网页存放根目录为/usr/local/apache2/htdocs

<Directory "Your sites' location">

目录访问权限配置:

  chmod –R 755 Your sites's location   #设置你的网页目录下所有文件的访问权限

 

  启动apache2

方式一:#usr/local/apache2/bin/apachectl start

方式二:将apache启动服务添加到系统服务中

1.  #cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

2.  保存后输入命令:

#chkconfig –add httpd

#chkconfig --level 345 httpd on

3.启动server httpd start

  启动测试:保持实验室与主机端网络畅通,主机端用浏览器登入实验室服务器ip,出现“It Works!”页面即为安装成功。

  若出现“Forbidden”页面,则是因为apache目录权限访问权限问题。

 

 

posted @ 2019-01-21 15:24  Enchel  阅读(188)  评论(0编辑  收藏  举报