Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The process of building lnmp by centos6.5

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

An operation and maintenance staff who does not write a blog is not a good developer.

1. Install centos6.5 operating system

2. Download nginx,www.nginx.org

3. Download php,www.php.net

Download libmcrypt http://pan.baidu.com/s/1mhHxXzU

4. Download mariadb,downloads.mariadb.org

Download cmake (MySQL compilation tool) http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz

5. Close selinux

Three states of selinux, viewed with the getenforce command, disable (off) permissive (loose) enforcing (forced)

Setenforce 0 to temporarily change it into loose mode

Vi / etc/selinux/config

Block all lines, plus

SELINUX=disable

6. Turn off the firewall

Service iptables stop (temporary shutdown)

Chkconfig iptables off (make its next restart turned off)

7. Install compilation tools and library files

Yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch

8. Install cmake

Tar zxvf cmake-2.8.8.tar.gz

Cd cmake-2.8.8

. / configure

Make

Make install

9. Install mysql

Groupadd mysql # add mysql Group

Useradd-g mysql mysql-s / bin/false # create a user mysql and join the mysql group, and do not allow mysql users to log in directly to the system

Mkdir-p / data/mysql # create MySQL database storage directory

Chown-R mysql:mysql / data/mysql # set permissions

Mkdir-p / usr/local/mysql # create installation directory

Tar zxvf mysql-5.5.37.tar.gz

Cd mysql-5.5.37

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DSYSCONFDIR=/etc # specifies the installation directory, and everyone knows it; specifying datadir, I haven't found any meaning yet, because I have to configure it later. Specifying / etc will make some scripts under mysql/bin read the my.cnf at this location when they are executed, but the startup script does not seem to read. Anyway, I have configured the datadir of my.cnf, but the startup script still reports an error. If you configure datadir in the startup script, you will not report an error.

Make # compilation

Make install # installation

Cd / usr/local/mysql

Cp. / support-files/my-huge.cnf / etc/my.cnf # copy the configuration file (Note: there is a my.cnf by default under the / etc directory, which can be overwritten directly)

Vi / etc/my.cnf # edit the configuration file and add it in the [mysqld] section

Datadir = / data/mysql # add the MySQL database path (the path is added here because many mysql scripts will read this file, such as the script to be executed in the next sentence; no matter whether the path is added here or not, it will not affect mysql startup, because it must be added to the startup script)

. / scripts/mysql_install_db-- user=mysql # generates mysql system databases (generates three system databases. If there is no path in the previous sentence and no path is specified in this sentence, it will be generated to the default directory. / mysql/data)

Cp. / support-files/mysql.server / etc/rc.d/init.d/mysqld # add Mysql to the system startup

Chmod 755 / etc/init.d/mysqld # increased execution permissions

Chkconfig mysqld on # join boot boot (this step will directly join the system service and then boot startup; if you only want to join the system service, you can use chkconfig-- add mysqld)

Vi / etc/rc.d/init.d/mysqld # editing

Basedir = / usr/local/mysql # MySQL program installation path

Datadir = / data/mysql # MySQl database storage directory (this must be added, regardless of whether it is included in my.cnf or not)

Service mysqld start # Startup

You don't have to do the following.

Vi / etc/profile # adds the mysql service to the system environment variable: add the following line at the end, and take effect after restarting the system (may not be added)

Export PATH=$PATH:/usr/local/mysql/bin

The following two lines link the library files of myslq to the default location of the system, so that you do not have to specify the library file address of mysql when compiling software such as PHP.

Ln-s / usr/local/mysql/lib/mysql / usr/lib/mysql

Ln-s / usr/local/mysql/include/mysql / usr/include/mysql

Shutdown-r now # needs to restart the system. After waiting for the system to restart, continue to operate under the terminal command line (you can specify the script location without restarting)

Mysql_secure_installation # set the Mysql password (I usually use the second one, or I don't have to change it first)

Press enter Y to enter the password twice according to the prompt

Or change the password directly / usr/local/mysql/bin/mysqladmin-u root-p password "123456" # change the password

Service mysqld restart # restart

10. Install nginx

Cd / usr/local/src

Groupadd www

Useradd-g www www-s / bin/false

Tar zxvf nginx-1.5.13.tar.gz

Cd nginx-1.5.13

/ configure-- prefix=/usr/local/nginx-- without-http_memcached_module-- user=www-- group=www-- with-http_stub_status_module-- with-openssl=/usr/-- with-pcre=/usr/local/src/pcre-8.35

Make

Make install

/ usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.conf # start nginx, or use the following script, which is not required

# set nginx self-startup and add the following script

Vi / etc/init.d/nginx

#! / bin/bash

# nginx Startup script for the Nginx HTTP Server

# it is v.0.0.2 version.

# chkconfig:-85 15

# description: Nginx is a high-performance web and proxy server.

# It has a lot of features, but it's not for everyone.

# processname: nginx

# pidfile: / var/run/nginx.pid

# config: / usr/local/nginx/conf/nginx.conf

