Home  >  Article  >  Backend Development  >  Alibaba Cloud centOS7 installs MYSQL plus PHP plus Apache environment

Alibaba Cloud centOS7 installs MYSQL plus PHP plus Apache environment

不言
不言Original
2018-04-14 10:53:061495browse

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



Enter the IP address of the server at this time, you should see the apache service page, you don’t need to enter the port, apache The default is to use port 80


## 2. Install PHP:

yum install php php-devel
Restart apache to make php take effect
systemctl restart httpd.service

At this time, you can create a PHP file in the directory: /var/www/html/

Code:

<?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
After installing the extension, you need to restart apache again

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


## Step 4: Check it out


            [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


  1. 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;


相关推荐:

详解在阿里云上部署PHP后端的方法

阿里云中安装Apache和PHP环境

阿里云如何搭建小程序PHP环境

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn