Baidu cloud server Centos-7.2 deployment LAMP environment

This article describes how to use the system to build centos 7.2 LAMP environment. centos7.2 structures LAMP following steps.  https://cloud.baidu.com/doc/BCC/s/Jjytjj2ru

1. Configure the firewall

CentOS 7.0 system than using a firewall as the default firewall

Close firewall:

systemctl stop firewalld.service    #停止firewall   
systemctl disable firewalld.service      #禁止firewall开机启动  

2. Install and configure apache

(1) can be used directly in the server comes yum source installation.

yum install -y httpd

(2) start httpd

systemctl start httpd

(3) view and access
can view the port 80 has been opened, use public IP can also open the apache default home page by netstat -anplt.

BCC-LAMP-01.png

BCC-LAMP-02.png

3. Install php and dependent extension, and open php

(1) install php environment.

yum install -y php

(2) mounting extensions

yum install -y php-gd php-mysql libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

(3) modify the apache configuration file

Can be viewed by apache httpd -V command to the default configuration file:/etc/httpd/conf/httpd.conf

BCC-LAMP-03.png

vim /etc/httpd/conf/httpd.conf

After adding the DirectoryIndexindex.php

In the config file, add on:

 LoadModule php5_module modules/libphp5.so

 AddType application/x-httpd-php .php

BCC-LAMP-04.png

(4) restart apache, and access the test.

systemctl restart httpd

Enter default with apache directory / var / www / html /, write phpinfo file.

vim /var/www/html/test.php

 <?php
         phpinfo();
 ?>

At this time, by ip / index.php to see

BCC-LAMP-05.png

4. Install mysql, and to verify the connection php

Above (1) centos7 system default database MariaDB, mysql need to download the installation source.

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm  
rpm -ivh mysql-community-release-el7-5.noarch.rpm  
yum install -y mysql-community-server  

After successful installation restart mysql service:
systemctl start mysqld

(2) after installation mysql database password is not authorized to enter the database, set a password.

mysql -u root  
mysql> use mysql;  
mysql> update user set password=PASSWORD("这里输入root用户密码") where user='root';  
mysql> flush privileges;  
mysql> exit  

(3) write code to test whether php mysql can connect and access.

vim /var/www/html/index.php

<?php  
$link=mysql_connect("localhost","root","刚才所设置的数据库密码");  
if(!$link) echo "FAILD!error";  
else echo "OK!You succeeded.";  
?>  

Use this time IP/index.php, you can see

BCC-LAMP-06.png

At this point, based on centos7.2 system installed LAMP environment have all been set up is completed.

Guess you like

Origin www.cnblogs.com/try-chi/p/12081373.html