Server Setup: detailed tutorial on CentOS LNMP Construction

Source: Internet
Author: User
Tags install wordpress

Currently, Linux + Nginx + PHP + MySQL (LNMP for short) is a popular configuration. The following describes the configuration method.

1. Install CentOS and LNMP packages.

Install CentOS 5.5. After the system is installed, it comes with APACHE. Run yum remove httpd to delete Apache!

Log on to LINUX Using SSH and install LNMP.

1. Download the one-click installation package of LNMP:

Http://soft.vpser.net/lnmp/lnmp0.5.tar.gz wget-c

Http://soft.vpser.net/lnmp/lnmp0.5.tar.gz

Or

Http://soft.vpser.net/lnmp/lnmp0.5-full.tar.gz 2, extract LNMP one-key installation package:

Installation Steps in tar zxvf lnmp0.5.tar.gz 3 and CentOS
# Download the command

Cd lnmp0.5/# And then execute

./Centos. sh, enter the domain name to bind, press enter, enter the MySQL root Password to be set, and press enter again to confirm.
The program automatically installs and compiles software Nginx, PHP, MySQL, phpMyAdmin, and Zend.

VM management
#1. Add a VM and run the following command:

. /Vhost. sh enter the domain name to be bound as prompted, and press Enter. If you want to add more domain names, enter y, and then enter the domain name to be bound. Multiple Domain names can be separated by spaces. Enter the directory to which the domain name is bound (absolute directory, such as/home/wwwroot/lnmp. If this parameter is left blank, the default domain name is/home/wwwroot/.), and then select whether to add pseudo-static rules, by default, discuz, WordPress, sablog, emlog, and dabr are available. You can directly enter the Preceding Names. To add custom pseudo-static rules, enter the desired name, the program will automatically create a pseudo-static file, directly under/usr/local/nginx/CONF/your custom pseudo-static name. conf
Add pseudo-static rules. Next, you will be prompted whether to enable the log function. Generally, you do not need to start it. Simply enter n. If you need to start it, enter y, and then enter the name of the log file to be defined, press enter to automatically add a VM.

# Lnmp status management:

/Root/lnmp {START | stop | reload | restart | kill | status} phpinfo: http: // The domain name or IP address entered earlier/phpinfo. php
PhpMyAdmin: http: // The domain name or IP address entered earlier/PHPmyAdmin/
Probe: http: // The previously entered domain name or IP/P. php
MySQL Root Password: if you do not enter the password, press enter as root; otherwise, enter the password for you.

Lnmp directory:
MySQL:/usr/local/MySQL
PHP:/usr/local/PHP
Nginx:/usr/local/nginx
Website directory:/home/wwwroot

* You can also manually add a VM Domain Name:

Type the following command:

VI/usr/local/nginx/CONF/nginx. conf or:

