Ubuntu 12.04
LAMP(Linux,Apache,Mysql,PHP)
1、安装Apache
(1)在安装HTTP Server之前需安装APR(Apache Portable Runtime)和APR-util安装APR
$ tar zxvf apr-1.4.6.tar.gz
$ cd apr-1.4.6/
$ ./configure
$ make
$ sudo make install
(2)安装APR-util
$ 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默认安装位置/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 startAH00558: 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!”
2、安装MySQL
(1)、下载安装mysql-5.5.25.tar.gz,默认安装位置/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
(2)、启动MySQL:
方法1:$ sudo service mysql.server start
方法2:$ sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
3、安装PHP
(1)安装下载php-5.4.4.tar.gz
$ 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
一条命令可以让你在ubuntu上很方便地安装web服务器
sudo tasksel install lamp-server用这个可以一次安装好apache+php+mysql
再两条命令让你安装上phpmyadmin,让你方便地管理mysql数据库:
sudo apt-get install phpmyadminsudo ln -s /usr/share/phpmyadmin/ /var/www/html
1.安装Apache2
使用下面这个命令,安装Apache2及其他库。
$ sudo apt-get -y install apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt libapache2-mod-suphp libopenssl-ruby libapache2-mod-ruby
2.阻止分布式拒绝服务(DDoS)攻击
$ sudo apt-get -y install libapache2-mod-evasive$ sudo mkdir -p /var/log/apache2/evasive
$ sudo chown -R www-data:root /var/log/apache2/evasive
把下面这个命令添加到mod-evasive.load的末尾处。
$ sudo nano /etc/apache2/mods-available/mod-evasive.load DOSHashTableSize 2048DOSPageCount 20 # 请求同一页面的最大数量
DOSSiteCount 300 # 同一侦听器上同一客户端IP请求任何对象的总数量
DOSPageInterval 1.0 # 页面数量阈值的间隔
DOSSiteInterval 1.0 # 站点数量阈值的间隔
DOSBlockingPeriod 10.0 # 客户机IP被阻止的时间段
DOSLogDir “/var/log/apache2/evasive”
DOSEmailNotify admin@domain.com
3.阻止DNS注入攻击
$ sudo apt-get -y install libapache2-mod-spamhaus$ sudo touch /etc/spamhaus.wl Append the config to apache2.conf
$ sudo nano /etc/apache2/apache2.conf
MS_METHODS POST,PUT,OPTIONS,CONNECT
MS_WhiteList /etc/spamhaus.wl
MS_CacheSize 256
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)