欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CentOS7編譯安裝新版LNMP環(huán)境

 更新時(shí)間:2016年10月20日 09:21:14   作者:centoscn  
本文給大家分享的是在最新版的centos系統(tǒng)中編譯安裝lnmp環(huán)境的詳細(xì)步驟,非常的實(shí)用,推薦需要的小伙伴們參考下

由于公司要求需要最新版的ZABBIX2.4.4需要最新版的系統(tǒng)CENTOS7和新版的LNMP環(huán)境,所以本人摸索著使用新版的環(huán)境搭建了LNMP系統(tǒng),環(huán)境版本如下:

  • 系統(tǒng):CentOS 7 x86_64
  • NGINX:nginx-1.7.12
  • 數(shù)據(jù)庫(kù):mariadb-10.0.13
  • PHP:php-5.5.23

首先做一些準(zhǔn)備工作,先把centos7的防火墻更換成iptables,可以參見(jiàn)如下鏈接

centos7防火墻設(shè)置iptables

修改成iptables之后就可以清空iptables里面的過(guò)濾規(guī)則了,然后再關(guān)閉selinux服務(wù)。記得不要忘了先安裝gcc gcc-c++ wget net-tools等功能哦。

首先安裝mariadb

應(yīng)為數(shù)據(jù)庫(kù)編譯需要很長(zhǎng)時(shí)間,所以我這里下載的是已經(jīng)編譯好了的二進(jìn)制包,下載版本為 mariadb-10.0.13-linux-glibc_214-x86_64.tar.gz 

1、下載二進(jìn)制包到/usr/local/src 目錄下:

復(fù)制代碼 代碼如下:
[root@centos74 ~]# cd /usr/local/src/
[root@centos74 src]# wget http://ftp.osuosl.org/pub/mariadb/mariadb-10.0.13/bintar-quantal-amd64/mariadb-10.0.13-linux-glibc_214-x86_64.tar.gz[/code]

2、將壓縮包解壓到/usr/local 目錄下:

[code][root@centos74 src]# tar zvxf mariadb-10.0.13-linux-glibc_214-x86_64.tar.gz -C /usr/local/


3、創(chuàng)建mariadb 數(shù)據(jù)初始化目錄/data/mysql:

復(fù)制代碼 代碼如下:
[root@centos74 src]# mkdir -p /data/mysql

4、添加系統(tǒng)用戶(hù)mysql,禁止登陸系統(tǒng),同時(shí),將mariadb 數(shù)據(jù)初始化目錄所屬主和組都修改為mysql:

復(fù)制代碼 代碼如下:
[root@centos74 src]# useradd -r -s /sbin/nologin mysql ;chown -R mysql.mysql /data/mysql/

5、重命名解壓出來(lái)的mariadb 目錄:

復(fù)制代碼 代碼如下:
[root@centos74 src]# mv /usr/local/mariadb-10.0.13-linux-x86_64/ /usr/local/mysql

6、進(jìn)入重命名后的目錄,初始化mariadb:

[root@centos74 src]# cd /usr/local/mysql/
[root@centos74 mysql]# ./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
Installing MariaDB/MySQL system tables in '/data/mysql' ...
140906 2:03:19 [Note] InnoDB: Using mutexes to ref count buffer pool pages
140906 2:03:19 [Note] InnoDB: The InnoDB memory heap is disabled
140906 2:03:19 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
140906 2:03:19 [Note] InnoDB: Compressed tables use zlib 1.2.3
140906 2:03:19 [Note] InnoDB: Using Linux native AIO
140906 2:03:19 [Note] InnoDB: Using CPU crc32 instructions
140906 2:03:19 [Note] InnoDB: Initializing buffer pool, size = 128.0M
........................................................................
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Support MariaDB development by buying support/new features from
SkySQL Ab. You can contact us about this at sales@skysql.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/

報(bào)錯(cuò):WARNING: The host 'test4' could not be looked up with resolveip.
解決辦法:vim /etc/hosts 在最后一行添加192.168.1.242 test4

報(bào)錯(cuò):./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解決辦法:yum -y install libaio-devel libaio

7、復(fù)制配置文件到/etc目錄覆蓋之前的my.cnf:

復(fù)制代碼 代碼如下:
[root@centos74 mysql]# cp support-files/my-large.cnf /etc/my.cnf

cp:是否覆蓋"/etc/my.cnf"? y

