centos yum setup linux+apache+mysql+php environment tutorial

  • 2020-05-12 06:40:32
  • OfStack

We use yum in linux system to install Apache+MySQL+PHP, which is very simple. It only takes a few steps to complete. The details are as follows:

1. Script YUM source installation:

1.yum install wget # install the download tool wget
2. wget http: / / www atomicorp. com installers/atomic # download atomic yum source, configuration CentOS yum 6.5 third party source
3. sh./atomic # script execution
4. yum check-update # updates the yum package

2. Installation of the 163yum source

1. Enter the yum source configuration directory

cd /etc/yum.repos.d

2. Backup the system's own yum source

mv CentOS-Base.repo CentOS-Base.repo.bk

3. Download the yum source of 163 netease:

centos7.x:

wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

centos6.x:

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

4. After updating the yum source, execute the following command to update the yum configuration for immediate effect

yum makecache

3. Add ali yum update source code:

1. Install wget:

yum install wget -y

2. Back up your original image files so you can restore them if something goes wrong.

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
3. Download new CentOS - Base. repo to/etc/yum repos. d /

CentOS 5:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4. Then rebuild the cache:

yum clean all

yum makecache

4. Install and configure MySQL

1. Execute yum to install MySQ

yum -y install mysql mysql-server

2. Add MySQL into the boot item and start MySQL immediately

chkconfig --levels 235 mysqld on # restart the automatic startup service
service mysqld start # restart mysql service

3. Set the password of MySQL root account

mysql_secure_installation

Press enter and enter Y as prompted

Enter the password twice and press enter

Enter Y 1 way as prompted

Last: Thanks for using MySQL!

The MySql password is set. Restart MySQL

service mysqld start

[root@localhost ~]# netstat -tulpn | grep -i mysql

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1723/mysqld

5. Install Apache

1. Install Apache using the yum command

yum � y install httpd

2. Set to boot Apache

chkconfig --levels 235 httpd on

3. Start Apache

service httpd start

4. Now directly type http://localhost or http:// native IP in your browser and you should see the Apache test page

Install the apache 1 extension ###

[root@localhost ~]# yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

6. Install configuration PHP

1. Install PHP using the yum command

[root@localhost ~]# yum -y install php php-mysql
[root@localhost ~]# yum -y install gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap
Install the php common extension

2. Restart the Apache server

[root@localhost ~]# service httpd restart
ps:apache default website directory /var/www/html

Then we provide php page for testing


[root@localhost ~]# cd /var/www/html/

[root@localhost html]# vi index.php

<?php

 phpinfo();

?>

7. Install configuration phpMyAdmin

After installing MySQL, Apache and PHP, we can install phpMyAdmin for visual management of MySQL database.

To its website to download the latest version: http: / / www phpmyadmin. net/home_page /

Under Windows, Navicat is also a very useful visualization tool for MySQL. It is recommended to use it.

[root@localhost ~]# unzip phpMyAdmin-4.2.6-all-languages.zip

[root@localhost ~]# mv phpMyAdmin-4.2.6-all-languages /var/www/html/phpmyadmin

[root@localhost ~]# cd /var/www/html/phpmyadmin

[root@localhost ~]# cp libraries/config.default.php config.inc.php

[root@localhost ~]# vi cnfig.inc.php

$cfg [' PmaAbsoluteUri] = ' '; Fill in the visit url of phpMyAdmin here.

$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address

$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port

$cfg [' Servers] [$i] [' user] = 'root'; // fill in the MySQL user name used by MySQL to access phpMyAdmin. The default is root.

fg [' Servers] [$i] [' password] = ' '; // fill in the password corresponding to the MySQL user name above.

Then restart the httpd service

[root@localhost ~]# service httpd restart

In the browser type http: / / localhost phpmyadmin can access.

If you encounter access problems, check SElinux.


Related articles: