1.lnmp
首先
确保CentOS7上网络配置正确,可以正常访问互联网。
确保已经关闭了iptables。
CentOS7上是firewall,关闭命令:
1
2
|
# systemctl stop firewalld.service # 停止firewalld服务 # systemctl disable firewalld.service # 设置开机默认不启动 |
确保selinux已经关闭。
1
2
3
4
|
# setenforce 0 # 不重启系统的状态下关闭selinux(permissive状态) # getenforce # 查看状态 # vim /etc/sysconfig/selinux # 开机不启动 SELINUX=disabled
|
在这里使用阿里云的yum源,命令行输入:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2.安装Apache
1
2
3
4
5
6
7
8
9
10
|
# yum install -y httpd # vim /etc/httpd/conf/httpd.conf # 修改配置文件 DirectoryIndex index.html index.php # 在该项后面添加index.php,支持index.php主页 AddType application /x-httpd-php .ph # 添加php支持 # vim /var/www/html/index.php # 在默认主页存放的路径下,添加index.php的测试文件 <?php phpinfo(); ?> # systemctl start httpd.service # 启动httpd # systemctl status httpd.service # 查看运行状态 # ss -ntlp # 查看监听的端口 # systemctl enable httpd.service # 设置开机启动 |
注意:如果是配置zabbix server的LAMP环境,配置文件里
1
|
DirectoryIndex index.html # 该项后面不要添加index.php |
3.安装MariaDB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# yum install -y mariadb-server # yum安装MariaDB,在CentOS6 yum install mysql-server # vim /etc/my.cnf # 在[mysql-safe]部分添加 skip_name_resolve=on # 禁止域名解析 innodb_file_per_table=on # 修改InnoDB为独立表空间模式 # systemctl start mariadb.service # 启动mariadb # systemctl enable mariadb.service # mysqladmin -u root password 'dtsdts'; # 创建管理员密码 # mysql_secure_installation # 初始化安全设置 # mysql -uroot -pdtsdts # root用户登录 MariaDB [(none)]> CREATE DATABASE zabbix CHARSET 'utf8' ; #创建zabbix库,默认字符集为utf8 MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@ '127.0.0.1' IDENTIFIED BY 'zbxpass' ; MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@ 'localhost' IDENTIFIED BY 'zbxpass' ; # zbxuser可以从本机登录,密码为zbxpass,对zabbix拥有所有权限 MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@ '10.10.10.%' IDENTIFIED BY 'zbxpass' ; # zbxuser可以从10.10.10.0网段登录,密码为zbxpass,对zabbix拥有所有权限 MariaDB [(none)]> flush privileges; # 刷新权限 |
4、安装php
1
2
|
# yum install -y php php-mysql # yum install -y php-gd php-xml php-process php-mbstring php-bcmath # 安装php扩展组件 |
可以修改/etc/php.ini进行简单的php优化(非必要):
1
2
3
4
5
6
|
max_execution_time = 300 memory_limit = 128M post_max_size = 16M upload_max_filesize = 2M max_input_time = 300 date .timezone PRC |
5、测试
1
2
3
|
# 重启服务 # systemctl restart httpd.service # systemctl restart mariadb.service |
或者