centos7.0 lnmp环境搭建手册
发布时间:2017-04-14 09:10 | 发布者:香港葡京赌侠诗 | 浏览次数:次
Centos7.5 lamp安装手册
yum安装ftp、apache、mysql、php
1、安装ftp
yum install vsftpd 实行安装ftp命令
systemctl start vsftpd.service开始ftp服务
systemctl enable vsftpd.service 设置为开机启动
2、安装apache
yum install httpd httpd-devel
2.1安装完成后,启动apache服务
systemctl start httpd.service
2.2设置开机自动启动
Systemctl enable httpd.service
3、安装mysql数据库
Centos7及以上版本开始使用mariadb数据库新的安装需要rpm或者第三方下载方式安装:
3.1下载mysql: wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
3.2 添加mysql:rpm -ivh mysql-community-release-el7-5.noarch.rpm
3.3 查看mysql版本:yum repolist all | grep mysql
3.4 通过一下语句启动某些版本: yum-config-manager --disable mysql56-community
3.5 启动mysql服务:systemctl start mysqld.service
3.6 设置开机启动:systemctl enable mysqld.service
3.7 添加远程用户,并授权:
CREATE USER 'apple'@'%' IDENTIFIED BY 'apple';
GRANT ALL PRIVILEGES ON *.* TO 'apple'@'%' IDENTIFIED BY 'apple' WITH GRANT OPTION;
刷新使授权生效:
flush privileges;
3.8 设置默认字符集编码:
default-character-set=utf8
3.9 备份还原数据库
备份: mysqldump --socket=/var/lib/mysql/mysql.sock --single-transaction=TRUE -u root -p test> test.sql
还原: mysql --socket=/var/lib/mysql/mysql.sock -u root -p test< test.sql
3.10 安装php
卸载yum remove php php-*以前版本
配置安装源rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
实行安装:
yum -y install php56w.x86_64
yum -y --enablerepo=webtatic install php56w-devel
yum -y install php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-opcache.x86_64
4、修改apache配置文件:
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
<IfModuledir_module>
DirectoryIndex index.php index.html
</IfModule>
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddTypeapplication/x-httpd-php .php
开启80和3306端口:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
重启防火墙:systemctl restart firewalld.service