centos7下lamp快速搭建环境
2017-02-19 22:50
148 查看
一、配置防火墙
CentOS 7.0默认使用的是firewall作为防火墙。
1、关闭firewall:
[python] view plain copy
在CODE上查看代码片派生到我的代码片
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、关闭SELINUX
[python] view plain copy
在CODE上查看代码片派生到我的代码片
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
3.安装apache
[python] view plain copy
在CODE上查看代码片派生到我的代码片
yum install httpd #根据提示,输入Y安装即可成功安装
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
4.安装mariadb(mysql)
[python] view plain copy
在CODE上查看代码片派生到我的代码片
yum install mariadb mariadb-server #询问是否要安装,输入Y即可自动安装,直到安装完成
systemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动
[python] view plain copy
在CODE上查看代码片派生到我的代码片
修改mysql密码:set password for 'root'@'localhost'=password('root');
[python] view plain copy
在CODE上查看代码片派生到我的代码片
mysql授权远程连接(navicat等): grant all on *.* to root identified by 'root';
5、安装PHP以及组件,使PHP支持 MariaDB
[python] view plain copy
在CODE上查看代码片派生到我的代码片
yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#这里选择以上安装包进行安装,根据提示输入Y回车
systemctl restart mariadb.service #重启MariaDB
systemctl restart httpd.service #重启apache
测试篇
cd /var/www/html
vi index.php #输入下面内容
<?php
phpinfo();
?>
:wq! #保存退出
在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!
centos引导windos7
开机启动命令行 systemctl set-default multi-user.target
1.使用root身份(必须)打开 /boot/grub2/grub.cfg
2.找到 ### BEGIN /etc/grub.d/30_os-prober###
在后面添加
menuentry "Windows 7 (loader) (on /dev/sda1)"{
insmod ntfs
set root=(hd0,1)
chainloader +1
}
首先,在CentOS中建立用户www。
其次,在Apache配置文件httpd.conf中设置User,Group。
最后,设置网站文件的用户和用户组为www。
网站目录文件权限的设置对网站的安全至关重要,下面简单介绍网站目录文件权限的基本设定。
我们假设http服务器运行的用户和用户组是www,网站用户为centos,网站根目录是/home/centos/web。
1、我们首先设定网站目录和文件的所有者和所有组为centos,www,如下命令:
chown -R centos:www /home/centos/web
2、设置网站目录权限为750,750是centos用户对目录拥有读写执行的权限,这样centos用户可以在任何目录下创建文件,用户组有有读执行权限,这样才能进入目录,其它用户没有任何权限。
find -type d -exec chmod 750 {} \;
3、设置网站文件权限为640,640指只有centos用户对网站文件有更改的权限,http服务器只有读取文件的权限,无法更改文件,其它用户无任何权限。
find -not -type d -exec chmod 640 {} \;
4、针对个别目录设置可写权限。比如网站的一些缓存目录就需要给http服务有写入权限。例如discuz x2的/data/目录就必须要写入权限。
find data -type d -exec chmod 770 {} \;
CentOS 7.0默认使用的是firewall作为防火墙。
1、关闭firewall:
[python] view plain copy
在CODE上查看代码片派生到我的代码片
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、关闭SELINUX
[python] view plain copy
在CODE上查看代码片派生到我的代码片
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
3.安装apache
[python] view plain copy
在CODE上查看代码片派生到我的代码片
yum install httpd #根据提示,输入Y安装即可成功安装
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
4.安装mariadb(mysql)
[python] view plain copy
在CODE上查看代码片派生到我的代码片
yum install mariadb mariadb-server #询问是否要安装,输入Y即可自动安装,直到安装完成
systemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动
[python] view plain copy
在CODE上查看代码片派生到我的代码片
修改mysql密码:set password for 'root'@'localhost'=password('root');
[python] view plain copy
在CODE上查看代码片派生到我的代码片
mysql授权远程连接(navicat等): grant all on *.* to root identified by 'root';
5、安装PHP以及组件,使PHP支持 MariaDB
[python] view plain copy
在CODE上查看代码片派生到我的代码片
yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#这里选择以上安装包进行安装,根据提示输入Y回车
systemctl restart mariadb.service #重启MariaDB
systemctl restart httpd.service #重启apache
测试篇
cd /var/www/html
vi index.php #输入下面内容
<?php
phpinfo();
?>
:wq! #保存退出
在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!
centos引导windos7
开机启动命令行 systemctl set-default multi-user.target
1.使用root身份(必须)打开 /boot/grub2/grub.cfg
2.找到 ### BEGIN /etc/grub.d/30_os-prober###
在后面添加
menuentry "Windows 7 (loader) (on /dev/sda1)"{
insmod ntfs
set root=(hd0,1)
chainloader +1
}
首先,在CentOS中建立用户www。
代码如下 | 复制代码 |
groupadd www useradd --shell /sbin/nologin -g www www |
代码如下 | 复制代码 |
# # If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch. # # User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. # User www Group www |
代码如下 | 复制代码 |
#假设网站部署在/home/www下 cd /home/www/ chown -R www:www . //前者为群组名称,后者为用户名, *表示全部文件 |
我们假设http服务器运行的用户和用户组是www,网站用户为centos,网站根目录是/home/centos/web。
1、我们首先设定网站目录和文件的所有者和所有组为centos,www,如下命令:
chown -R centos:www /home/centos/web
2、设置网站目录权限为750,750是centos用户对目录拥有读写执行的权限,这样centos用户可以在任何目录下创建文件,用户组有有读执行权限,这样才能进入目录,其它用户没有任何权限。
find -type d -exec chmod 750 {} \;
3、设置网站文件权限为640,640指只有centos用户对网站文件有更改的权限,http服务器只有读取文件的权限,无法更改文件,其它用户无任何权限。
find -not -type d -exec chmod 640 {} \;
4、针对个别目录设置可写权限。比如网站的一些缓存目录就需要给http服务有写入权限。例如discuz x2的/data/目录就必须要写入权限。
find data -type d -exec chmod 770 {} \;
相关文章推荐
- linux开发环境的快速搭建
- Javascript编程环境快速搭建要点
- 关于Cygwin环境下快速搭建GTK+2.0开发环境的方法(原创)
- 使用wordpress在appache php mysql环境下快速搭建个人博客!!!
- centos系统使用yum快速搭建lamp环境
- QuickServer--在吵闹的环境里快速搭建自己的TcpServer(Pragmatic系列)
- Javascript编程环境快速搭建要点
- 主题:推荐一个eclipse插件:一键式快速搭建Struts2.0,SSH2环境
- Ruby on rails开发从头来(windows)(一)-使用InstantRails快速搭建Ruby On Rails开发环境
- 使用appfuse2.0快速搭建环境(myeclipse)
- 使用appfuse2.0快速搭建环境(myeclipse)1
- php学习日志081106- 快速搭建开发环境
- QuickServer--在吵闹的环境里快速搭建自己的TcpServer(Pragmatic系列)
- Eclipse3.4+Maven2+jetty6快速搭建web快速开发环境
- 使用appfuse2.0快速搭建环境(myeclipse)
- 快速搭建PHP开发环境WAMP+ZendStudio+ZendDebugger
- QuickServer--在吵闹的环境里快速搭建自己的TcpServer(Pragmatic系列)
- 快速搭建MogileFS 2.x测试环境
- 15.1 快速上手:关于搭建实验环境
- Java环境快速搭建(服务管理器)