Web server configuration and Nginx and MySQL deployment

Source: Internet
Author: User

Nginx Compiler Installation Method:

Mkdir-p/home/oldboy/tools

Cd/home/oldboy/tools

wget http://nginx.org/download/nginx-1.8.1.tar.gz ####### #或者 RZ upload local Nginx Package

2. Installing Pcre

Yum Install pcre-devel-y ####### #依赖包

3. Installing OpenSSL

Yum Install Openssl-devel ####### #依赖包

4. View Yum Source

Yum Repolist

Installation URLs for 5.yum sources

Http://mirrors.aliyun.com/help/centos

6. Extracting the Nginx compression package

Tar XF nginx ####### #解压nginx包

7. Create Users and directories

Useradd-s/sbin/nologin-m www ####### #创建用户和目录

Mkdir-p/application

8. Enter/home/oldboy/tools

Cd/home/oldboy/tools

9. Go to Nginx directory to execute script

/configure--user=www--group=www--with-http_stub_status_module--with-http_ssl_module--prefix=/application/ nginx-1.8.1

10. Perform the compilation

Make

11. Perform a compilation installation

Make install

12.nginx whether the installation was successful

/application/nginx-1.8.1/sbin/nginx

2) browser opens Web server IP 10.0.0.8 ####### #打开后为nginx页面

13. Enter the/application directory

14. Create a soft link

Ln-s/APPLICATION/NGINX-1.8.1//application/nginx

15. Start Nginx

/application/nginx/sbin/nginx

15. Detect if Nginx is started

Ss-lntup|grep Nginx

16. View Nginx's compilation information

/application/nginx/sbin/nginx-v


########/application/nginx/sbin/nginx-t Check grammar

########/application/nginx/sbin/nginx-s Reload Smooth Restart

# #Nginx主配置文件

First back up Cp/application/nginx/conf/nginx.conf{,.bak} ****************************************

Cat >/application/nginx/conf/nginx.conf<<eof

Worker_processes 1;


Error_log Logs/error.log error;

PID Logs/nginx.pid;


Events {

Worker_connections 1024;

}


HTTP {

Include Mime.types;

Default_type Application/octet-stream;

Sendfile on;

Keepalive_timeout 65;

Log_format main ' \ $remote _addr-\ $remote _user [\ $time _local] "\ $request" '

' \ $status \ $body _bytes_sent "\ $http _referer" '

"\ $http _user_agent" "\ $http _x_forwarded_for";

Include extra/*.conf;

}


Eof


Mkdir-p/application/nginx/conf/extra ########### #创建一个目录


# #www配置文件

Cat >/application/nginx/conf/extra/www.conf<<eof

server {

Listen 80;

server_name etiantian.org;

Rewrite ^/(. *) $ http://www.etiantian.org/$1 permanent;

}


server {

Listen 80;

server_name www.etiantian.org;

Location/{

Root html/www;

Index index.html index.htm;

}

Access_log Logs/www_access.log Main;

}

Eof


# #bbs配置文件

Cat >/application/nginx/conf/extra/bbs.conf<<eof

server {

Listen 80;

server_name bbs.etiantian.org;

Location/{

Root Html/bbs;

Index index.html index.htm;

}

Access_log Logs/bbs_access.log Main;

}

Eof


# #blog配置文件

Cat >/application/nginx/conf/extra/blog.conf<<eof

server {

Listen 80;

server_name blog.etiantian.org;

Location/{

Root Html/blog;

Index index.html index.htm;

}

Access_log Logs/blog_access.log Main;

}

Eof


# #status配置文件

Cat >/application/nginx/conf/extra/status.conf<<eof

server{

Listen 80;

server_name status.etiantian.org;

Location/{

Stub_status on;

Access_log off;

}

}

Eof



Mkdir/application/nginx/html/{www,bbs,blog}

echo www >/application/nginx/html/www/index.html

Echo BBS >/application/nginx/html/bbs/index.html

Echo Blog >/application/nginx/html/blog/index.html

Use for loop:

For n in www bbs blog;d o echo web01 $n >/application/nginx/html/$n/index.html;d One

/application/nginx/sbin/nginx-t

/application/nginx/sbin/nginx-s Reload

/application/nginx/sbin/nginx-s stop

/application/nginx/sbin/nginx



##################################### MySQL Deployment #############################



MySQL installation process:


1. Enter/home/oldboy/tools to perform an upload of MySQL database instructions and create a MySQL user

Cd/home/oldboy/tools

RZ-E Select the Windows MySQL database to upload,

# # #创建mysql用户 # # #

Useradd-s/sbin/nologin-m MySQL

2. Go to the MySQL software storage path and unzip:

Cd/home/oldboy/tools

Tar XF mysql-5.5.49-linux2.6-x86_64.tar.gz

3. Move the extracted MySQL directory to the specified directory

MV mysql-5.6.35-linux-glibc2.5-x86_64/application/mysql-5.6.35

4. Create a soft link for MySQL

Ln-s/application/mysql-5.6.35//application/mysql

5. Assign the MySQL software owner to the MySQL installation directory

Chown-r mysql.mysql/application/mysql/

6. (key) Execute MySQL script

/application/mysql/scripts/mysql_install_db--basedir=/application/mysql--datadir=/application/mysql/data--user =mysql

7. Copy the script from the MySQL installation directory to Linux system services

Cp/application/mysql/support-files/mysql.server/etc/init.d/mysqld

8. Execute permissions for script X

chmod +x/etc/init.d/mysqld

9. Replace the configuration file

Sed-i ' S#/usr/local/mysql#/application/mysql#g '/application/mysql/bin/mysqld_safe/etc/init.d/mysqld

10. Overwrite the original configuration file.

\cp/application/mysql/support-files/my-default.cnf/etc/my.cnf

11. Start the MySQL service:

/etc/init.d/mysqld start

12. Implant the command path to MySQL

Echo ' Export path=/application/mysql/bin: $PATH ' >>/etc/profile

Source/etc/profile

which MySQL

13. Join the boot-up

Chkconfig--add mysqld

Chkconfig mysqld on

14. Set the user password for MySQL root

/application/mysql/bin/mysqladmin-u root password ' oldboy123 '

Password is 123

15. Test if the password is valid: (log in to MySQL)

Mysql-uroot-poldboy123

16. Query all the databases in MySQL

show databases;

17. Create a Database

Create Database Oldboy;

18. Delete a database

Drop database Oldboy;

19. View the users of the system

Select Uesr,host from Mysql.user;


This article is from the "12215961" blog, please be sure to keep this source http://12225961.blog.51cto.com/12215961/1898122

Web server configuration and Nginx and MySQL deployment

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.