Centos7.0 's LNMP and lamp are detailed _linux

Source: Internet
Author: User
Tags fpm install php

The LNMP and lamp of centos7.0

First configure the firewall

CentOS 7.0 uses firewall as a firewall by default

1. Close firewall:

  Systemctl Stop Firewalld.service #停止firewall 
  

2. Close SELinux

Vi/etc/selinux/config 
#SELINUX =enforcing #注释掉 
selinux=disabled #增加 
: wq! #保存退出 
setenforce 0 #使配置立即生效

LNMP Installation

1. Install Nginx

Yum install yum-priorities-y 
wget http://nginx.org/packages/centos/7/noarch/RPMS/ nginx-release-centos-7-0.el7.ngx.noarch.rpm 
rpm-ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm 
Yum Install Nginx 

2. Start Nginx

Systemctl start Nginx.service #启动nginx 
systemctl stop nginx.service #停止 
systemctl restart Nginx.service #重启 
Systemctl Enable Nginx.service #设置开机启动 

3. Change the Nginx port number (depending on your needs)

cd/etc/nginx/conf.d/ 
vim default.conf 
Listen 80 converted to listen I 
then restart Nginx 
systemctl Nginx.service #重启nginx 

4. Visit http://ip:81 to see Nginx home

5. Next Installation PHP-FPM

Yum install php-fpm 
after installation
systemctl start Php-fpm.service #启动php-fpm systemctl 
enable Php-fpm.service # Setting up Boot 

6. Change the Nginx profile to identify the PHP vi/etc/nginx/conf.d/default.conf, put the previous # to remove the can, conveniently change the Fastcgi_param

 Location ~ \.php$ { 
    root      html; 
    Fastcgi_pass  127.0.0.1:9000; 
    Fastcgi_index index.php; 
    Fastcgi_param script_filename/usr/share/nginx/html/$fastcgi _script_name; 
    Include    fastcgi_params; 
  } 

7. Visit test.php

Create a new test.php <?php echo 123 in/usr/share/nginx/html;? >

visit http://ip:81/test.php to see the PHP page in Nginx

8. Load Configuration

Enter vi/etc/nginx/conf.d/default.conf

  Upstream site{ 
      server 172.16.170.138; 
      Server 172.16.170.139; 
  } 
  server { 
    listen    ; 
    server_name localhost; 

    #charset Koi8-r; 
    #access_log/var/log/nginx/log/host.access.log main; 

    Location/{ 
      root  /usr/share/nginx/html; 
      Index index.html index.htm; 
      Proxy_pass http://site; 
    } 

9. Change the name of the above Site,localhost to www.a.com

Lamp installation

1. Install Apache

Yum Install httpd #根据提示, enter y installation to successfully install 
  systemctl start Httpd.service #启动apache 
  systemctl Stop Httpd.service # Stop the Apache 
  systemctl restart Httpd.service #重启apache 
  systemctl enable Httpd.service #设置apache开机启动 

2. Install mariadb (MySQL)

 Yum Install mariadb mariadb-server #询问是否要安装, enter Y to install automatically until the installation is complete 
  systemctl start Mariadb.service #启动MariaDB 
  Systemctl Stop Mariadb.service #停止MariaDB 
  systemctl restart Mariadb.service #重启MariaDB 
  systemctl Enable Mariadb.service #设置开机启动 

3. Modify the MySQL password, the default is empty after installation

Modify MySQL Password: Set password for ' root ' @ ' localhost ' =password (' root ');

MySQL Authorized remote connection (NAVICAT, etc.): Grant all on *.* to root identified by ' root ';

4. Install PHP and components to enable PHP to support MARIADB

Yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash< c1/> #这里选择以上安装包进行安装, enter y return 
systemctl restart Mariadb.service #重启MariaDB systemctl restart 
httpd.service Restart Apache

5. Access Test

cd/var/www/html
vi index.php #输入下面内容
 <?php
  phpinfo ();
? >
: wq! #保存退出

Enter the server IP address in the client browser and see the relevant configuration information as shown in the following figure!

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.