Nginxd=/usr/local/nginx/sbin/nginx

Nginx_config=/usr/local/nginx/conf/nginx.conf

Nginx_pid=/var/run/nginx.pid

RETVAL=0

Prog= "nginx"

# Source function library.

. / etc/rc.d/init.d/functions

# Source networking configuration.

. / etc/sysconfig/network

# Check that networking is up.

[${NETWORKING} = "no"] & & exit 0

[- x $nginxd] | | exit 0

# Start nginx daemons functions.

Start () {

If [- e $nginx_pid]; then

Echo "nginx already running...."

Exit 1

Fi

Echo-n $"Starting $prog:"

Daemon $nginxd-c ${nginx_config}

RETVAL=$?

Echo

[$RETVAL = 0] & & touch / var/lock/subsys/nginx

Return $RETVAL

}

# Stop nginx daemons functions.

Stop () {

Echo-n $"Stopping $prog:"

Killproc $nginxd

RETVAL=$?

Echo

[$RETVAL = 0] & & rm-f / var/lock/subsys/nginx / var/run/nginx.pid

}

# reload nginx service functions.

Reload () {

Echo-n $"Reloading $prog:"

# kill-HUP `cat ${nginx_pid} `

Killproc $nginxd-HUP

RETVAL=$?

Echo

}

# See how we were called.

Case "$1" in

Start)

Start

Stop)

Stop

Reload)

Reload

Restart)

Stop

Start

Status)

Status $prog

RETVAL=$?

*)

Echo $"Usage: $prog {start | stop | restart | reload | status | help}"

Exit 1

Esac

Exit $RETVAL

Chmod 775 / etc/rc.d/init.d/nginx

Chkconfig nginx on

/ etc/rc.d/init.d/nginx restart

Service nginx restart

11. Install libmcrypt

Cd / usr/local/src

Tar zxvf libmcrypt-2.5.8.tar.gz

Cd libmcrypt-2.5.8

. / configure

Make

Nake install

11.2. Install php

Cd / usr/local/src

Tar-zvxf php-5.5.10.tar.gz

Cd php-5.5.10

Mkdir-p / usr/local/php5

/ configure-- prefix=/usr/local/php5-- with-config-file-path=/usr/local/php5/etc-- with-mysql=/usr/local/mysql-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-mysql-sock=/tmp/mysql.sock-- with-gd-- with-iconv-- with-zlib-- enable-xml-- enable-bcmath-- enable-shmop-- enable-sysvsem-- enable-inline-optimization-- with-curlwrappers-- enable -mbregex-enable-fpm-- enable-mbstring-- enable-ftp-- enable-gd-native-ttf-- with-openssl-- enable-pcntl-- enable-sockets-- with-xmlrpc-- enable-zip-- enable-soap-- with-pear-- with-gettext-- enable-session-- with-mcrypt-- with-curl

Make

Make install

Cp php.ini-production / usr/local/php5/etc/php.ini

Rm-rf / etc/php.ini

Ln-s / usr/local/php5/etc/php.ini / etc/php.ini

Cp / usr/local/php5/etc/php-fpm.conf.default / usr/local/php5/etc/php-fpm.conf

Vi / usr/local/php5/etc/php-fpm.conf

User = www # set the php-fpm running account to www

Group = www # set the php-fpm running group to www

Pid = run/php-fpm.pid # cancel the previous semicolon

Cp / usr/local/src/php-5.5.10/sapi/fpm/init.d.php-fpm / etc/rc.d/init.d/php-fpm# copy php-fpm to startup directory

Chmod + x / etc/rc.d/init.d/php-fpm # add execute permission

Chkconfig php-fpm on # set boot up

Vi / usr/local/php5/etc/php.ini # Edit configuration file

Change it to: date.timezone = PRC # set time zone

12. Configure nginx to support php

Vi / usr/local/nginx/conf/nginx.conf # edits the configuration file with the following modifications

The first line of user www www; # user is uncommented, and the Nginx running group is changed to www www;. It must be the same as the user,group configuration in / usr/local/php5/etc/php-fpm.conf, otherwise there will be errors in php operation.

Index index.php index.html index.htm; # add 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

}

# uncomment part of FastCGI server location, and pay attention to the parameters of fastcgi_param line, change to

$document_root$fastcgi_script_name, or use an absolute path

/ etc/init.d/nginx restart # restart nginx

13. Testing

Cd / usr/local/nginx/html/ # enter the nginx default website root directory

Rm-rf / usr/local/nginx/html/* # Delete the default test page

Vi index.php # Editing

Phpinfo ()

Chown www.www / usr/local/nginx/html/-R # sets the directory owner

Chmod 700 / usr/local/nginx/html/-R # set directory permissions

Shutdown-r now # restart the system

14. Related orders

Service nginx restart # restart nginx

Service mysqld restart # restart mysql

/ usr/local/php5/sbin/php-fpm # launch php-fpm

/ etc/rc.d/init.d/php-fpm restart # restart php-fpm

/ etc/rc.d/init.d/php-fpm stop # stop php-fpm

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report