星空网 > 软件开发 > 操作系统

Centos7下搭建LAMP平台环境 (转载)

 1.启用Apache(httpd)

Centos7默认已经安装httpd服务,只是没有启动。如果你需要全新安装,可以yum install -y httpd

启动服务:systemctl start httpd.service

设置开机自动启动:systemctl enable httpd.service

HTTP服务器已经启动,进行一下简单配置

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

     
#添加,在错误页中显示Apache的版本,Off为不显示 

ServerSignature On  

     #修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录) 

Options Indexes FollowSymLinks  

#AddHandler cgi-script .cgi #修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)

AllowOverride None  #修改为:AllowOverride All (允许.htaccess)

AddDefaultCharset UTF-8 #修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)

#Options Indexes FollowSymLinks   #修改为 Options FollowSymLinks(不在浏览器上显示树状目录结构)

DirectoryIndex index.html   #修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php(设置默认首页文件,增加index.php)

MaxKeepAliveRequests 500  #添加MaxKeepAliveRequests 500 (增加同时连接数)

:wq! #保存退出

systemctl restart httpd.service #重启apache 

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

2.设置防火墙

Centos7下的防火墙已经由iptables改为firewall,使用firewall-cmd命令开放80及443端口:

firewall-cmd –permanent –zone=public –add-service=http

firewall-cmd –permanent –zone=public –add-service=https

firewall-cmd –reload

设置SELinux为permissive模式 命令行下 setenforce 0 立即生效,重启失效。

编辑 vim/etc/sysconfig/selinux  SELinux=enforcing 修改为disabled 关闭SELinux,重启永久生效。

笔者ip为192.168.1.108,测试下服务器能否打开,浏览器http://192.168.1.108回车后看到欢迎页面,说明服务器正常运行。

3.安装MariaDB数据库

CentOS 7.0中,已经使用MariaDB替代了MySQL数据库,原因你懂的,MYSQL被Oracle收购以后,前景堪忧,所以MYSQL兄弟MariaDB就出来了,继续开源事业。

安装:yum -y install mariadb-server mariadb

启动:systemctl start mariadb.service

      systemctl enable mariadb.service

配置:cp /usr/share/mysql/my-huge.cnf /etc/my.cnf  覆盖原配置就好了。

设置数据库管理员密码:mysql_secure_installation   一路y就可以了,当然第一次y后面要输入两次密码。

4.安装PHP5

安装PHP主程序: yum -y install php

安装PHP组件,使PHP支持 MariaDB

yum -y install php-gd php-ldap php-odbc php-pear php-

重启: systemctl restart httpd.service

配置: vi /etc/php.ini

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

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

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

short_open_tag = ON #支持php短标签

open_basedir = .:/tmp/  #设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题(例如:织梦内容管理系统),可以注销此行,或者直接写上程序的目录/data/www.osyunwei.com/:/tmp/

测试一下:vi /var/www/html/index.php  输入<?php phpinfo(); ?>  wq保存退出。打开http://192.168.1.108 如果能看到PHP配置信息页,说明PHP服务器正常。

至此,LAMP平台就搭建好了,您可以在上面搭建Worldpress网站了,当然,如果你觉得数据库管理起来比较麻烦的话,也可以用yum install phpMyAdmin安装图形化管理工具。




原标题:Centos7下搭建LAMP平台环境 (转载)

关键词:Centos

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

中国邮政国际小包:https://www.goluckyvip.com/tag/102505.html
中国国际邮政小包:https://www.goluckyvip.com/tag/102506.html
美国 国际小包:https://www.goluckyvip.com/tag/102507.html
国际小包价格查询:https://www.goluckyvip.com/tag/102508.html
寄国际包裹多少钱一公斤:https://www.goluckyvip.com/tag/102509.html
中国国际小包:https://www.goluckyvip.com/tag/102510.html
丽人丽妆2023年扭亏为盈 玉容初、美壹堂等自有品牌增速超40% :https://www.kjdsnews.com/a/1836576.html
一天拿下10万美金预售!深圳大卖出海第一年成为亚马逊供应商:https://www.kjdsnews.com/a/1836577.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流