Add the following code to vi/usr/local/nginx/conf/vhost/*. conf:

Server
{
Listen 80;
Server_name www. ****. com ***. com *. ***. com;
Index index.html index.htm index. php;
Root/home/wwwroot /***;
Location ~ . * \. (Php | php5 )? $
{
Fastcgi_pass unix:/tmp/php-cgi.sock;
Fastcgi_index index. php;
Fcinclude gi. conf;
}
Location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $
{
Expires 30d;
}
Location ~ . * \. (Js | css )? $
{
Expires 12 h;
}
Access_log off;
} *** You can change it to your domain name. To create a VM, you only need to add the same code below;

Run again

Kill-HUP 'cat/usr/local/nginx/logs/nginx. Pi' or

The VM takes effect after/usr/local/nginx/sbin/nginx-s reload.

2. Update nginx and re-compile nginx to support IPv6 (skip this section if IPv6 is not required)

Click here: ipv6 settings for nginx and Apache Web Servers

3. Install vsftpd
1. Install vsftpd in Yum:

Yum install vsftpd
Touch/var/log/vsftpd. log # create a vsftp log file. 2. Set the file to run automatically and start it manually at startup:

Chkconfig vsftpd on
Service vsftpd start
Netstat-Tl can check whether the ftp port is listening!
3. Configuration File
Configure/etc/vsftpd/ftpusers and/etc/vsftpd/user_list, # users who cannot log on to FTP;
Configure/etc/vsftpd. conf
# Anonymous_enable = Yes
Anonymous_enable = No # Set that anonymous users are not allowed to access
Chroot_local_user = yes # restrict all ftp users in the system to xferlog_file =/var/log/vsftpd. log in the home directory to set the path for saving vsftpd service logs. Note: This file does not exist by default. Must be manually touch
Ascii_upload_enable = Yes
Ascii_download_enable = yes: supports the upload and download functions in ASCII mode.
Pam_service_name = vsftpd PAM Authentication file name. PAM will be authenticated according to/etc/pam. d/vsftpd
4. Set the FTP directory
Modify the/home/wwwroot directory attributes:

Chmod-R 777/home/wwwroot recursively grants read, write, and execute permissions to all files and subdirectories in this directory.

Chgrp-R ftp/home/wwwroot recursively sets the group attributes of this directory and all files and subdirectories in this directory to an ftp group
5. add FTP users

Adduser-d/home/wwwroot-g ftp-s/sbin/nologin username # Add a user. The group is FTP and the directory is/home/wwwroot.

Passwd username # Set User Password
Changing password for user beinan.
New password:
Retype new password:
Passwd: all authentication tokens updated successfully.
6. Restart FTP

Service vsftpd restartguest_enable = YES sets to enable the virtual user function.
Guest_username = ftp specifies the host user of the virtual user. -CentOS already has built-in ftp users.
User_config_dir =/etc/vsftpd/vuser_conf set the path for storing the configuration file of the virtual user's personal vsftp. Configuration file for storing virtual user personality (configuration file name = virtual user name)
7. Sometimes, when uploading multiple small files, you can edit/etc/vsftpd. conf as follows:

Connect_from_port_20 = YES
Pasv_min_port = 49152
Pasvanderbilt max_port = 65534
Data_connection_timeout = 1 or package and upload the file to the server and decompress it to solve this problem.
8. Modify the FTP directory of an existing user

Usermod-d/home/www/abc.com abc Note:/home/www/abc.com is the user name of the target folder to be modified.
9. The default setting of vsftpd is that all directories can be accessed by the customer, which is extremely insecure. Therefore, you must restrict the access to directories by using the following methods:

Chroot_local_user = YES add this line at the bottom of vsftpd. conf and restart ftp.

4. Common commands in Linux

1.decompress the tar.gz compressed file in the current directory with the following command:

Tar zxvf filename.tar.gz 2. Install unzip in CentOS
Command:

Yum install unzip decompress the zip file in the current directory
Command:

Unzip filename.zip 3. Create a directory command named mkdir.

Mkdir/home/wwwroot/abc. com4. Run the delete directory command to specify the rm-rf directory name.

Rm-rf/home/wwwroot/abc.com two parameters-rf:
-R is recursive down. No matter how many levels of directories are there, delete them together.
-F means to delete the file directly without any prompts.
Delete an object using the rm-f file name

V. Example: install WordPress and set a fixed link tutorial

1. Install Wget

Yum install wget2. enter the Virtual Machine directory

Cd/home/wwwroot3. download WordPress to the server and decompress it

Wget http://wordpress.org/latest.tar.gz
Tar zxvf latest.tar.gz 4. Modify WordPress directory attributes

Chmod-R 777/home/wwwroot/wordpress
Chgrp-R ftp/home/wwwroot/wordpress
Chown-R www/home/wwwroot/wordpress5.nginx Fixed Link (Permalink) settings for WordPress
Edit the/usr/local/nginx/conf/nginx. conf file and add the following lines to the server container. The wordpress directory is modified as follows:

Location/wordpress /{
Rewrite ^ index \. php $-last;

If (! -E $ request_filename ){
Rewrite./wordpress/index. php last;
}
} After the modification is complete, run the following command to restart lnmp:

/Root/lnmp restart
This article from centos configuration tutorial | CentOS installation, configuration, learning tutorial website original link: http://www.centos.ws/centos/configure/923.html

Related Article

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.