CentOS 7 yum install LAMP, LNMP and build personal blog site WordPress

The experiment was set up to conduct LAMP and LNMP in CentOS7.2, environment 3.10.0-327.el7.x86_64 kernel version, and on top of this to make a WordPress blog site.

[root@Shining ~]# uname -a
Linux Shining.ACG 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@Shining ~]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)

First, tell us about LAMP and LNMP

LAMP

    LMAP namely Linux + Apache + Mysql / MariaDB + initials Perl / PHP / Python acronym. This is a group used to build dynamic Web sites or servers open source software. They themselves are separate programs, but because often used together, have a higher and higher degree of compatibility together to form a powerful Web application platform. With the vigorous development trend of open source, LAMP open source J2EE and .Net has been formed with the three pillars of business software, software development and lower the cost of investment in software, so the attention of the entire IT sector. From the site's traffic is more than 70% of traffic is to provide the LAMP, LAMP is the most powerful website solution.

Linux

    Linux is a free to use and free dissemination of Unix-like operating system, is a POSIX and UNIX-based multi-user, multi-tasking, multi-threading and multi-CPU support for the operating system. It can run major UNIX software tools, applications, and network protocols. It supports 32-bit and 64-bit hardware. Linux has inherited the Unix design idea to the network as the core, is a stable performance multi-user network operating system.

    The use CentOS is a distribution of Linux.

Apache  

    Apache HTTP Server (referred to as Apache) is an Apache Software Foundation open source web server that can run on most computer operating systems, because of its multi-platform security and is widely used, is the most popular Web server software of One. It is fast, reliable, and can be extended through a simple API, the Perl / Python interpreter like compiled into the server.

    When one of the programs of the main program called Apache httpd, which is why we need to install the experiment.

MySQL

    MySQL is a relational database management system, developed by the Swedish company MySQL AB, currently part of Oracle's products. The most popular MySQL relational database management system, MySQL WEB application is the best RDBMS (Relational Database Management System, a relational database management system) one application software. MySQL is a relational database management systems, relational database to store data in separate tables rather than putting all the data in a large warehouse, thus increasing the speed and improved flexibility. MySQL SQL language used is the most common standardized language used to access databases. MySQL software uses a dual licensing policy, which is divided into community and commercial versions, because of its small size, high speed, low cost of ownership, especially open source this feature, the development of small and medium websites have chosen MySQL as the database website . Because of its excellent performance version of the community, with PHP and Apache can form a good development environment.

    The experiment used MySQL database software is a branch of software, called MariaDB.

MariaDB MySQL database management system is a branch, mainly by the open source community in the maintenance, the purpose of using GPL licensed MariaDB is fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL. In terms of storage engine, use XtraDB (English: XtraDB) instead of MySQL's InnoDB.

php  

    PHP (English name: PHP: Hypertext Preprocessor, Chinese name: "Hypertext Preprocessor") is a versatile open source scripting language. Syntax absorbed the C language, Java, and Perl features conducive to learning, widely used, mainly for Web development. PHP syntax unique mix of C, Java, Perl and PHP own syntax. It can perform dynamic than the CGI or Perl pages more quickly. Compared with dynamic PHP pages made with other programming languages, PHP is embedded into HTML program (an application under the Standard Generalized Markup Language) document to execute, execute efficient than completely CGI generated HTML markup is much higher; PHP can also be performed after the compiled code, the compiler can optimize the code to achieve encryption and run, make the code run faster.

LNMP

    LNMP and LAMP difference is that using Nginx instead of Apache.

    Nginx is a lightweight Web server / reverse proxy server and e-mail (IMAP / POP3) proxy server, and released under a BSD-like agreement. The program developed by Russian designer Igor Sysoev, Russia for large-scale web portal and search engine Rambler (Russian: Рамблер) use. It features occupy less memory, high concurrency, the ability to do concurrent nginx fact the same type of web server performance is better.

Compare the advantages and disadvantages of Nginx and Apache

apache nginx relative advantages:

    Lightweight, also from the web service, than apache uses less memory and resources.

    Anti concurrent, non-blocking Nginx processing request is asynchronous, and the apache is blocked type, low resource consumption Nginx high performance can be maintained under high concurrency.

    Highly modular design, the preparation module is relatively simple.

    Community activists, all kinds of high-performance modules produced rapidly ah.

apache nginx relative advantages:

    rewrite, rewrite nginx powerful than the.

    Module over more basic thought can be found.

    Little bug, nginx relatively large number of bug.

    Super-stable.