8、復(fù)制mysql 啟動(dòng)腳本文件到/etc/init.d 目錄下并重命名為mysqld:

復(fù)制代碼 代碼如下:
[root@centos74 mysql]# cp support-files/mysql.server /etc/init.d/mysqld

同時(shí)修改啟動(dòng)腳本的權(quán)限為755:

復(fù)制代碼 代碼如下:
[root@centos74 mysql]# chmod 755 !$
chmod 755 /etc/init.d/mysqld

9、編輯啟動(dòng)腳本,定義datadir 路徑:

復(fù)制代碼 代碼如下:
[root@centos74 mysql]# vim /etc/init.d/mysqld

定義數(shù)據(jù)存放路徑:
datadir=/data/mysql

10、將mariadb自帶命令放入$PATH

[root@localhost ~]# PATH=$PATH:/etc/init.d/#當(dāng)前有效,重啟shell就失效
[root@localhost ~]# echo "export PATH=$PATH:/etc/init.d/" >>/etc/profile
[root@localhost ~]# echo "export PATH=$PATH:/usr/local/mysql/bin/" >>/etc/profile
[root@localhost ~]# source !$

11、啟動(dòng)mariadb:

[root@centos74 mysql]# /etc/init.d/mysqld start

Starting MySQL. SUCCESS!

第二步,開(kāi)始安裝php

這里要先聲明一下,針對(duì)Nginx的php安裝和針對(duì)apache的php安裝是有區(qū)別的,因?yàn)镹ginx中的php是以fastcgi的方式結(jié)合nginx的,可以理解為nginx代理了php的fastcgi,而apache是把php作為自己的模塊來(lái)調(diào)用的。同樣的,php官方下載地址: http://www.php.net/downloads.php

下載php

[rot@localhost src]# cd /usr/local/src
[root@localhost src]# wget http://am1.php.net/distributions/php-5.5.23.tar.gz

解壓php

[root@localhost src]# tar zxf php-5.5.23.tar.gz

創(chuàng)建相關(guān)賬戶(hù)

[root@localhost src]# useradd -s /sbin/nologin php-fpm

配置編譯參數(shù)

復(fù)制代碼 代碼如下:
[root@localhost src]# cd php-5.5.23
[root@localhost src]# yum -y install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel
[root@localhost php-5.5.23]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=mysqlnd  --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-pear --with-curl --enable-bcmath --enable-mbstring --enable-sockets --with-gd --with-libxml-dir=/usr/local --with-gettext

錯(cuò)誤:configure: error: xml2-config not found. Please check your libxml2 installation.
解決辦法:yum -y install libxml2-devel

錯(cuò)誤:configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/
解決辦法:yum -y install libcurl-devel

錯(cuò)誤:configure: error: jpeglib.h not found.
解決辦法:yum -y install libjpeg-turbo-devel

錯(cuò)誤:configure: error: png.h not found.
解決辦法:yum -y install libpng-devel

錯(cuò)誤:configure: error: freetype-config not found.
解決辦法:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

錯(cuò)誤:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決辦法:yum -y install libmcrypt-devel

安裝php

[root@localhost php-5.3.27]# make && make install

以上每一個(gè)步驟,如果沒(méi)有完全執(zhí)行正確,那么下一步是無(wú)法進(jìn)行的,使用 echo $? 看結(jié)果是否為 “0” , 如果不是,就是沒(méi)有執(zhí)行正確。

修改配置文件

cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/php/etc/php-fpm.conf

把如下內(nèi)容寫(xiě)入該文件:

