目录

LAMP

Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案.

Install LAMP via YUM

yum groupinstall -y "mysql数据服务器" "PHP支持"
yum install -y php-mysql
service httpd start
service mysqld start

Install LAMP via ResourceCode

Apache

Port:TCP80 TCP443

logFile:/var/log/httpd/

step1. Install Apache

rpm -e httpd -nodeps   #move system pre-installed httpd software.
tar zxvf http-XXX -C /var/src
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite && make && make install
/usr/local/apache2/bin/apachectl start
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

step2. Addition service to chkconfig

vim /etc/init.d/httpd

#!/bin/sh
#chkconfig:35 12 32
#description:httpd server
#12 --> priority
#32 --> close priority

step3. Start the chkconfig service

chkconfig --add httpd
chkconfig httpd on

step4. Edit the httpd service config file

vim /usr/local/apache2/conf/httpd.conf

#Global
ServerRoot "URL" #Directory for store the config file
Timeout 60 #connect timeout
PidFile run/httpd.pid #the directory for store pid file
listen 80 #listen into port
user XXX #httpd default users:will use 'apache' user when you install via YUM, otherwise you have to create the 'daemon' user to run the httpd service when you install resource.
group XXX #httpd service default group keepAlive on #one connect much transfer data
MaxkeepAliveRequests 500 #Max connection count.
keepAliveTimeout 50 #keep connect alive timeout
prefork #work model to small web
work #work model to big web
Server Admin:ManagerMail
ServerName:www.domain.com:80
DocumentRoot "[websiteUrl]" #VirtualHost more preferential a.yum install: /var/www/html b.resource install:/usr/local/apache2//htdocs
DirectoryIndex: #set welcome page
#Set welcome page example:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
AddDefaultCharset UTF-8 #add character set
#Locality:
<Directory "/var/www/html[websiteUrl]">
Options
AllowOverride
Order
Deny from
</Directory>

step5. Httpd Stress testing

ab -c X httpdServerIP   #X:Sub-requent requests count
ab -n X httpdServerIP #X:Total requests count
Forexample:
ab -c 2000 -n 4000 http://www.domain.com/ #2000 times PV(PageView) at the same time.
ulimit -n 2000 #Change the max supervene access count. Because the max supervene access count have to less than 1024 in the linux file.
ulimit -a #Check all limit

Apache Virtual Machine Type

  1. Virtual Machine type:

    (1) DomainName-based virtual hosting

    (2) IP address-based

    (3) Port-based

Use name-based virtual hosting(the same of ip and port)

step1

mkdir htdocs/baidu htdocs/sina
echo www.baidu.com > htdocs/baidu/index.html
echo www.sina.com > htdocs/sina/index.html

step2. Open virtual machine function

vim httpd.conf

#Virtual Hosts
Include conf/extra/httpd-vhosts.conf

vim conf/extra/httpd-vhosts.conf #Define virtual machine domain

For example:

NameVirtualHost \*:80   #specify virtual machine to name-based hosts.
#Attention: "*:80" have to same as below sections.
<VirtualHost *:80>
ServerAdmin jmilk@fan.com
DocumentRoot "/usr/local/apache2/htdoes/baidu"
ServerName Jmilk.fan.com
ErrorLog "logs/baidu-error_log"
CustomLog "logs/baidu-access_log" common
<Directory "/usr/local/apache2/htdoes/baidu"> #Setup website access permission
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin jmilk@fan.com
DocumentRoot "/usr/local/apache2/htdoes/sina"
ServerName Jmilk.fan.com
ErrorLog "logs/sina-error_log"
CustomLog "logs/sina-access_log" common
</VirtualHost>

vim /etc/hosts

10.20.0.210 www.baidu.com www.sina.com
service httpd restart

Use IP-based virtual hosting

Much step of setup the IP-based virtual hosting as same as the name-based virtual hosting,but different as below.

step1. Comments the “NameVritualHost *:80”

step2. Specify the different IP in the sections of <VirtualHost IP:80>

Use Post-based virtual hosting

step1. Add the Listen port

vim httpd.conf

  Listen 80
Listen 81

step2. Comments the “NameVritualHost *:80”

step3. Specify the different IP in the sections of <VirtualHost IP:Post>

Create personal page.

vim httpd.conf #open home directory

 #User home directories
Include conf/extra/httpd-userdir.conf

