Alibaba Cloud centOS7 installs MYSQL plus PHP plus Apache environment

不言
Release: 2023-03-23 19:50:02
Original
1496 people have browsed it

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
Copy after login

Start apache:

##

systemctl start httpd.service
设置开机自动启动:systemctl enable httpd.service
Copy after login



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
Copy after login
Restart apache to make php take effect
systemctl restart httpd.service
Copy after login

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

Code:

<?php phpinfo(); ?>
Copy after login

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
Copy after login
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
Copy after login
② yum install mysql-server
Copy after login
③ yum install mysql-devel
Copy after login
如果第②步没有可用的包则执行下面五个步骤(有则忽略):
Copy after login

                                                                                                                                                                           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
Copy after login


## Step 4: Check it out


            [root@master ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Copy after login

会获得两个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
Copy after login



然后,重启服务:


$ service mysqld restart
Copy after login


接下来登录重置密码:


$ mysql -u root
mysql > use mysql;
mysql > update user set password=password(&#39;123456&#39;) where user=&#39;root&#39;;
mysql > exit;
Copy after login


5. 开放3306端口



[plain] view plain copy


  1. service iptables start/stop
    Copy after login

会报错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
Copy after login


添加以下内容:


-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
Copy after login


保存后重启防火墙:


$ sudo service iptables restart
Copy after login


6. 创建普通用户并授权

示例(使用root用户登录):


mysql > use mysql;
Copy after login



mysql > grant all privileges on *.* to &#39;root&#39;@&#39;%&#39; identified by &#39;123456&#39;;mysql > flushn privileges;
Copy after login


相关推荐:

详解在阿里云上部署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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template