centos 6.0 php,CentOS 6.0安装配置LAMP服务器(Apache+PHP5+MySQL)

85d236d0b027eba2fb8008fb09c8d765.png

准备篇:配置防火墙,开启80端口、3306端口

vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT(允许80端口通过防火墙)

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT(允许3306端口通过防火墙)

重启防火墙使配置生效

/etc/init.d/iptables restart

service iptables restart系统运维 温馨提醒:qihang01原创内容版权所有,转载请注明出处及原文链接

安装篇:

一、安装Apache

1、检查是否已安装Apache

rpm -qa|grep httpd

httpd-2.2.15-5.el6.centos.i686

httpd-tools-2.2.15-5.el6.centos.i686

如果看到上面的信息,说明系统已经安装了Apache

2、安装Apache

yum install httpd

Package httpd-2.2.15-5.el6.centos.i686 already installed and latest version

Nothing to do

如果看到上面的信息,说明系统已经安装了Apache

启动Apache /etc/init.d/httpd start

重启Apache /etc/init.d/httpd restart

设为开机启动 chkconfig httpd on

chkconfig –levels 3 httpd on(设置在运行级别3,即使命令行模式下自动启动)

chkconfig --list httpd (查看当前 httpd service 被配置在哪几个运行级别自启动)

备注:Apache启动之后会提示错误:

正在启动 httpd:httpd: Could not reliably determine the server's fully qualif

domain name, using ::1 for ServerName

解决办法:是因为DNS没配置好. 如果不想配置DNS, 就在httpd.conf , 修改 ServerName localhost:80 即可

特别说明:CentOS 6.0 如果是默认Desktop安装的话,系统已经默认安装了Apache,只需要设置为开机启动即可。

二、安装MySQL

1、检查是否已安装MySQL

rpm -qa|grep mysql

2、安装MySQL

yum install mysql mysql-server

询问是否要安装,输入Y即可自动安装,直到安装完成。

启动MySQL /etc/init.d/mysqld start

设为开机启动 chkconfig mysqld on

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷贝配置文件(注意:/etc目录下面默认有一个my.cnf,直接覆盖即可)

3、为root账户设置密码

mysql_secure_installation

根据提示输入Y,回车

输入2次密码,回车

最后出现:Thanks for using MySQL!

MySql密码设置完成

重新正常启动 MySQL:

/etc/init.d/mysqld stop

/etc/init.d/mysqld start

/etc/init.d/mysqld restart

三、安装PHP5

1、检查是否已安装PHP5

rpm -q php

出现 package php is not installed

说明系统没有安装PHP5

2、安装PHP5

yum install php

根据提示输入Y直到安装完成

重启Apache /etc/init.d/httpd restart

说明:Apache 网站的默认文档的路径是 /var/www/html,在这个目录里新建一个php探针文件,http://localhost/浏览会显示很多 PHP5 的安装信息

cd /var/www/html

touch index.php

vi index.php

phpinfo();

?>

保存退出

ls -1显示出index.php文件

PHP5 正在工作,你会看到很多模块都可以在 PHP5 中使用了,而 MySQL 并没有在这里被列出来,

这意味着 PHP5 并不支持MySQL,你还需要安装 php-mysql 这个包。

3、安装PHP组件,使 PHP5 支持 MySQL 系统运维 温馨提醒:qihang01原创内容版权所有,转载请注明出处及原文链接

yum search php 搜索php模块,挑选那些你需要的模块,安装。

yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

这里选择以上安装包进行安装

根据提示输入Y回车

重启MySql /etc/init.d/mysqld restart

重启Apche /etc/init.d/httpd restart

配置篇:

一、Apache配置

cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.confbak 修改之前先备份原文件

cp /etc/httpd/conf/httpd.confbak /etc/httpd/conf/httpd.conf 恢复备份文件

vi /etc/httpd/conf/httpd.conf 编辑文件

ServerTokens OS  ← 找到这一行,将“OS”改为“ProductOnly”(在出现错误页的时候不显示服务器操作系统的名称)

ServerTokens ProductOnly   ← 变为此状态

ServerSignature On  ← 找到这一行,将“On”改为“Off”

ServerSignature Off  ← 在错误页中不显示Apache的版本