WordPress

    WordPress is a PHP language development blog platform, users can set up their own Web site on the server that supports PHP and MySQL database. Can also WordPress as a content management system (CMS) to use. WordPress is a personal blog system, and gradually evolved into a content management system software, it uses the PHP language and MySQL database development. Users can use their blog on a server that supports PHP and MySQL database. There are many free WordPress templates developed by third parties, installation is easy to use. But to do its own template, you will need to have some expertise. For example, the HTML code in an application at least you want to know the Standard Generalized Markup Language, CSS, PHP and other related knowledge. WordPress supports Chinese official version, while lovers of Chinese language pack developed by a third party, such as wopus Chinese language pack. WordPress has thousands of kinds of plug-ins and countless theme template styles. 

Below officially entered the experimental stage

Linux, CentOS installation that is not repeated here.

Apache installation

    Apache package name is httpd, use yum install httpd:

[root@Shining ~]# yum install httpd

    After installing the httpd need to start, before you start, we look at the network situation:

[root@Shining ~]# ss -tl
State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port                
LISTEN     0      5      192.168.122.1:domain                   *:*                    
LISTEN     0      128        *:ssh                      *:*                    
LISTEN     0      128    127.0.0.1:ipp                      *:*                    
LISTEN     0      100    127.0.0.1:smtp                     *:*                    
LISTEN     0      32        :::ftp                     :::*                    
LISTEN     0      128       :::ssh                     :::*                    
LISTEN     0      128      ::1:ipp                     :::*                    
LISTEN     0      100      ::1:smtp                    :::* 
[root@Shining ~]# ss -tnl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      5      192.168.122.1:53                       *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      128    127.0.0.1:631                      *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      32          :::21                      :::*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      128        ::1:631                     :::*                  
LISTEN     0      100        ::1:25                      :::*

    80 ports can see http service is not in a listening state.

    Next, we start the httpd service:

[root@Shining ~]# systemctl start httpd

At this point, enter localhost in the browser appears Apache welcome page (here using CentOS 6.8 presentation, the same Cent OS 7 results):

Capture .PNG

MySQL

    CentOS 7 default installation of MariaDB, if not, then install the database software on the machine, you can use the following installed:

[root@Shining ~]# yum install mysql

After installing MySQL service is turned on:

[root@Shining ~]# systemctl start mariadb
[root@Shining ~]# ss -tl
State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port                
LISTEN     0      50         *:mysql                    *:*                    
LISTEN     0      5      192.168.122.1:domain                   *:*                    
LISTEN     0      128        *:ssh                      *:*                    
LISTEN     0      128    127.0.0.1:ipp                      *:*                    
LISTEN     0      100    127.0.0.1:smtp                     *:*                    
LISTEN     0      128       :::http                    :::*                    
LISTEN     0      32        :::ftp                     :::*                    
LISTEN     0      128       :::ssh                     :::*                    
LISTEN     0      128      ::1:ipp                     :::*                    
LISTEN     0      100      ::1:smtp                    :::*                    
[root@Shining ~]# ss -tnl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      50           *:3306                     *:*                  
LISTEN     0      5      192.168.122.1:53                       *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      128    127.0.0.1:631                      *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128         :::80                      :::*                  
LISTEN     0      32          :::21                      :::*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      128        ::1:631                     :::*                  
LISTEN     0      100        ::1:25                      :::*

We can see, MySQL service is turned on, listening 3306 port.

Enter MariaDB

