Lnmp and Lamp in centos7.0

Source: Internet
Author: User

Lnmp and Lamp in centos7.0

First configure the firewall
CentOS 7.0 uses firewall as the firewall by default.
1. Disable firewall:

Systemctl stop firewalld. service # stop firewall systemctl disable firewalld. service # disable firewall startup

2. Disable SELINUX

Vi/etc/selinux/config # SELINUX = enforcing # comment out SELINUX = disabled # Add: wq! # Save and exit setenforce 0 # Make the configuration take effect immediately
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 # start nginx systemctl stop nginx. service # stop systemctl restart nginx. service # restart systemctl enable nginx. service # Set startup

3. Change the nginx port number (based on your needs)

Cd/etc/nginx/conf. d/vim default. conf change listen 80 to listen 81 and restart nginx systemctl restart nginx. service # restart nginx

4. visit http: // ip: 81 to view the nginx homepage. 5. install PHP-fpm in the next step.

Yum install php-fpm after installing systemctl start php-fpm.service # start php-fpm systemctl enable php-fpm.service # Set boot start

6. Change the nginx configuration file to identify php vi/etc/nginx/conf. d/default. conf. Remove the previous # And change 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. Access test. php

Create a test. php file in/usr/share/nginx/html. <? Php echo 123;?> Access http: // ip: 81/test. php to view the php page in nginx.

8. load configuration

Go to vi/etc/nginx/conf. d/default. conf

    upstream site{              server 172.16.170.138;              server 172.16.170.139;      }      server {          listen       80;          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 above site and localhost to www.a.com for domain name modification.

Lamp installation

1. install apache

Yum install httpd # Enter Y as prompted to install systemctl start httpd. service # start apache systemctl stop httpd. service # Stop apache systemctl restart httpd. service # restart apache systemctl enable httpd. service # Set apache startup
  • 1
  • 2
  • 3
  • 4
  • 5

2. Install mariadb (MySQL)

Yum install mariadb-server # ask if you want to install it. Enter Y to install it automatically until systemctl start mariadb is installed. service # Start MariaDB systemctl stop mariadb. service # Stop MariaDB systemctl restart mariadb. service # restart MariaDB systemctl enable mariadb. service # Set startup

3. Change the mysql password. It is blank by default after installation.

Modify the 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 the components so that PHP supports MariaDB

Yum install php-mysql php-gd libjpeg * php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash # select the above installation package here install, enter Y and press ENTER systemctl restart mariadb as prompted. service # restart MariaDB systemctl restart httpd. service # restart apache

5. Access Test

Cd/var/www/htmlvi index. php # enter the following content <? Php phpinfo ();?> : Wq! # Save and exit

Enter the Server IP address in the browser of the client. The configuration information shown in is displayed!

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.