首页 后端开发 php教程 CentOS6.6 32位 Minimal版本纯编译安装Nginx Mysql PHP Memcached

CentOS6.6 32位 Minimal版本纯编译安装Nginx Mysql PHP Memcached

Jun 23, 2016 pm 01:39 PM

CentOS是红帽发行的免费的稳定Linux版本,在企业服务器应用中都会选用Minimal版本,因为Minimal是CentOS”最纯洁”的服务器系统,因为Minimal版本连vim编辑器都需要自己安装,Minimal组件最少,无桌面,扩展灵活,非常适合做服务器。

1.配置网卡

Minimal版本的CentOS被安装后,网卡驱动默认是down状态,需要手动激活,在连接好网线后需要执行命令:
[root@jhq0113 soft]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

然后按i进入编辑状态,进行如下修改:

修改完毕后,按ESC,然后shift+:,wq进行保存退出。

然后开始配置DNS服务器地址:

[root@jhq0113 soft]# vi /etc/resolv.conf

最主要的是配置nameserver属性,可以是自己的网关地址,如下图所示:

修改完毕后保存退出。键入以下命令激活网卡:

[root@jhq0113 soft]# ifconfig eth0 up

至此,网卡已经配置好了,如果仍然发现开机网卡未启动等问题,可以执行以下两条命令进行完善。

[root@jhq0113 soft]# chkconfig ?add network
[root@jhq0113 soft]# chkconfig network on

重启网卡命令:

2.配置防火墙,开放22(SSH),3306(Mysql),80(Nginx),11211(Memcached),6379(Redis)端口
[root@jhq0113 soft]# vi /etc/sysconfig/iptables
修改为:

重启防火墙使配置生效:
[root@jhq0113 soft]# /etc/init.d/iptables restart

3.安装组件
更新系统:
[root@jhq0113 soft]# yum update
稍后键入y进行确认。

安装vim:
[root@jhq0113 soft]# yum install vim

安装编译工具及依赖:
[root@jhq0113 soft]# 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

4.下载Cmake,Mysql,PHP,Nginx,libevent,libmcrypt,pcre,memcached
如果自己寻找这些很困难,推荐给大家几个很好的源地址:
阿里:http://mirrors.aliyun.com/
搜狐:http://mirrors.sohu.com/
网易:http://mirrors.163.com/

我的就是在搜狐下载的,版本如下:

5.系统约定
软件源代码包存放位置:/usr/local/src
源码包编译安装位置:/usr/local/软件名字

源码放在/usr/local/src的实现方案有多种,可以在Windows下载,然后通过Xftp传送至指定目录,也可以cd到指定目录,wget 下载地址; 进行下载。

6.正式编译安装

安装Mysql:

Mysql需要Cmake进行编译安装,所以在安装Mysql前必须先安装Cmake


解压Cmake:
[root@jhq0113 src]# tar xzvf cmake-3.1.1.tar.gz

进入cmake解压后目录:
[root@jhq0113 src]# cd cmake-3.1.1

预编译,这个过程可能需要一段时间:
[root@jhq0113 cmake-3.1.1]# ./configure

编译并安装:
[root@jhq0113 cmake-3.1.1]# make && make install

添加mysql组
[root@jhq0113 cmake-3.1.1]# groupadd mysql

创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
[root@jhq0113 cmake-3.1.1]# useradd -g mysql mysql -s /bin/false

创建MySQL数据库存放目录
[root@jhq0113 cmake-3.1.1]# mkdir -p /data/mysql

设置MySQL数据库存放目录权限
[root@jhq0113 cmake-3.1.1]# chown -R mysql:mysql /data/mysql

创建MySQL安装目录
[root@jhq0113 cmake-3.1.1]# mkdir -p /usr/local/mysql

返回/usr/local/src目录:
[root@jhq0113 cmake-3.1.1]# cd /usr/local/src

解压mysql:
[root@jhq0113 src]# tar xzvf mysql-5.6.13.tar.gz

进入mysql解压目录:
[root@jhq0113 src]# cd mysql-5.6.13

用Cmake预编译Mysql,此过程可能需要一段时间:
[root@jhq0113 mysql-5.6.13]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/

编译:
[root@jhq0113 mysql-5.6.13]# make

安装:
[root@jhq0113 mysql-5.6.13]# make install

拷贝配置文件(如果/etc目录下面默认有一个my.cnf,直接覆盖即可):
[root@jhq0113 support-files]# cp /usr/local/mysql/support-files/my-default.cnf /etc/init.d/my.cnf

添加Mysql路径:
[root@jhq0113 support-files]# vim /etc/my.cnf

修改后:

生成Mysql系统数据库:
[root@jhq0113 support-files]# /usr/local/mysql/scripts/mysql_install_db ?user=mysql ?basedir=/usr/local/mysql ?datadir=/data/mysql

把Mysql加入系统启动:
[root@jhq0113 support-files]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld

增加mysqld执行权限:
[root@jhq0113 support-files]# chmod 755 /etc/init.d/mysqld

mysqld加入开机启动:
[root@jhq0113 support-files]# chkconfig mysqld on

编辑配置文件:
[root@jhq0113 support-files]# vim /etc/init.d/mysqld

修改后:

把Mysql服务加入系统环境变量:
[root@jhq0113 support-files]# vim /etc/profile

修改后:

将myslq的库文件链接到系统默认的位置,以确保在编译类似PHP等软件时可以不用指定mysql的库文件地址。
[root@jhq0113 support-files]# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
[root@jhq0113 support-files]# ln -s /usr/local/mysql/include/mysql /usr/include/mysql