[root@Shining ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Display Database

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| db_name            |
| mysql              |
| performance_schema |
| test               |
| testdb             |
+--------------------+
6 rows in set (0.00 sec)

MariaDB [(none)]>

Create a database:

MariaDB [(none)]> create database db_name;

Switch databases:

MariaDB [(none)]> use db_name
Database changed
MariaDB [db_name]>

Create a user: format to create user 'username' @ 'which allows users to host landing' identified by 'password'

    % Means that the host does not limit the landing.

MariaDB [db_name]> create user 'username'@'%' identified by '123456';

Give permission for the user:

MariaDB [db_name]> grant all privileges to 'username'@'%';

Displaying user permissions:

MariaDB [(none)]> show grants for 'username'@'%';
+---------------------------------------------------------------------------------------------------------+
| Grants for username@%                                                                                   |
+---------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'username'@'%' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' |
| GRANT ALL PRIVILEGES ON `db_name`.`db_name` TO 'username'@'%'                                           |
+---------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

Exit Database:

MariaDB [db_name]> exit
Bye

Preparations complete database.

Then be php installation:

[root@Shining ~]# yum install php php-mysql

Httpd service came after the main installation directory

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

Edit the file phpinfo.php

[root@localhost html]# vim phpinfo.php

Says:

<?php
echo phpinfo();

Save and exit. Then, open a browser, enter the host ip / phpinfo.php you can see information about PHP:

Capture 2.PNG

Next, download WordPress:

Available at https://cn.wordpress.org/wordpress-4.5.3-zh_CN.tar.gz

[root@localhost html]# wget https://cn.wordpress.org/wordpress-4.5.3-zh_CN.tar.gz

Decompression,

[root@localhost html]# tar xvf wordpress-4.5.3-zh_CN.tar.gz

Obtained wordpress folder, copy the contents of the folder at / var / www / html, which has a wp-config-sample.php, the file is wordpress profile. Copy as wp-config.php to take effect.

Editing wp-config.php:

// ** MySQL settings - specific information from the host you are using ** // 
name / ** WordPress database * / 
the DEFINE ( 'DB_NAME', 'database_name_here'); 

/ ** MySQL database username * / 
the DEFINE ( 'DB_USER', 'username_here'); 

/ ** MySQL database password * / 
the DEFINE ( 'DB_PASSWORD', 'password_here'); 

/ ** MySQL host * / 
the DEFINE ( 'DB_HOST', 'localhost'); 

/ ** create the default character encoding data table * / 
DEFINE ( 'db_charset', 'UTF8'); 

/ ** database finishing type. If in doubt, do not change * / 
the DEFINE ( 'DB_COLLATE', '');

The documents in the database_name_here, username_here, password_here, localhost, respectively, into the database name, database user name, password database, database host. Save and exit will take effect.

Next, enter wordpress host address in the browser, you can access wordpress:

Capture 3.PNG

This is a page prompts the user to enter information in the database, if the user does not wp-config.php file configured, this page will appear.

Capture 4.PNG

Here enter the database information submitted;

blob.png

Welcome page, enter the title information, user name and password. Click install WordPress.

blob.png
blob.png

Next, install and configure the Nginx.

First of all, php a php-fpm need to install the software:

[root@localhost wordpress]# yum install php-fpm

Start php-fpm:

[root@localhost wordpress]# service php-fpm start

Install Nginx:

[root@localhost yum.repos.d]# yum install nginx

Configuration Nginx configuration file /etc/nginx/nginx.conf

[root@Shining /var/www/html]# vim /etc/nginx/nginx.conf

Add or modify the following:

server {
        listen       80; 
        server_name  172.16.253.159;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / { 
            root   /var/www/html;
            index  index.html index.htm index.php;
        }   
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           /var/www/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
     }

Restart Nginx, restart php-fpm

[root@localhost yum.repos.d]# service nginx restart
Stopping nginx:                                            [FAILED]
Starting nginx:                                            [  OK  ]
[root@localhost yum.repos.d]# service php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]

Note To turn off before starting the httpd service Nginx, because both use port 80 can cause conflicts.

Visit this site:

blob.png

Note that if php-fpm service is not started, the following error occurs:

blob.png

to sum up:

The experiment yum installed, all the lower level of technology. During the experiment many times there is a problem, but fortunately resolved.

The following are some of the problems.

1, yum source of the problem. There is no built-in CentOS yum Nginx, add the repo own files. However, the implementation of a yum clean all, yum makecache. Giving rise to a problem, because there is a point source cdrom, but could not find, I mount the cdrom, still go wrong. Then check the autofs service, normal. Later found to be the image file is broken ......

2, Apache and Nginx difference. At the beginning of the experiment, I swing between Apache and Nginx, I do not know the difference between these two, so he tried again. Apache is very simple, good start to install the service can be used. But also need to configure Nginx, I'm stuck here for a long time. Because it is yum install the path of all profiles with online tutorials speak differently, it took a long time to find the configuration file. And then it took a long time to configure. Finally, since there is no start php-fpm, resulting in an error. Results It took a long time to find the cause of the error that makes you go crazy.

3, MySQL problems. Initially forgot command. I went back to watch the video to learn. Results of the first to add a user no added successfully. Wordpress has led to an error. Second, wordpress by the error, no error after the restart. The reason still do not know.

4, when writing blog computer problem, lost half of the content (cry blind) after the restart. After a certain while writing save!

Original article, author: wangshuai, should the reprint, please indicate the source: http: //www.178linux.com/60558

Guess you like

Origin www.cnblogs.com/ricksteves/p/11875831.html
Recommended