[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024

保存配置文件后,檢驗(yàn)配置是否正確的方法為:

/usr/local/php/sbin/php-fpm -t

如果出現(xiàn)諸如 “test is successful” 字樣,說(shuō)明配置沒(méi)有問(wèn)題。

啟動(dòng)php-fpm

cp /usr/local/src/php-5.5.23/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
service php-fpm start


如果想讓它開(kāi)機(jī)啟動(dòng),執(zhí)行:

chkconfig php-fpm on

檢測(cè)是否啟動(dòng):

ps aux |grep php-fpm

看看是不是有很多個(gè)進(jìn)程(大概20多個(gè))。

安裝nginx

下載nginx

cd /usr/local/src/
wget http://nginx.org/download/nginx-1.7.12.tar.gz

解壓nginx

tar zxvf nginx-1.7.12.tar.gz

配置編譯參數(shù)

cd nginx-1.7.12
./configure \
--prefix=/usr/local/nginx \
--with-http_realip_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-pcre

報(bào)錯(cuò):./configure: error: the HTTP rewrite module requires the PCRE library.
解決辦法:yum -y install pcre-devel

報(bào)錯(cuò):./configure: error: the HTTP gzip module requires the zlib library.
解決辦法:yum install -y zlib-devel

編譯nginx

make

安裝nginx

make install

編寫(xiě)nginx啟動(dòng)腳本,并加入系統(tǒng)服務(wù)

vim /etc/init.d/nginx

寫(xiě)入如下內(nèi)容:

#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings

NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"

start() {
    echo -n $"Starting $prog: "
    mkdir -p /dev/shm/nginx_temp
    daemon $NGINX_SBIN -c $NGINX_CONF
    RETVAL=$?
    echo
    return $RETVAL
}

stop() {
    echo -n $"Stopping $prog: "
    killproc -p $NGINX_PID $NGINX_SBIN -TERM
    rm -rf /dev/shm/nginx_temp
    RETVAL=$?
    echo
    return $RETVAL
}

reload(){
    echo -n $"Reloading $prog: "
    killproc -p $NGINX_PID $NGINX_SBIN -HUP
    RETVAL=$?
    echo
    return $RETVAL
}

restart(){
    stop
    start
}

configtest(){
  $NGINX_SBIN -c $NGINX_CONF -t
  return 0
}

case "$1" in
 start)
    start
    ;;
 stop)
    stop
    ;;
 reload)
    reload
    ;;
 restart)
    restart
    ;;
 configtest)
    configtest
    ;;
 *)
    echo $"Usage: $0 {start|stop|reload|restart|configtest}"
    RETVAL=1
esac

exit $RETVAL

保存后,更改權(quán)限:

chmod 755 /etc/init.d/nginx
chkconfig --add nginx

如果想開(kāi)機(jī)啟動(dòng),請(qǐng)執(zhí)行:

chkconfig nginx on

更改nginx配置

首先把原來(lái)的配置文件清空:

> /usr/local/nginx/conf/nginx.conf

“>” 這個(gè)符號(hào)為重定向的意思,單獨(dú)用它,可以把一個(gè)文本文檔快速清空。

vim /usr/local/nginx/conf/nginx.conf

寫(xiě)入如下內(nèi)容:

user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
{
  use epoll;
  worker_connections 6000;
}

http
{
  include mime.types;
  default_type application/octet-stream;
  server_names_hash_bucket_size 3526;
  server_names_hash_max_size 4096;
  log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
  '$host "$request_uri" $status'
  '"$http_referer" "$http_user_agent"';
  sendfile on;
  tcp_nopush on;
  keepalive_timeout 30;
  client_header_timeout 3m;
  client_body_timeout 3m;
  send_timeout 3m;
  connection_pool_size 256;
  client_header_buffer_size 1k;
  large_client_header_buffers 8 4k;
  request_pool_size 4k;
  output_buffers 4 32k;
  postpone_output 1460;
  client_max_body_size 10m;
  client_body_buffer_size 256k;
  client_body_temp_path /usr/local/nginx/client_body_temp;
  proxy_temp_path /usr/local/nginx/proxy_temp;
  fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
  fastcgi_intercept_errors on;
  tcp_nodelay on;
  gzip on;
  gzip_min_length 1k;
  gzip_buffers 4 8k;
  gzip_comp_level 5;
  gzip_http_version 1.1;
  gzip_types text/plain application/x-javascript text/css text/htm application/xml;

server
{
  listen 80;
  server_name localhost;
  index index.html index.htm index.php;
  root /usr/local/nginx/html;

  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_pass unix:/tmp/php-fcgi.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
  }

}

}

保存配置后,先檢驗(yàn)一下配置文件是否有錯(cuò)誤存在:

/usr/local/nginx/sbin/nginx -t

如果顯示內(nèi)容如下,則配置正確,否則需要根據(jù)錯(cuò)誤提示修改配置文件:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

啟動(dòng)nginx:

service nginx start

如果不能啟動(dòng),請(qǐng)查看 “/usr/local/nginx/logs/error.log” 文件,檢查nginx是否啟動(dòng):

ps aux |grep nginx

看是否有進(jìn)程。

測(cè)試是否解析php文件

