在centos 7上装载php7.0.2、mysql 5.7.11 和 nginx-1.9.12

来源:互联网 发布:画线主图公式源码 编辑:程序博客网 时间:2024/06/05 01:53
Installation of php7 and mysql 5.7.11 and nginx on centos 7

wget php7
tar zxvf php-7.0.2.tar.gz
cd php-7.0.2
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
make &&  make install
make test


groupadd mysql
useradd -r -g mysql -s /bin/false mysql
tar zxvf /path/to/mysql-VERSION-OS.tar.gz
cd /usr/local/
ln -s full-path-to-mysql-VERSION-OS mysql
cd mysql
mkdir mysql-files
chmod 750 mysql-files
chown -R mysql .
chgrp -R mysql .
mkdir data
chmod 777 data
bin/mysqld --initialize --user=mysql
bin/mysql_ssl_rsa_setup
chown -R root .
chown -R mysql data mysql-files
bin/mysqld_safe --user=mysql &
cp support-files/mysql.server /etc/init.d/mysql.server
开启:service mysql start
./bin/mysqladmin -u root password -p
用刚才bin/mysqld --initialize --user=mysql提供的临时密码登录然后输入新的密码

最后,设定远程登录mysql。Linux下为了安全默认不允许mysql本机以外的机器访问mysql数据库服务,
需要重新授权root,方便远程访问。

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select Host,User from user;
+-----------+-----------+
| Host      | User      |
+-----------+-----------+
| %         | root      |
| localhost | mysql.sys |
| localhost | root      |
+-----------+-----------+
3 rows in set (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' identified by 'password';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

授权语句最后的‘password’是mysql数据库root用户的新密码。

修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码
PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin
export PATH

执行命令source /etc/profile 或 执行点命令 ./profile使其修改生效,
执行完可通过echo $PATH命令查看是否添加成功。

nginx是最繁琐的,关键点是解决所有依赖。而且注意版本,对于所需要的依赖的版本是有要求的,
不是所有版本都可以(会出现缺少文件的问题)

4、下载pcre (支持nginx伪静态)

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz

5、下载openssl(nginx扩展)

http://www.openssl.org/source/openssl-1.0.1h.tar.gz

6、下载zlib(nginx扩展)

http://zlib.net/zlib-1.2.8.tar.gz



1、安装pcre

cd /usr/local/src

mkdir /usr/local/pcre

tar zxvf pcre-8.35.tar.gz

cd pcre-8.35

./configure --prefix=/usr/local/pcre

make

make install

2、安装openssl

cd /usr/local/src

mkdir /usr/local/openssl

tar zxvf openssl-1.0.1h.tar.gz

cd openssl-1.0.1h

./config --prefix=/usr/local/openssl

make

make install

vi /etc/profile

export PATH=$PATH:/usr/local/openssl/bin

:wq!

source /etc/profile

3、安装zlib

cd /usr/local/src

mkdir /usr/local/zlib

tar zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure --prefix=/usr/local/zlib

make

make install

4、安装Nginx

groupadd www

useradd -g www www -s /bin/false

cd /usr/local/src

tar zxvf nginx-1.6.0.tar.gz

cd nginx-1.6.0

./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35

注意:--with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35指向的是源码包解压的路径,而不是安装的路径,否则会报错

make

make install

/usr/local/nginx/sbin/nginx #启动Nginx

设置nginx开机启动

vi /etc/rc.d/init.d/nginx  #编辑启动文件添加下面内容


############################################################

#!/bin/sh

#

# nginx - this script starts and stops the nginx daemon

#

# chkconfig: - 85 15

# description: Nginx is an HTTP(S) server, HTTP(S) reverse \

# proxy and IMAP/POP3 proxy server

# processname: nginx

# config: /etc/nginx/nginx.conf

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

# pidfile: /usr/local/nginx/logs/nginx.pid

# Source function library.

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

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

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

nginx="/usr/local/nginx/sbin/nginx"

prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {

# make required directories

user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`

if [ -z "`grep $user /etc/passwd`" ]; then

useradd -M -s /bin/nologin $user

fi

options=`$nginx -V 2>&1 | grep 'configure arguments:'`

for opt in $options; do

if [ `echo $opt | grep '.*-temp-path'` ]; then

value=`echo $opt | cut -d "=" -f 2`

if [ ! -d "$value" ]; then

# echo "creating" $value

mkdir -p $value && chown -R $user $value

fi

fi

done

}

start() {

[ -x $nginx ] || exit 5

[ -f $NGINX_CONF_FILE ] || exit 6

make_dirs

echo -n $"Starting $prog: "

daemon $nginx -c $NGINX_CONF_FILE

retval=$?

echo

[ $retval -eq 0 ] && touch $lockfile

return $retval

}

stop() {

echo -n $"Stopping $prog: "

killproc $prog -QUIT

retval=$?

echo

[ $retval -eq 0 ] && rm -f $lockfile

return $retval

}

restart() {

#configtest || return $?

stop

sleep 1

start

}

reload() {

#configtest || return $?

echo -n $"Reloading $prog: "

killproc $nginx -HUP

RETVAL=$?

echo

}

force_reload() {

restart

}

configtest() {

$nginx -t -c $NGINX_CONF_FILE

}

rh_status() {

status $prog

}

rh_status_q() {

rh_status >/dev/null 2>&1

}

case "$1" in

start)

rh_status_q && exit 0

$1

;;

stop)

rh_status_q || exit 0

$1

;;

restart|configtest)

$1

;;

reload)

rh_status_q || exit 7

$1

;;

force-reload)

force_reload

;;

status)

rh_status

;;

condrestart|try-restart)

rh_status_q || exit 0

;;

*)

echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"

exit 2

esac

############################################################

系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链

:wq! #保存退出

chmod 775 /etc/rc.d/init.d/nginx #赋予文件执行权限

chkconfig nginx on #设置开机启动

/etc/rc.d/init.d/nginx restart #重启

访问,查看是否成功显示Nginx欢迎页面!


0 0
原创粉丝点击