centos7搭建LAMP

LAMP = Linux + Apache + MySQL + PHP

1)Apache
yum install httpd
启动服务,开机自起,开放80端口

2)MySQL
由于yum源上没有mysql-server。所以必须去官网下载,这里 我们用wget命令,直接获取。
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server
启动服务,开机自起,开放3306端口,(设置root密码)
重启计算机

3)PHP
yum install php
#安装PHP组件,使PHP支持mysql
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
可能需要重启mysqld和httpd
案考:安装LAMPhttp://www.cnblogs.com/wgq123/p/6028718.html
4)配置虚拟主机
一台计算机可以放置多个网站,称为ie虚拟主机,不同的网站通过不同的域名访问,每一个网站对应磁盘上的单独的目录。
centos7 apache2.4(配置文件目录结构跟linux版本、apache版本有关系,但配置理念一样,apache版本一样时配置方法基本一样,路径可能不同)
vim /etc/httpd/conf/httpd.conf
增加include vhost.d/*.conf
mkdir /etc/httpd/vhost.d/
[root@centos7-1 httpd]# cat ./vhost.d/name.conf 
<VirtualHost *:80>
    ServerAdmin admin@amsilence.com
    DocumentRoot "/var/html/www"
    ServerName www.centos7-1.com
    ErrorLog "/var/httpd/logs/www-error_log"
    CustomLog "/var/httpd/logs/www-access_log" common
</VirtualHost>

<Directory /var/html/www/>    可改成 DirectoryIndex index.php index.html放到<Vir...>    </Vir...>中
Require all granted
</Directory>

<VirtualHost *:80>
    ServerAdmin admin@amsilence.com
    DocumentRoot "/var/html/bbs"
    ServerName bbs.centos7-1.com
    ErrorLog "/var/httpd/logs/bbs-error_log"
    CustomLog "/var/httpd/logs/bbs-access_log" common
</VirtualHost>

<Directory /var/html/bbs/>
Require all granted
</Directory>

检查配置:/sbin/service httpd configtest

重启httpd服务。  

参考http://blog.csdn.net/wusilen/article/details/54317822



网页分为动态和静态两种,静态网页用户每次看到的内容都一样。

DNS图

动态网页是服务器上的程序,次程序可以由C、bash、PHP、Java、Python、Ruby等语言编写。当用户去浏览某个动态网页时文件时,服务器临时去执行这个网页文件(实际上就是程序),
执行结果就是生成一份完整的HTML文件保存在内存中,而不是硬盘上。


原文地址:https://www.cnblogs.com/daduryi/p/6637518.html