~~~
cd /usr/local/src/
wget http://apache.mirror.globo.tech//httpd/httpd-2.4.35.tar.gz
tar zxvf httpd-2.4.35.tar.gz
cd httpd-2.4.35
~~~
~~~
./configure \
--prefix=/usr/local/apache \
--sysconfdir=/etc/httpd \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/bin/apu-1-config \
--with-pcre=/usr/local/pcre \
--enable--ssl \
--enable-so \
--enable-rewrite
~~~
~~~
make && make install
~~~
## 编辑配置文件
#在文件最后的部分,末尾加上这两句代码
~~~
cp /etc/httpd/httpd.conf /data/temp/httpd.conf
vim /etc/httpd/httpd.conf
PidFile "/var/run/httpd.pid"
AddHandler application/x-httpd-php .php
~~~
#设置特定目录的属性
~~~
ServerName localhost:80
<Directory "/usr/local/apache/htdocs/iooni.com">
Require all granted
AllowOverride All #去读取.htaccess配置文件的内容
Order allow,deny #先执行allow访问控制规则,再执行deny
Allow from all #放行所有
</Directory>
~~~
example(例子):
~~~
<VirtualHost *:80>
DirectoryIndex index.php index.html
ServerAdmin 1422476675@qq.com
DocumentRoot "/data/waimai/public"
ServerName www.amlee.org
ErrorLog logs/dummy-host.amlee.org-error_log
CustomLog logs/dummy-host.amlee.org-access_log common
</VirtualHost>
~~~
#### 启动httpd服务
~~~
/usr/local/apache/bin/apachectl start //启动httpd服务
问题:Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
netstat -tulnp | grep ':80' //查看被占用端口的进程
kill '进程号'
~~~
#### 开机自启
~~~
vim /etc/rc.d/rc.local
/usr/local/apache/bin/apachectl start #last line add
~~~
#### 环境变量
~~~
vi /root/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/apache/bin
source /root/.bash_profile
~~~