The content shared in this article is the installation of MYSQL plus PHP plus Apache environment on Alibaba Cloud centOS7. Now I share it with everyone. Friends in need can refer to the content of this article.
1.Install apache:
##
yum install httpd httpd-devel
Start apache:
##
systemctl start httpd.service 设置开机自动启动:systemctl enable httpd.service
yum install php php-devel
systemctl restart httpd.service
<?php phpinfo(); ?>
Then access this file, you can see some information about PHP. The path of the php.ini configuration file can be seen on this page
Install php extension
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
systemctl restart httpd.service
3. Install MYSQL and set up remote access
##① yum install mysql
② yum install mysql-server
③ yum install mysql-devel
如果第②步没有可用的包则执行下面五个步骤(有则忽略):
The wget command #: Download mysql's repo source
## Step 3: Install mysql-community- release-el7-5.noarch.rpm package
[root@master ~]# yum -y install wget
[root@master ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
第五步:安装mysql
[root@master ~]# yum install mysql-server
然后,重启服务:
$ service mysqld restart
接下来登录重置密码:
$ mysql -u root mysql > use mysql; mysql > update user set password=password('123456') where user='root'; mysql > exit;
5. 开放3306端口
[plain] view plain copy
service iptables start/stop
会报错Failed to start iptables.service: Unit iptables.service failed to load: No such file or directory.
CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理
firewall-cmd --zone= public --query-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=3306/tcp
如果firewall is not running
通过systemctl start firewalld开启防火墙,没有任何提示即开启成功。
firewall-cmd --permanent --zone=public --add-port=3306/tcp,提示success,表示设置成功,这样就可以继续后面的设置了。
$ sudo vim /etc/sysconfig/iptables
添加以下内容:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
保存后重启防火墙:
$ sudo service iptables restart
6. 创建普通用户并授权
示例(使用root用户登录):
mysql > use mysql;
mysql > grant all privileges on *.* to 'root'@'%' identified by '123456';mysql > flushn privileges;
相关推荐:
The above is the detailed content of Alibaba Cloud centOS7 installs MYSQL plus PHP plus Apache environment. For more information, please follow other related articles on the PHP Chinese website!