Distributed Installation lnmp environment

Install nginx

  1. 1

    which nginx # to see if there is nginx

    Installation structures lnmp environment centos / linux

  2. 2

    yum list nginx # listed nginx

    install nginx yum install nginx #

     Occurs is this ok [Y / N] Period: Enter y

    # Saw {Complete!} Installed successfully.

    Installation structures lnmp environment centos / linux

  3. 3

    which nginx # to see if there is nginx

     

    service nginx start # start nginx process method [1]

    /etc/init.d/nginx start # start nginx process method [2]

     

     The method [1] or [2] may be optionally substituted, in the process of starting the service may be given

    Starting nginx: nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) [FAILED]

    Solution: Modify the nginx configuration

                     cd /etc/nginx/conf.d/

                      vi default.conf

                      I carried out by keyboard editing state, the [::]: 80 in front of this line add "#" indicates a comment that line, and then press the Esc key keyboard, and finally enter: wq (save and exit)

                      Restart nginx process (method [1] or [2])

     

    ps -ef | grep nginx # View nginx process

    Installation structures lnmp environment centos / linux

    Installation structures lnmp environment centos / linux

  4. 4

    curl members.3322.org/dyndns/getip # View external IP

    Enter the IP you see in the browser can display the welcome page represent nginx nginx has been successfully installed

    If it does not appear likely that the firewall is not open port 80

    Solution:

    /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT

    /etc/rc.d/init.d/iptables save

    /etc/init.d/iptables restart

    You can also turn off the firewall: service iptables stop

    Under normal circumstances just rent a server firewalls are closed

    Installation structures lnmp environment centos / linux

    END

Install php

  1. 1

    yum -y install php php-fpm # install php and php-fpm package

    # Saw {Complete!} Installed successfully.

    Installation structures lnmp environment centos / linux

  2. 2

    Start php-fpm:

    /etc/init.d/php-fpm start                    #1

    service php-fpm start                         #2

    Installation structures lnmp environment centos / linux

  3. 3

    Nginx modify PHP configuration file so that the request is forwarded to the php-fpm bound ip and port:

    we /etc/nginx/conf.d/default.conf

     

    The bottom of which an input; the server {}

     

       location ~ \.php$ {

                fastcgi_pass   127.0.0.1:9000;

                fastcgi_index  index.php;

                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

                include        fastcgi_params;

       }

    Enter: wq to save and exit

    Installation structures lnmp environment centos / linux

  4. 4

    [Emphasis] to restart nginx:

    service nginx restart

    --------------------------------------------------

    Verify that PHP file to process the request:

    we /usr/share/nginx/html/info.php

    <?php

       phpinfo();

    ---------------------------------------------------

    Access IP address:

    http: // extranet IP / info.php

    Installation structures lnmp environment centos / linux

    END

Install mysql

  1. yum -y install mysql mysql-server # does not need to be prompted to install

    # Saw {Complete!} Installed successfully.

    Installation structures lnmp environment centos / linux

  2. service mysqld start # start mysql server

     

    mysqladmin -u root password 123456 # 123456 into the password you want to set

     

    Log mysql test

     mysql -u root -p Enter password: (set your own password) which is followed by the user name -u, -p asked for a password, enter the password to enter the password at the Enter.

     

    Ctrl-C -! Exit # exit the terminal

    Installation structures lnmp environment centos / linux

  3. Php extension mounting operation to mysql

     

    yum -y install php-mysql # php-mysql mounting extension

     

     service php-fpm restart # restart php-fpm process

    Installation structures lnmp environment centos / linux

  4. Check if you can operate by php mysql database:

     

    we /usr/share/nginx/html/dbConnect.php

     

    <?php

      @mysqli_connect ( "localhost", "root", "mysql password you set", "mysql") or die ( "connect mysql failed \ n");

      echo "connect ok\n";

     

    http: // extranet IP / dbConnect.php # executes in the browser

    Installation structures lnmp environment centos / linux

  5.  

Released eight original articles · won praise 13 · views 60000 +

Guess you like

Origin blog.csdn.net/qq_37655695/article/details/78019072
Recommended