Centos6.X下安装php nginx mysql 环境
---------------------------------------更换163软件源,此步可以省略,记得把repo文件里面的6.5改成当前版本号
yum makecache && yum -y update
---------------------------------------配置防火墙,开启80端口、3306端口
备注:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,
正确的应该是添加到默认的22端口这条规则的下面
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 9000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
---------------------------------------关闭SELINUX
vi /etc/selinux/config
-----------------------------------
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加这一行
------------------------------#重启系统
reboot
---------------------------------------依赖组件
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre-devel zlib-devel gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* unzip vim
---------------------------------------安装pcre,默认gz文件包位置:/usr/local/src
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 && cd ../
---------------------------------------安装mysql
groupadd mysql && useradd -g mysql mysql -s /bin/false && mkdir -p /home/mysqldata && chown -R mysql:mysql /home/mysqldata && mkdir -p /usr/local/mysql && cd /usr/local/src && tar zxvf mysql-5.1.56.tar.gz && cd mysql-5.1.56
./configure --prefix=/usr/local/mysql --localstatedir=/home/mysqldata --enable-assembler --enable-static --with-mysqld-user=mysql --with-big-tables --enable-thread-safe-client --enable-local-infile --with-charset-utf8 --with-extra-charsets=all && make && make install
cp ./support-files/my-huge.cnf /etc/my.cnf
vim /etc/my.cnf
=============在[mysqld]中增加下面一行
datadir = /home/mysqldata
=============
./scripts/mysql_install_db --user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld chkconfig mysqld on
vim /etc/rc.d/init.d/mysqld
============================下面两个参数,等号后面是空,把后面的添加进去
basedir = /usr/local/mysql
datadir = /home/mysqldata
============================
service mysqld start
vim /etc/profile
=====================================================在export之后增加下面这一行
export PATH=$PATH:/usr/local/mysql/bin
=====================================================
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
---------------------------------------安装 nginx
cd /usr/local/src
groupadd www && useradd -g www www -s /bin/false && mkdir -p /usr/local/nginx && tar zxvf nginx-1.7.3.tar.gz && cd nginx-1.7.3 && ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.35
make && make install
vim /etc/rc.d/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
=======================================================
:x!保存退出
chmod 775 /etc/rc.d/init.d/nginx
chkconfig nginx on
service nginx restart
===========================上面这一步执行完之后,就可以在浏览器里面输入虚拟机的ip地址访问了
---------------------------------------php组件支持软件安装
cd /usr/local/src && tar -zxvf libiconv-1.13.1.tar.gz && cd libiconv-1.13.1/ && ./configure --prefix=/usr/local && make && make install && cd ../ tar -zxvf libmcrypt-2.5.7.tar.gz && cd libmcrypt-2.5.7/ && ./configure && make && make install && /sbin/ldconfig && cd libltdl/ && ./configure --enable-ltdl-install && make && make install && cd ../../ tar -zxvf mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9/ && ./configure && make && make install && cd ../ ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config tar -zxvf mcrypt-2.6.8.tar.gz &&cd mcrypt-2.6.8/ && /sbin/ldconfig && ./configure && make && make install && cd ../ cd /usr/local/src && tar -zvxf php-5.3.10.tar.gz && cd php-5.3.10 && mkdir -p /usr/local/php
---------------------------------------x64库文件支持,x64才需要执行下面这一行
cp -frp /usr/lib64/libldap* /usr/lib/
---------------------------------------nginx
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-iconv-dir=/usr/local/ --with-freetype-dir --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-jpeg-dir --with-png-dir --with-zlib --with-mhash --enable-sockets --enable-ftp --with-libxml-dir --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-fpm --with-xmlrpc --enable-zip --enable-soap --without-pear
---------------------------------------
make ZEND_EXTRA_LIBS='-liconv'
make install cp php.ini-production /usr/local/php/etc/php.ini
ln -s /usr/local/php/etc/php.ini /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf
======================================下面的前面五行是增加,后面两行是前面参数在,后面的加上www,最后一排好像是把前面的分号去掉就可以了
[global]
pid = run/php-fpm.pid [www]
pm.max_children = 64
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 1024 user = www
group = www
============================= cp /usr/local/src/php-5.3.10/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig php-fpm on
vim /usr/local/php/etc/php.ini
=============================================php.ini文件用默认的也可以,这里面的有引起配置有问题
找到:;open_basedir =
修改为:open_basedir = .:/tmp/ #防止php木马跨站,重要!!========这一句好像有问题
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_php = On
修改为:expose_php = OFF #禁止显示php版本的信息
找到:display_errors = On
修改为:display_errors = OFF #关闭错误提示
==============================================================================
---------------------------------------配置nginx支持php
vim /usr/local/nginx/conf/nginx.conf
===========================================这里面的配置注意找一下,有的是增加后面的值,有的是去掉分号就可以了
user www www;
=========================================http{}这一个节点的大括号里面添加这个
autoindex on; #开启nginx目录浏览功能
autoindex_exact_size off; #文件大小从KB开始显示
autoindex_localtime on; #显示文件修改时间为服务器本地时间 其中server段增加如下配置:
# 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 /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
其中 location /{} 中 index index.html index.htm 改为
index index.php index.html index.htm;
===========================================
到这一步就算完成了,下面的是配置zend加密以及多域名绑定的
==================pdo-mysql支持20140716
cd /usr/local/src && tar zxvf pdo_mysql-1.0.2.tgz && cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make && make install
vim /usr/local/php/etc/php.ini
==========================找到extension=php-mysql.dll后面添加一行
extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/pdo_mysql.so"
---------------------------------------配置php支持Zend Guard
安装Zend Guard
cd /usr/local/src && mkdir /usr/local/zend
tar xvfz ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
tar xvfz ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ ##64位
cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ ##32位
vim + /usr/local/php/etc/php.ini##最后一行的下面添加
====================================================
[Zend Guard]
zend_extension=/usr/local/zend/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
============================================
---------------------------------------
mkdir -p /home/www/vhosts/ && mkdir -p /home/www/html/ && chown -R www:www /home/www/vhosts/ && chown www.www /home/www/html/ -R && chmod 700 /home/www/html/ -R
---------------------------------------测试及相关组件参数
cd /usr/local/nginx/html/ #进入nginx默认网站根目录
vim index.php #新建index.php文件
====================
<?php
phpinfo();
?>
======================完成后重启才能有效=====================
http://192.168.9.8/index.php
#############################################################################
---------------------------------------多域名支持
vim /usr/local/nginx/conf/nginx.conf
==========================================
include /home/www/vhosts/*.conf;
==========================================
CREATE USER chy@localhost IDENTIFIED BY '123456';
grant all on qyoa.* to chy@localhost;
grant alter,create,delete,drop,index,insert,select,update on qyoa.* to chy@localhost;
========================================== 1.2.2 设置mysql密码
mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
1.2.3 允许远程登录
mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
完成后就能用mysql-front远程管理mysql了。 ============================第二种yum安装方法============================
CentOS下yum安装LAMP 1. 用yum安装Apache,Mysql,PHP.
1.1安装Apache
yum install httpd httpd-devel
安装完成后,用/etc/init.d/httpd start 启动apache
设为开机启动:chkconfig httpd on
1.2 安装mysql
1.2.1 yum install mysql mysql-server mysql-devel
同样,完成后,用/etc/init.d/mysqld start 启动mysql
1.2.2 设置mysql密码
mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
1.2.3 允许远程登录
mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
完成后就能用mysql-front远程管理mysql了。
1.2.4 设为开机启动
chkconfig mysqld on
2. 安装php
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
/etc/init.d/httpd start
3. 测试一下
3.1在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。
<?
phpinfo();
?>
3.2 防火墙配置
a.添加.允许访问端口{21: ftp, 80: http}.
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
b.关闭防火墙{不推荐}.
service iptables stop
c.重置加载防火墙
service iptables restart
3.3然后在客户端浏览器里打开http://serverip/test.php,若能成功显示,则表示安装成功。
至此,安装完毕。感慨,yum真是太好用了。
CentOS 打开防火墙80端口 注意:有时安装好可能无法访问,需要打开80端口
很大的原因是防火墙:
通过/etc/init.d/iptables status命令查询是否有打开80端口,如果没有可通过两种方式处理:
1.修改vi /etc/sysconfig/iptables命令添加使防火墙开放80端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
2.关闭防火墙
/etc/init.d/iptables stop
#start 开启
#restart 重启
永久性关闭防火墙chkconfig --level 35 iptables off
环境包下载地址: http://pan.baidu.com/s/1i3XTcoP
Centos6.X下安装php nginx mysql 环境的更多相关文章
- centos6.4下安装php7+nginx+mariadb环境
一,安装php71,创建php用户和用户组,并在github下载php7源码#新建php用户和php组# groupadd -r php && useradd -r -g php -s ...
- Mac下安装 php+nginx+mysql 开发环境
一.mysql安装 mysql是安装最简单顺利的 1. 首先去官方网站下载Mac适用的MySQL的dmg包 下载页面 选择图中最下方的dmg包下载进行安装 安装完成后 MySQL的安装目录为/usr/ ...
- CentOS-6.5下安装navicat for mysql
一.安装前准备 安装epel源 安装wine 如果不安装wine,则可能会出现安装完navicat for mysql后无法启动的情况. 二.安装epel源 cd /tmp ...
- centos6.5下安装jdk并配置环境变量
链接: https://blog.csdn.net/wawawawawawaa/article/details/81158943 以下链接供参考: https://blog.csdn.net/Bugg ...
- Ubunt16.04下安装PHP7+Nginx+MySQL
本文通过Ubuntu PPA来安装PHP7. 1.添加PPA $ sudo apt-get install python-software-properties software-properti ...
- CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档
----------------CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档----------------------- [JDK1.7安 ...
- 64位Win7下安装与配置PHP环境【Apache+PHP+MySQL】
[软件下载] 本安装实例所使用安装文件如图所示: 其中,64位版本的MySQL安装文件mysql-5.5.33-winx64.msi,可直接从官网下载,下载地址:http://dev.mysql.co ...
- CentOS6.5下安装配置MySQL
CentOS6.5下安装配置MySQL,配置方法如下: 安装mysql数据库:# yum install -y mysql-server mysql mysql-deve 查看mysql-server ...
- 建站笔记1:centos6.5下安装mysql
近期买了个域名,想要玩玩自己建站点:接下来遇到的问题都会一次记录下来.以备自己以后复习查看: 首先建站方案选择: wordPress +centos6.5 +mysql; server买的:搬瓦工最低 ...
随机推荐
- 不是技术牛人,如何拿到国内IT巨头的Offer(转载)
转载的文章,中间有几段需要去学习. byvoid 面阿里星计划的面试结果截图泄漏,引起无数IT屌丝的羡慕敬仰.看看这些牛人,NOI金牌,开源社区名人,三年级开始写Basic-在跪拜之余我们不禁要想,和 ...
- 使用属性动画简单实现view飞入效果
比较简单的效果,可以用来菜单飞入之类,作为记录吧, package com.test.animation; import android.app.Activity; import android.os ...
- iOS开发中的4种数据持久化方式【二、数据库 SQLite3、Core Data 的运用】
在上文,我们介绍了ios开发中的其中2种数据持久化方式:属性列表.归档解档.本节将继续介绍另外2种iOS持久化数据的方法:数据库 SQLite3.Core Data 的运 ...
- linux文件上传
租了个服务器,要把自己打的war包打上去发布,服务器是linux的(本机是mac).以前都是用wget命令,把需要上传的东西先放到github上面再在服务器上用wget命令下载.最近不知道什么原因,w ...
- Linux:远程到linux的图形界面
一般linux都没有安装图形界面,可以通过VNC服务来实现步骤如下: 一.安装vnc server1.查看是否安装vncrpm -q vnc-serverpackage vnc is not inst ...
- COOKIE&&SESSION
---------------------------------------------------------------------------COOKIE------------------- ...
- 关于rand()与srand()函数
rand函数功能为获取一个伪随机数(伪随机数的概念下面会有介绍). 一.函数名: rand(); 二.声明: int rand(); 三.所在头文件: stdlib.h 四.功能: 返回一个伪随机数. ...
- c#基础-oop(面向对象理解)
OOP-面向对象 封装,继承多态 一个桌子,用面向对象来描述一下它这个桌子项目 定义桌子类 对象:桌子 桌子的属性:名字,材质,体积 桌子的方法;放东西(方法) 现在桌子要放书,放花瓶,放文件(这里就 ...
- Flex_控件
1.Text控件 外观: 代码: <?xml version="1.0" encoding="utf-8"?> <s:Application ...
- mysql问题小结
1.数据表存在,但查询时提示不存在 原因:默认情况下,mysql在windows对表名大小不敏感(lower_case_table_names=1),在linux上大小敏感(lower_case_ta ...