LAMP includes Linux operating system, Apache website service, MySQL database server, PHP (or Perl, python) web programming language
The main role of each part
(Platform) Linux: Open source, free and stable as the foundation of LAMP architecture
(Front desk) Apache: As the front end of the LAMP architecture, it provides front-end web services
(Back-end) MySQL: As a back-end relational database of LAMP architecture
(Intermediate connection) PHP, Perl, Python: as the three programming languages for developing dynamic web pages, it is responsible for interpreting dynamic webpage files, communicating with web servers and database systems for collaborative work, and providing a development and operating environment for web applications.
Installation sequence
When building the LAMP platform, the order of installation of each component is Linux, Apache, MySQL, PHP.
Among them, there is no strict order for the installation of Apache and MySQL. The installation of the PHP environment is generally placed at the end, responsible for communicating with the web server and database system to work together.
Apache web service
To compile and install the Apache website service, we need to download several installation packages from the Internet, namely httpd-2.4.29.tar.gz, apr-1.6.2.tar.gz and apr-util-1.6.0.tar .gz.
1. Turn off the firewall, and upload the software packages required to install Apache to the /opt directory
cd /opt/
tar zxvf apr-1.6.2.tar.gz
tar zxvf apr-util-1.6.0.tar.gz
tar jxvf httpd-2.4.29.tar.bz2
mv apr-1.6.2 /opt/httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 /opt/httpd-2.4.29/srclib/apr-util
cd /opt/httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \ #指定将 httpd 服务程序的安装路径
--enable-so \ #启用动态加载模块支持,使 httpd 具备进一步扩展功能的能力
--enable-rewrite \ #启用网页地址重写功能,用于网站优化、防盗链及目录迁移维护
--enable-charset-lite \ #启动字符集支持,以便支持使用各种字符集编码的页面
--enable-cgi #启用CGI(通用网关接口)脚本程序支持,便于网站的外部扩展应用访问能力
4. Compile and install
make #make -j 2 表示开2核同时进行编译
make install
5. Optimize the configuration file path, and put the executable program file of the httpd service into the directory of the path environment variable for easy system identification
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd #用于service服务管理
chmod +x /etc/init.d/httpd
vi /etc/init.d/httpd
#!/bin/bash #在第一行前插入新行,添加此三行内容
# chkconfig: 35 85 21 #35级别自动运行 第85个启动 第21个关闭
# description: Apache is a World Wide Web server
#!/bin/bash
# chkconfig: 35 85 21
# description: Apache is a World Wide Web server
chkconfig --add httpd #将httpd服务加入到service管理器
systemctl start httpd.service
或
service httpd start
mysql -u root -p
grant all privileges on *.* to 'root'@'%' identified by 'abc123';
#授予root用户可以在所有终端远程登录,使用的密码是abc123,并对所有数据库和所有表有操作权限
show databases; #查看当前已有的数据库
Compile and install PHP parsing environment
1. Transfer the software packages required to install PHP to the /opt directory
php-7.1.10.tar.bz2
2. Install GD library and GD library related programs to process and generate pictures
mysql -u root -p
CREATE DATABASE bbs;
#创建一个数据库
GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';
#把bbs数据库里面所有表的权限授予给bbsuser,并设置密码admin123
flush privileges;
#刷新数据库
show databases;