CentOS65 builds LNMP

WBOY
Release: 2016-08-08 09:24:22
Original
919 people have browsed it

1: View environment:

1

2

[root@10-4-14-168 html]# cat /etc/redhat-release

CentOS release 6.5 (Final)

2: Turn off the firewall

1

[root@10-4-14-168 html]# chkconfig iptables off

3: Configure CentOS 6.0 third-party yum source (there is no nginx package in the default standard source of CentOS)

1

#wget http://www.atomicorp.com/installers/atomic

1

#sh ./atomic

1

#yum -update

4: Install development packages and library files

1

2

3

4

#yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng

libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel

gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2

libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

5: Uninstall installed apache, mysql, php

1

2

3

# yum remove httpd

# yum remove mysql

# yum remove php

6: Install nginx

1

2

3

4

# yum install nginx

# service nginx start

# chkconfig --levels 235 nginx on

//Set level 2, 3, and 5 to boot

7:安装mysql

1

2

3

# yum install mysql mysql-server mysql-devel

# service mysqld start

# chkconfig --levels 235 mysqld on

1

2

3

4

5

6

7

8

Log in to MySQL to delete the empty user and change the root password

mysql>select user,host,password from mysql.user; t;

drop

user ''@ localhost;

mysql>update mysql.user set password = PASSWORD('*********' ) where user='root';

mysql>flush privileges;

Also Provide a method to change the database user password:

mysqladmin -u root password "123456" //Set a password for the root user

service mysqld restart

8: Install php

1

2

# yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap

php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap

//Install php and required components to make PHP support MySQL and FastCGI mode

1

#yum install php-tidy php-common php-devel php-fpm php-mysql

1

2

# service php-fpm start

# chkconfig --levels 235 php-fpm on

9: Configure nginx to support PHP 7

8

9

10 # mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

/

/

Change the configuration file to a backup file

# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf

/

/

Since you have to write the original configuration file yourself, you can use the default configuration file as the configuration file

/

/

Modify nginx configuration file and add fastcgi support

# vi /etc/nginx/nginx.conf

index index.php index.html index.htm;

/

/

Join index.php

location ~ .php$ {

            root           /usr/share/nginx/html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

                                                                                                      SCRIPT_FILENAME​​​​​​​​​​​​​ include fastcgi_params;    }//Remove the comments from the above code and modify it to the nginx default path

10: Configure php

12

//Edit the file php.ini and add cgi.fix_pathinfo at the end of the file = 1
[root@CentOS ~]# vi /etc/php.ini

11: Restart nginx php-fpm

1

2

# service nginx restart
# service php-fpm restart

# vi /usr/share/nginx/html/info.php

phpinfo();

?>

13 : Test whether nginx parses php

12

Local browser input: 127.0.0.1/info.php
Display php interface The environment is set up successfully

14: Test whether mysql is installed successfully
<?php
    $link = mysql_connect("localhost","root","mysql密码");
    if (!$link){
    <span style="white-space:pre">	</span>die('Could not connect: ' . mysql_error());
    }else{
Copy after login
<span style="white-space:pre">	</span> echo "Mysql已经正确配置";
Copy after login
    }
    mysql_close($link);
?>
Copy after login
The page shows: Mysql has been correctly configured mysql installation connection is successful

15: Check the installed software information

Software installation After completion, you can use the command rpm -ql to view the specific installation directory of the software package.

Take viewing the installation directory of nginx as an example:

#rpm -ql nginx

You can view the version information of the software package through the command rpm -q. Take checking the nginx version as an example:
#rpm -q nginx

Original address: http://www.cnblogs.com/xiaoit/p/3991037.html


The above introduces how to build LNMP on CentOS65, including all aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!