vim httpd-userdir.conf

 userDir public_html   --> Create Public_html file in the home directory.

Login the personal page

 chmod o+x /home/user
http://IP/~userName

Security access https

step1. Install Apache by resource and enable ssl protocol

yum -y install mod_ssl
rpm -qa |grep openssl
./configure --enable-so --enable-rewirte --enable-ssl && make && make install

step2. Edit the Apache config file to enable ssl function module

vim httpd.conf

LoadModule ssl_module modules/mod_ssl.so
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf

setp3. Create ssl cert

cd conf/ and Running the cert script as below

#certcreate.sh
#!/bin/bash
read -p "文件名称前缀:" name
openssl genrsa -des3 -out ${name}a.key 1024
openssl rsa -in ${name}a.key -out ${name}.key
openssl req -new -key ${name}.key -out ${name}.csr
openssl x509 -req -days 1000 -in ${name}.csr -signkey ${name}.key -out ${name}.crt

step4. Specify virtual machine which used security(ssl) cert and ssl cert’s store directory url.

vim extra/httpd-ssl.conf

Listen 443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:/usr/local/apache2//logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
SSLMutex "file:/usr/local/apache2//logs/ssl_mutex"
NameVirtualHost *:443 <VirtualHost *:443>
DocumentRoot "/usr/local/apache2//htdocs/baidu"
ServerName jmilk.fan.com:443
ServerAdmin jmilk@fan.com
ErrorLog "/usr/local/apache2//logs/baidu_error_log"
TransferLog "/usr/local/apache2//logs/baidu_access_log"
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL -->列出运行客户端协商的密码
SSLCertificateFile "/usr/local/apache2//conf/server.crt"
SSLCertificateKeyFile "/usr/local/apache2//conf/server.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/usr/local/apache2//cgi-bin">
SSLOptions +StdEnvVars
</Directory> BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "/usr/local/apache2//logs/ssl_request_log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

step4. restart httpd service

service httpd restart

Access control

Only permission user who can access this web pager.

step1. Install awstats software.

unzip awstats-7.0.zip               #Program by Analytic language ,so don't need to compile.
cd /usr/local/awstats-7.0/tools
./awstats_configure.pl #Install of interactive mode
service httpd restart #The entry into force of awstats plugin

step2. Edit the awstats plugin configure file.

vim /etc/awstats/awstats.jmilk.fan.com.conf(awstats.domain.com.conf)

LogFile="/usr/local/apache2/logs/baidu-access_log"
mkdir /var/lib/awstats
http://localhost/awstats/awstats.pl #access awstats software

step3. Edit apache configure file to add awstats plugin

vim httpd-vhosts.conf #change the CustomLog type from “common” to “combined”

CustomLog "logs/sina-access_log" common  --> CustomLog "logs/baidu-access_log" combined
service httpd restart

step4. setting awstats’s access limit

vim httpd.conf

#Add section below for example:
#This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats-7.0/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "AWSTATS"
AuthType Basic
AuthUserFile /usr/local/awstats/wwwroot/.htpasswd
require valid-user
</Directory>

step5. Create htpasswd user by htpasswd tool

cd /usr/local/apache2/bin/htpassed
htpasswd -c /usr/local/apache2/conf/.htpasswd userName1 #In frist create user,you have to use option -c to specify the htpasswd file store url
htpasswd userName2
service httpd restart

MySQL

Port: TCP 3306

step1. install Mysql

step1. Install MySQL via resource

tar zxvf mysql-XXX -C /var/src
useradd mysql -s /sbin/nologin -M #-M --> have not home directory
./configure --prefix=/usr/local/mysql --sysconfdir=/etc/ && make && make install

step2. Initialization Mysql configure.

cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql-install-db --user=mysql
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/var
ln -s /usr/local/mysql/bin/* /usr/local/bin

vim /etc/profile

PATH=${PATH}/usr/local/mysql/bin

step3. Start mysql service

mysql_safe --user=mysql &
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf --> setup mysql interface
ldconfig #Refresh the ld.so.conf file.
service mysqld start
chkconfig mysqld on

step4. Setup mysql’s user and password.

mysqladmin -u root password '123'    #setting password
mysql -u root -p123 #login mysql
#or
mysql_secure_installation --> Basic secure setting

step5. Check the Mysql install

 mysal -u root -p123
show databases;
use mysql;
show tables;

step6. Mysql usage

a. list user’s table field information

describe user;

b. create database and create file in the /usr/local/mysql/var/

create database world;

c. create table

create table tableName(id int not null,name char(16) not null,password char(16) not null default '123',primany key(id));

d. delete table

drop table table DBName.tableName;
delete fro tableName where id=3;

e. select table info or select table item info.

select * from tableName;
select * from tableName where price > 10; #selece by condition
select * from tableName order by price; #from small to big sort
select * from tableName order by price desc; #from big to small sort. desc 降序
select avg(price) from tableName; #average value
select sum(price) from tableName; #summation; or use function min() max() count():output notes conunt.
select type,avg(price) from tableName group by type;
type,avg(price) #every type's average price
select type,avg(price) from tableName group by type having avg(price) > 10; #use where before grouping, use having after grouping.

f. select from much table.

select table1Name.name,table2Name.nation from table1Name,table2Name where table1Name.id=table2Name.id;           #内链接查询
select table1Name.name,table2Name.nation from table1Name left join table2Name on table1Name.id=table2Name.id; #左链接(left join)查询,以左表为主,左表必须全列出符合的记录,右表若没有对应的记录时,以null补全
select table1Name.name,table2Name.nation from table1Name right join table2Name on table1Name.id=table2Name.id; #右链接(right join)
select table1Name.name,table2Name.nation from table1Name cross join table2Name; #全链接查询,交叉查询(cross join)笛卡儿积

g. Insert item into table

insert into tableName(id,name,password) values(1,'userName','123');

h. Update the table item info.

update tableName set password=encrypt('123') where id=1;

b.Mysql date backup and recover:

(1) Backup:

mysqldump -u root -p123 databaseName > tableName.sql  --> backup a database
mysqldump -u root -p123 --all-databases > all.sql --> backup all database

(2) Recover:

mysql -u root -p123 tableName < tableName.sql
mysql -u root -p123 < all.sql --> resover all the database

PHP

step1. Install php support

tar zxvf libmcrypt -C /usr/local
tar zxvf mhach -C /usr/local
tar zxvf mcrypt -C /usr/local #libmcrypr,mhach annd mcrypt combine to secure encrypt deal with.
cd /usr/local/libmcrypt
./configure && make && make install
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
cd /usr/local/mhach
./configure && make && make install
ldconfig
cd /usr/local/mcrypt
./configure && make && make install
tar zxvf php-XXX.tar.gz -C /usr/local
mv php-XXX PHP5
cd /usr/local/php5
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apx5 --with-mysql=/usr/local/mysql --with-mcrpyt --with-config-file-path=/usr/local/php5 --enable-mbstring && make && make install

step2. Edit php Configure file

cp /usr/local/php5/php.ini-development /usr/local/php5/php.ini

vim /usr/local/apache2/conf/httpd.conf #add php plugin to apache


<IfModule mime_module> #加入.PHP后缀识别模块
AddType application/x-httpd-php .php
</IfModule> <IfModule dir_module> #加入PHP欢迎页面
DirectoryIndex index.html index.php
</IfModule>

step3. Test the php module

vim TestPHP.php

<?php
phpinfo()
?>

step4. Install phpMyAdmin manager paper.

tar phpMyAdmin -C /usr/local/apache2/htdocs/baidu
mv phpMyAdmin pma
cp pma/confg.sample.inc.php pma/config.inc.php

step5. Install Discuz

unzip Discuz
cd Discuz
mv upload /usr/local/apache2/htdoes/bbs
chown -R daemon:daemon /usr/local/apache2/htdoes/bbs
http://localhost/bbs #enter installtation pager

Linux_LAMP 最强大的动态网站解决方案的更多相关文章

  1. Linux进阶之LAMP和LNMP动态网站搭建

    一.什么是LAMP LAMP=Linux Apache Mysql/MariaDB PHP/Perl/Python 这些软件都是开源免费的软件,几个程序各自是独立的,经常为了达到我们需要的效果而协同工 ...

  2. React和动态网站接口的经济学

    来自: React and the economics of dynamic web interfaces 自从2000开始我就一直在做web开发,曾见过很多以各种库和框架的起起落落,这些库和框架作为 ...

  3. 编程语言 : Java的动态Web解决方案泛谈

    文章概述 最近发现很久前一股脑地学习框架,发觉越发迷糊.知道了框架只是暂时的,重点是基础的技术.该文大篇幅回顾Servlet技术栈和简要的MVC框架. 至于为什么学J2EE,额,大家都用框架,可框架也 ...

  4. Linux中什么是动态网站环境及如何部署

    当谈论起网站时,我们可能听说过静态和动态这两个词,但却不知道它们的含义,或者从字面意思了解一些却不知道它们的区别. 这一切可以追溯到网站和网络应用程序,Web应用程序是一个网站,但很多网站不是Web应 ...

  5. nginx详解反向代理、负载均衡、LNMP架构上线动态网站(week4_day1_part1)-技术流ken

    nginx介绍 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”,是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理 ...

  6. 《Linux就该这么学》培训笔记_ch20使用LNMP架构部署动态网站环境

    <Linux就该这么学>培训笔记_ch20使用LNMP架构部署动态网站环境 文章最后会post上书本的笔记照片. 文章主要内容: 源码包程序 LNMP动态网站架构 配置Mysql服务 配置 ...

  7. 编译LNMP部署动态网站环境

    LNMP动态网站部署架构是由一套 Linux+Nginx+MySQL+PHP 组成的动态网站系统解决方案. 以下配置环境为:Linux=RHEL7 --> Nginx=1.13 --> M ...

  8. 编译LAMP部署动态网站环境

    LAMP动态网站部署架构是由一套 Linux+Apache+MySQL+PHP 组成的动态网站系统解决方案. 以下配置环境为:Linux=RHEL7 --> Apache=2.4.33 --&g ...

  9. nginx详解反向代理,负载均衡,LNMP架构上线动态网站

    1.nginx介绍 nginx.org Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”,是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/ ...

随机推荐

  1. 表格变色示例中发现的问题——attr()与prop()

    在练习jQuery表格变色例子过程中,发现了一下几个问题: 在IEEdge浏览器中切换选中行会出现上一个表格行背景色被吃掉的情况: 在chrome中从上向下单击行中任意单元可以选中该行,而从下往上单击 ...

  2. ioncube扩展的安装详细图文教程,适合所有新手

    有些程序在php环境下运行需要安装ionCube Loader的扩展支持,这里跳过介绍这些东西直接说一下怎么让你的主机环境支持这种扩展,顺利的让你的程序运行起来!这个教程适合用云服务器或者独立服务器的 ...

  3. eclipse项目添加到本地仓库

    右键项目→Team→Add to Index 提交后,项目变化如下: *表示已经提交到暂存区,可以进行提交操作 右键项目→Team→Commit 可以填写提交信息: 点击信息下面的commit按钮 项 ...

  4. 第三次作业—Wordcount

    一.地址 Github项目地址:https://github.com/1320068008/WordCount-1 同伴蒋鑫作业地址:https://www.cnblogs.com/JxsBK/p/1 ...

  5. Peakvue和自相关技术轴承诊断

    什么是应力波 应力波产生于“金属与金属相互碰撞的事件” 加速度传感器捕捉含有具有短时特性应力波的轴承振动信号 应力波是一种非常短暂的连续的脉冲信号, 通常在百万分之一秒到千分之一秒的区间范围内, 它是 ...

  6. qt03 QString和QByteArray相互转换

    QString str("hello");   QByteArray bytes = str.toUtf8(); // QString转QByteArray方法1       QS ...

  7. 1.基础: 万丈高楼平地起——Redis基础数据结构 学习记录

    <Redis深度历险:核心原理和应用实践>1.基础: 万丈高楼平地起——Redis基础数据结构 学习记录http://naotu.baidu.com/file/b874e2624d3f37 ...

  8. 逻辑卷管理器(LVM)

    一.什么是LVM? LVM(Logical Volume Manager)逻辑卷管理是在Linux2.4内核以上实现的磁盘管理技术.它是Linux环境下对磁盘分区进行管理的一种机制.现在不仅仅是Lin ...

  9. ZROI 19.07.30 简单图论/kk

    1.最短路 NOI2019 D2T1 我被这题送Fe了/lb 只有zz才会写二维线段树,比如我. 实际上你只需要矩形取min就可以. kd-tree可以随便过,最慢的点\(0.1s\). 另外一种简单 ...

  10. [转帖]ssh 远程执行命令

    ssh 远程执行命令 https://www.cnblogs.com/youngerger/p/9104144.html SSH 是 Linux 下进行远程连接的基本工具,但是如果仅仅用它来登录那可是 ...