Linux下如何搭建WEB服务器教程

软件:LAMP(Linux,Apache,Mysql,PHP)

1、安装Apache

(1)在安装HTTP Server之前需安装APR(Apache Portable Runtime)和APR-util安装APR(http://apr.apache.org/)
$ tar zxvf apr-1.4.6.tar.gz
$ cd apr-1.4.6/
$ ./configure
$ make
$ sudo make install


(2)安装APR-util(http://apr.apache.org/)
$ tar zxvf apr-util-1.4.1.tar.gz
$ cd apr-util-1.4.1
$ ./configure –with-apr=/usr/local/apr (whereis apr)
$ make
$ sudo make install


(3)安装httpd-2.4.2.tar.bz2(http://httpd.apache.org/)默认安装位置/usr/local/apache2网页放在/usr/local/apache2/htdocs配置文件/usr/local/apache2/conf/httpd.conf
$ tar jxvf httpd-2.4.2.tar.bz2
$ cd httpd-2.4.2/
$ ./configure
$ make
$ sudo make install

(4)启动HTTP Server$ sudo /usr/local/apache2/bin/apachectl start

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message

(5)查看http是否正常运行$ netstat -a | grep httptcp 0 0 *:http *:* LISTEN

(6)在浏览器输入127.0.0.1如果正常应该显示“It works!”
END


2、安装MySQL

下载mysql-5.5.25.tar.gz(http://www.mysql.com/downloads/mysql/)默认安装位置/usr/local/mysql/
$ tar zxvf mysql-5.5.25.tar.gz
$ cd mysql-5.5.25/
$ sudo groupadd mysql


$ sudo useradd -r -g mysql mysql


$ cmake .
$ make
$ sudo make install

$ cd /usr/local/mysql/
$ sudo chown -R mysql .
$ sudo chgrp -R mysql .

$ sudo scripts/mysql_install_db –user=mysql

$ sudo chown -R root .
$ sudo chown -R mysql data/

$ sudo cp support-files/my-medium.cnf /etc/my.cnf


$ sudo cp support-files/mysql.server /etc/init.d/mysql.server


启动MySQL
方法1:$ sudo service mysql.server start


方法2:$ sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
END

3、安装PHP

(1)安装下载php-5.4.4.tar.gz(http://php.net/)
$ tar zxvf php-5.4.4.tar.gz
$ cd php-5.4.4
$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --enable-mbstring --with-mcrypt(可能需要安装libmcrypt-dev )
$ sudo make install
$ sudo cp php.ini-development /usr/local/lib/php.ini

(2)配置HTTP Server使之支持PHPapache配置文件/usr/local/apache2/conf/httpd.conf修改或添加如下配置
<;IfModule dir_module>
    DirectoryIndex index.php
<;/IfModule>

<;FilesMatch \.php$>
    SetHandler application/x-httpd-php
<;/FilesMatch>

(3)重启HTTP Server
$ sudo /usr/local/apache2/bin/apachectl restart

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值