Linux CentOS7 System Configuration Lnmp

Source: Internet
Author: User

Tips: Before you do this, make sure that you have CENTOS7 installed because all of the following operations are done under CENTOS7.

1, first to stop the native firewall, and then configure Iptables, open 21/22/80/8080/3306 port, the specific configuration method can refer to me about how to configure the Centos7 firewall that blog;

2, Link Xshell operation server configuration xftp transfer files (because in the production environment Linux system is not possible to install local, is basically a remote server, so this time need to use remote control)

(1) Connection Xshell: This is a fool-type terminal, just enter the server IP address and then enter the user name and password (the premise is that you have opened the first step 22 port)

(2) Configure Xftp:<1>yum install VSFTPD #下载安装

<2>/sbin/service vsftpd Restart or/sbin/service vsftpd start or/bin/systemctl Restart Vsftpd.service These three always have a command to start

<3> Local Download XFTP client, enter IP address, username and password to link (if using FTP protocol transfer Please ensure open 21 port, if using SFTP protocol transmission Please ensure Open 22 port)

3, check whether Yum source is the latest version, not the latest download latest (I test found even the latest also to perform the following operation, do not perform the subsequent download nginx will fail, so very pit. )

<1>yum install wget #安装下载工具, here is the latest version of the note will continue to do the following

<2>wget http://www.atomicorp.com/installers/atomic #下载

<3>sh./atomic #安装

<4>yum check-update #更新yum源

Now that the preparation for configuring LNMP is over, the following is the installation chapter.

Install Nginx:

1. Yum Remove httpd* php* #删除系统自带的软件包

2. Yum install Nginx #安装nginx Follow the prompts to enter Y for installation

3, Chkconfig Nginx on #设置nginx开机启动

4, systemctl restart Nginx #启动服务

Install MySQL:

1, yum install MySQL mysql-server #输入Y即可自动安装, until the installation is complete, before this step to resolve the problem of no available packages (personal test There are no available packages need to do the following operation, or MySQL can not be installed):

<1>wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm #下载

<2> ls #显示

<3>RPM-IVH mysql-community-release-el7-5.noarch.rpm #解压

<4>ls-1/etc/yum.repos.d/mysql-community*

The following two lines of code appear to be configured:

/etc/yum.repos.d/mysql-community.repo

/etc/yum.repos.d/mysql-community-source.repo

Now execute the Yum install MySQL Mysql-server

2. Systemctl restart MySQL #启动mysql

3. Chkconfig mysqld on #设为开机启动

4, Mysql_secure_installation #为root账号设置密码

5, password settings to complete restarting MySQL, perform operation 2

Install PHP:

1. Yum Install PHP php-fpm #根据提示输入Y直到安装完成

2. Yum Install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php -bcmath Php-mhash libmcrypt #安装PHP组件, so PHP5 support MySQL

3, Chkconfig php-fpm on #设置php-fpm boot up

4, systemctl restart PHP-FPM #启动PHP服务器

The installation here is also finished, the following is the configuration of Nginx and PHP to implement the Nginx support PHP

To modify the Nginx configuration file:

1, vi/etc/nginx/nginx.conf #编辑
User Nginx Nginx; #修改nginx运行账号为: Nginx User of Nginx Group
: Wq #保存退出

2, vi/etc/nginx/conf.d/default.conf #编辑

Index index.php index.html index.htm; #增加index. php

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
#取消FastCGI the comment for the server section location, and note the parameters of the Fastcgi_param row, change to $document_root$fastcgi_script_name, or use the absolute path

3, service Nginx restart #重启nginx

To modify a PHP configuration file:

1, Vi/etc/php.ini #编辑

Date.timezone = PRC #在946行 Remove the preceding semicolon and change to Date.timezone = PRC

Disable_functions =

Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_ Restore,dl,ope

Nlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space, Checkdnsrr,checkdns

RR,GETSERVBYNAME,GETSERVBYPORT,DISK_TOTAL_SPACE,POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD,

Posix_getegid,posix_geteuid,posix_getgid,

Posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,

Posix_getppid,posix_getpwnam,posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty,

Posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,

Posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#在386行 lists the functions that PHP can disable, and if some programs need to use this function, you can delete and cancel the disabled.
expose_php = Off #在432行 Suppress the PHP version information
MAGIC_QUOTES_GPC = on #在745行 open MAGIC_QUOTES_GPC to prevent SQL injection
Short_open_tag = on #在229行支持php短标签
Open_basedir =.:/ tmp/#在380行 setting means to allow access to the current directory (i.e. the directory where the php script file resides) and the/tmp/directory, which prevents the PHP Trojan from crossing the station, and if the installer has a problem after the change

2,: wq! #保存退出

3, Configuration php-fpm:

<1>vi/etc/php-fpm.d/www.conf #编辑

user = Nginx #修改用户为nginx
Group = Nginx #修改组为nginx
<2>:wq! #保存退出

Test:

1,cd/usr/share/nginx/html #进入Nginx服务器的网页目录

2, VI index.php #添加以下代码
<?php
Phpinfo ();
?>

3,: wq! #保存退出

4, Chown Nginx.nginx/usr/share/nginx/html-r #设置权限

5, service Nginx restart #重启nginx

6, service php-fpm restart #重启php-fpm

Even if the basic completion, the following is to go to the local browser to enter the IP address access, the PHP information page is to indicate the success of the configuration!

Linux CentOS7 System Configuration Lnmp

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.