Linux下Apache服务器安装与配置
1.下载
从Apache官网http://httpd.apache.org/download下载httpd-NN.tar.gz,NN表示版本号。
2.解压
$ gzip -d httpd-NN.tar.gz
$ tar xvf httpd-NN.tar.gz
$ cd httpd-NN
3.配置
$ ./configure --prefix=[apache dir],这里[apache dir]设置为/usr/local/apache。
4.编译
$ make
5.安装
$ make install
6.操作
启动:$ sudo /usr/local/apache/bin/apachectl -k start,注意要用全路径,而不能cd到bin文件夹执行apachectl -k start。
关闭:$ sudo /usr/local/apache/bin/apachectl -k stop
重启:$ sudo /usr/local/apache/bin/apachectl -k restart
7.可能遇到的问题
启动Apache时遇到httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName问题,解决如下
$ sudo vim /usr/local/apache/conf/httpd.conf
在#ServerName ...注释下面添加一行
#ServerName localhost
重启服务器即可。