Options Indexes FollowSymLinks  ← 找到这一行,删除“Indexes”,并添加“Includes”、“ExecCGI”,禁止列出目录

Options Includes ExecCGI FollowSymLinks  ← 允许服务器执行CGI及SSI

AddHandler cgi-script .cgi  ← 找到这一行,去掉行首的“#”,并在行尾添加“.pl”

AddHandler cgi-script .cgi .pl  ← 允许扩展名为.pl的CGI脚本运行

AllowOverride None  ← 找到这一行,将“None”改为“All”

AllowOverride All  ← 变为此状态,允许.htaccess

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined  ← 找到这一行

LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined  ← 改为此状态(添加“!414”到规则中,对于过长的日志不记录)

AddDefaultCharset UTF-8  ← 修改UTF-8为GB2312

AddDefaultCharset GB2312  ← (添加GB2312为默认编码)

Options Indexes MultiViews FollowSymLinks  ← 找到这一行,将“Indexes”删除

Options MultiViews FollowSymLinks  ← 变为此状态(不在浏览器上显示树状目录结构)

DirectoryIndex index.html index.html.var ← 找到这一行,修改默认首页文件

DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var ← 变为此状态(设置默认首页文件,增加index.php)

KeepAlive Off #修改为On 允许程序性联机

KeepAlive On

MaxKeepAliveRequests 100 #修改为1000 一次联机最大传输数量,0为不限制

MaxKeepAliveRequests 500

/etc/init.d/httpd restart #保存配置后重启

rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html 删除默认测试页

二、php配置

cp /etc/php.ini /etc/php.inibak #编辑之前先备份

vi /etc/php.ini

date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC

disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。

expose_php = Off #禁止显示php版本的信息

display_errors = OFF #关闭错误提示

register_globals = OFF #关闭注册全局变量

magic_quotes_gpc = On #打开magic_quotes_gpc来防止SQL注入

log_errors = On #记录错误日志

error_log = /var/log/php/error_log.log #设置错误日志存放目录,文件必须允许apache用户的和组具有写的权限

#(chown apache.apache /var/log/php/error_log.log)

open_basedir = .:/tmp/ #设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站

至此,CentOS 6.0 LAMP服务器(Apache+PHP5+MySQL)安装配置完成。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是在 CentOS 7 上安装 Zabbix 6.0、Nginx、MySQL 8、PHP 7.4 的步骤: 1. 安装 EPEL 和 Remi 源: ``` yum install -y epel-release rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm ``` 2. 安装 Nginx: ``` yum install -y nginx systemctl start nginx systemctl enable nginx ``` 3. 安装 PHP 7.4: ``` yum install -y php74-php-fpm php74-php-mysqlnd php74-php-xmlrpc php74-php-gd php74-php-intl php74-php-mbstring php74-php-soap php74-php-xml php74-php-json php74-php-zip systemctl start php74-php-fpm systemctl enable php74-php-fpm ``` 4. 安装 MySQL 8: ``` rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm yum install -y mysql-community-server systemctl start mysqld systemctl enable mysqld ``` 5. 配置 MySQL: ``` mysql_secure_installation ``` 6. 创建 Zabbix 数据库: ``` mysql -u root -p CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost'; FLUSH PRIVILEGES; EXIT; ``` 7. 导入 Zabbix 数据库: ``` cd /usr/share/doc/zabbix-server-mysql-6.0.0/ zcat create.sql.gz | mysql -u zabbix -p zabbix ``` 8. 安装 Zabbix Server 和 Agent: ``` yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent ``` 9. 配置 Zabbix: ``` vi /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=password ``` 10. 启动 Zabbix Server 和 Agent: ``` systemctl start zabbix-server zabbix-agent systemctl enable zabbix-server zabbix-agent ``` 11. 配置 Nginx: ``` vi /etc/nginx/conf.d/zabbix.conf server { listen 80; server_name localhost; root /usr/share/zabbix; location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/run/php74-php-fpm/zabbix.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ``` 12. 重启 Nginx: ``` systemctl restart nginx ``` 13. 打开浏览器,输入服务器 IP 地址,进入 Zabbix Web 界面,按照提示进行 Zabbix 配置即可。 注意:以上步骤仅供参考,具体操作根据实际情况进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值