重启系统:
reboot

建立连接:
[root@jhq0113 ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

重启Mysqld:
[root@jhq0113 ~]# service mysqld restart

设置Mysql密码:
[root@jhq0113 support-files]# /usr/local/mysql/bin/mysql_secure_installation

修改root密码:

默认没有密码,直接回车,然后输入两次密码,一路按Y 回车下去

设置Mysql可以远程登录:
[root@jhq0113 ~]# mysql -uroot -p

输入密码登录,然后执行下面的语句,限制Mysql root用户可以在指定Ip地址下远程登录
mysql> grant all privileges on . to ‘root’192.168.1.*’%’ identified by ‘你的密码’;

更新权限:
mysql> flush privileges;

退出:
mysql> exit;

这样你的Mysql就可以在192.168.1.*内用Navicat进行远程登录了。

至此,Mysql安装完毕。

安装Nginx:
安装Nginx之前需要安装pcre,进入/usr/local/src目录,解压pcre,进入pcre解压目录,执行以下命令进行编译安装:
[root@jhq0113 pcre-8.35]# ./configure ?prefix=/usr/local/pcre && make && make install

创建web组合web用户,不允许web用户直接登录系统:
[root@jhq0113 pcre-8.35]# groupadd web
[root@jhq0113 pcre-8.35]# useradd -g web web -s /bin/false

编译安装nginx,解压,进入安装目录,执行以下命令:
[root@jhq0113 nginx-1.7.0]# ./configure ?prefix=/usr/local/nginx ?without-http_memcached_module ?user=web ?group=web ?with-http_stub_status_module ?with-openssl=/usr/ ?with-pcre=/usr/local/src/pcre-8.35
注意:?with-pcre=/usr/local/src/pcre-8.31指向的是源码包解压的路径,而不是安装的路径,否则会报错

编译安装:
[root@jhq0113 nginx-1.7.0]# make && make install

编辑Nginx启动命令:
[root@jhq0113 nginx-1.7.0]# vim /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=/usr/local/nginx/logs/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 /usr/local/nginx/logs/nginx.pid

}

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

赋予nginx执行权限:
[root@jhq0113 nginx-1.7.0]# chmod 775 /etc/init.d/nginx

设置nginx开机启动:
[root@jhq0113 nginx-1.7.0]# chkconfig nginx on

启动nginx:
[root@jhq0113 nginx-1.7.0]# service nginx start

测试Nginx安装和启动状态:

至此,Nginx安装完毕,待安装好PHP后再做对PHP的支持和指定自定义发布目录设置。

创建web目录:
[root@jhq0113 nginx-1.7.0]# mkdir -p /home/data/web

未完待续!

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前 By 尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
4 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

11个最佳PHP URL缩短脚本(免费和高级) 11个最佳PHP URL缩短脚本(免费和高级) Mar 03, 2025 am 10:49 AM

长URL(通常用关键字和跟踪参数都混乱)可以阻止访问者。 URL缩短脚本提供了解决方案,创建了简洁的链接,非常适合社交媒体和其他平台。 这些脚本对于单个网站很有价值

Instagram API简介 Instagram API简介 Mar 02, 2025 am 09:32 AM

在Facebook在2012年通过Facebook备受瞩目的收购之后,Instagram采用了两套API供第三方使用。这些是Instagram Graph API和Instagram Basic Display API。作为开发人员建立一个需要信息的应用程序

在Laravel中使用Flash会话数据 在Laravel中使用Flash会话数据 Mar 12, 2025 pm 05:08 PM

Laravel使用其直观的闪存方法简化了处理临时会话数据。这非常适合在您的应用程序中显示简短的消息,警报或通知。 默认情况下,数据仅针对后续请求: $请求 -

构建具有Laravel后端的React应用程序:第2部分,React 构建具有Laravel后端的React应用程序:第2部分,React Mar 04, 2025 am 09:33 AM

这是有关用Laravel后端构建React应用程序的系列的第二个也是最后一部分。在该系列的第一部分中,我们使用Laravel为基本的产品上市应用程序创建了一个RESTFUL API。在本教程中,我们将成为开发人员

简化的HTTP响应在Laravel测试中模拟了 简化的HTTP响应在Laravel测试中模拟了 Mar 12, 2025 pm 05:09 PM

Laravel 提供简洁的 HTTP 响应模拟语法,简化了 HTTP 交互测试。这种方法显着减少了代码冗余,同时使您的测试模拟更直观。 基本实现提供了多种响应类型快捷方式: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

php中的卷曲:如何在REST API中使用PHP卷曲扩展 php中的卷曲:如何在REST API中使用PHP卷曲扩展 Mar 14, 2025 am 11:42 AM

PHP客户端URL(curl)扩展是开发人员的强大工具,可以与远程服务器和REST API无缝交互。通过利用Libcurl(备受尊敬的多协议文件传输库),PHP curl促进了有效的执行

在Codecanyon上的12个最佳PHP聊天脚本 在Codecanyon上的12个最佳PHP聊天脚本 Mar 13, 2025 pm 12:08 PM

您是否想为客户最紧迫的问题提供实时的即时解决方案? 实时聊天使您可以与客户进行实时对话,并立即解决他们的问题。它允许您为您的自定义提供更快的服务

宣布 2025 年 PHP 形势调查 宣布 2025 年 PHP 形势调查 Mar 03, 2025 pm 04:20 PM

2025年的PHP景观调查调查了当前的PHP发展趋势。 它探讨了框架用法,部署方法和挑战,旨在为开发人员和企业提供见解。 该调查预计现代PHP Versio的增长

See all articles