創(chuàng)建測(cè)試文件:

vim /usr/local/nginx/html/2.php

內(nèi)容如下:

<?php echo phpinfo();?>

測(cè)試:

[root@localhost nginx]# curl localhost/2.php

或者使用瀏覽器打開(kāi)http://YourServerIPAddress/2.php

重要:如果解析不了,檢查日志發(fā)現(xiàn)連接不到php,我的php版本為5.5.23,比較新的版本,需要在php/etc/php-fpm.conf文件中添加

listen.owner = nobody
listen.group = nobody

這兩行,再重啟一下服務(wù)就能使用php了

原因是/tmp/php-fcgi.sock這個(gè)文件沒(méi)有讀權(quán)限

至此,最新版的LNMP環(huán)境源碼編譯安裝完成了

相關(guān)文章

  • 探索Linux內(nèi)核:Kconfig的秘密

    探索Linux內(nèi)核:Kconfig的秘密

    今天小編就為大家分享一篇關(guān)于探索Linux內(nèi)核:Kconfig的秘密,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2018-10-10
  • Ubuntu18.04 一鍵升級(jí)Python所有第三方包 及安裝python包的方法

    Ubuntu18.04 一鍵升級(jí)Python所有第三方包 及安裝python包的方法

    pip 是 Python 包管理工具,該工具提供了對(duì)Python 包的查找、下載、安裝、卸載的功能。這篇文章給大家介紹Ubuntu18.04 一鍵升級(jí)Python所有第三方包 ,感興趣的朋友一起看看吧
    2019-10-10
  • centos 7 源碼安裝openssh的方法

    centos 7 源碼安裝openssh的方法

    這篇文章主要介紹了centos 7 源碼安裝openssh的方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-06-06
  • Linux?文件內(nèi)容相關(guān)命令使用匯總

    Linux?文件內(nèi)容相關(guān)命令使用匯總

    Linux操作系統(tǒng)有很多強(qiáng)大的文件內(nèi)容相關(guān)命令,這些命令可以讓您查看、分析和編輯文件。其中,最基本和常用的命令包括cat、more、less和head/tail等。除了這些基本命令之外,grep和find命令也是文件搜索和過(guò)濾方面的有力工具。
    2023-04-04
  • linux系統(tǒng)中rsync+inotify實(shí)現(xiàn)服務(wù)器之間文件實(shí)時(shí)同步

    linux系統(tǒng)中rsync+inotify實(shí)現(xiàn)服務(wù)器之間文件實(shí)時(shí)同步

    這篇文章主要介紹了rsync+inotify實(shí)現(xiàn)服務(wù)器之間文件實(shí)時(shí)同步,需要的朋友可以參考下
    2014-11-11
  • foreman ubuntu16 快速安裝

    foreman ubuntu16 快速安裝

    foreman ubuntu16快速安裝,非常實(shí)用的方法,小編覺(jué)得很不錯(cuò),分享給大家,希望對(duì)大家有幫助
    2018-09-09
  • Ubuntu18.04更換國(guó)內(nèi)源的方法示例

    Ubuntu18.04更換國(guó)內(nèi)源的方法示例

    這篇文章主要介紹了Ubuntu18.04更換國(guó)內(nèi)源的方法示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • CentOS 6.5中SSH免密碼登錄配置教程

    CentOS 6.5中SSH免密碼登錄配置教程

    這篇文章主要介紹了CentOS 6.5中SSH免密碼登錄配置的相關(guān)資料,包括環(huán)境設(shè)置,本機(jī)生成公鑰和私鑰等知識(shí)點(diǎn),本文給大家介紹的非常詳細(xì)具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-10-10
  • CentOS 7中 Minimal 安裝JDK 1.8的教程

    CentOS 7中 Minimal 安裝JDK 1.8的教程

    這篇文章主要介紹了CentOS 7 Minimal 安裝JDK 1.8的教程,非常不錯(cuò),具有參考借鑒價(jià)值 ,需要的朋友可以參考下
    2018-05-05
  • Linux常用硬盤(pán)管理相關(guān)命令介紹

    Linux常用硬盤(pán)管理相關(guān)命令介紹

    大家好,本篇文章主要講的是Linux常用硬盤(pán)管理相關(guān)命令介紹,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話(huà)記得收藏一下哦,方便下次瀏覽
    2021-12-12

最新評(píng)論