搜尋
首頁資料庫mysql教程yum装配nginx+mysql+php

yum安装nginx+mysql+php 命令准备 创建目录 mkdir 目录名 chmod 777 目录名 变更权限 加入开机启动项服务 chkconfig --add php-fpm chkconfig nginx on 查找文件位置 经常用于查找yum安装后各种配置文件及启动程序所在位置 find|grep php-fpm 服务启动 servic

yum安装nginx+mysql+php

命令准备

创建目录

mkdir 目录名

chmod 777 目录名 变更权限

加入开机启动项服务

chkconfig --add php-fpm

chkconfig nginx on 

查找文件位置 经常用于查找yum安装后各种配置文件及启动程序所在位置

find|grep php-fpm

服务启动

service nginx
start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest

service nginx  start

service php-fpm start

查看进程

ps -ef | grep java

查看进程

kill -9 进程id

1.安装

添加nginx源

http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm 

wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

rpm -qa | grep nginx 检查nginx 是否加入源路径


安装 php mysql nginx

yum install mysql mysql-server php php-mysql php-fpm nginx


php组件库 选择安装 如果找不到源地址,请查找小技巧里面的更新第三方源库

yum install php-cli php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy php-common php-devel


2.配置

2.1nginx 配置

配置文件位置 如果找不到相关配件,查找文件位置 命令
/etc/nginx/nginx.conf
/etc/nginx/conf.d/*.conf
 
多个站点放在conf.d目录,在nginx.conf用include语法包含
include /etc/nginx/conf.d/*.conf;


默认default.conf修改

server {
    listen       80;
    server_name  localhost;<span>#自定义域名配置</span>

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /home/www;<span>#自定义目录设置</span>
        index  index.html index.htm<span> index.php</span>;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #<span>错误页处理</span>
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /home/www;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        #root           /home/www;
        #fastcgi_pass   127.0.0.1:9000;
	<span>fastcgi_pass  unix:/tmp/php-cgi.sock;#这种方式听说性能提升比较多</span>
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/www$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

类似

其他*.conf 可自定义添加

server
	{
		listen       80;
		server_name wx.vtz.cc;
		index index.html index.htm index.php;
		root  /home/wwwroot/weixin;

		location ~ .*\.(php|php5)?$
			{
				try_files $uri =404;
				fastcgi_pass  unix:/tmp/php-cgi.sock;
				fastcgi_index index.php;
				include fcgi.conf;
			}

		location /status {
			stub_status on;
			access_log   off;
		}

		location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
			{
				expires      30d;
			}

		location ~ .*\.(js|css)?$
			{
				expires      12h;
			}

		access_log  /home/wwwlogs/weixin_access.log  access;
	}

2.2  php-fpm.conf配置

include=/etc/php-fpm.d/*.conf  //因为包含其他文件,/etc/php-fpm.d查找到www.conf 修改

[www] 

#设置监听 修改项

#listen = 127.0.0.1:9000
listen = /tmp/php-cgi.sock


3.添加服务自启动

nginx 服务
chkconfig --add nginx 
chkconfig nginx on
service nginx start

php-fpm
chkconfig --add php-fpm 
chkconfig php-fpm on
service php-fpm start

mysql
chkconfig --add mysqld 
chkconfig mysqld on
service mysqld start

默认root 密码空

小技能:

1.php开启错误提示

<span><strong>vim</strong></span> <span>/</span>etc<span>/</span>php5<span>/</span>fpm<span>/</span>php.ini

打开错误提示

display_errors = On

因为用到的四fpm与nginx配合,所以还需要修改php-fpm.conf文件

<span><strong>vim</strong></span> <span>/</span>etc<span>/</span>php5<span>/</span>fpm<span>/</span>php-fpm.conf

再最后添加 有可能在此配置文件里面 www.conf

php_flag<span><strong>[</strong></span>display_errors<span><strong>]</strong></span> = on

让后从新读取nginx配置

<span><strong>sudo</strong></span> service nginx reload

2.其他安装参考

  1. 配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有nginx软件包)
    1 yum install wget
    2 wget http://www.atomicorp.com/installers/atomic
    3 sh ./atomic
    4 yum update
  2. 安装开发包和库文件
    1 yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng
    2 libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel
    3 gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2
    4 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
  3. 卸载已安装的apache、mysql、php
    1 yum remove httpd
    2 yum remove mysql
    3 yum remove php

  4. 安装nginx
    1 yum install nginx
    2 service nginx start
    3 chkconfig --levels 235 nginx on
  5. 安装mysql
    1 yum install mysql mysql-server mysql-devel
    2 service mysqld start
    3 chkconfig --levels 235 mysqld on
    4 mysqladmin -u root password "密码" <span></span>service mysqld restart
  6. 安装php
    1 yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap
    2 php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap
    3 php-tidy php-common php-devel php-fpm
    4  
    5 service php-fpm start
    6  
    7 chkconfig --levels 235 php-fpm on
  7. 配置nginx支持php
    1 mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
    2 cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
    3 vi /etc/nginx/nginx.conf
    在文件中加入 
    1 location ~ \.php$ {
    2             root           /usr/share/nginx/html;
    3             fastcgi_pass   127.0.0.1:9000;
    4             fastcgi_index  index.php;
    5             fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
    6             include        fastcgi_params;
    7 }
  8. 重启nginx php-fpm
    view source print?
    1 service nginx restart
    2 service php-fpm restart

3.服务器状况php函数组件探针

下载地址

4.mysql 新建用户外网访问

insert into mysql.user(Host,User,Password) values("%","admin",password("1234"));
update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";
grant all privileges on *.* to 'yourname'@'%' identified by 'youpasswd';   //密码为必填项
flush privileges;

5.linux svn搭建 版本库

1、 # yum install subversion
2、新建一个目录用于存储SVN所有文件
    # mkdir /home/svn
3、在上面创建的文件夹中为项目 project_1 创建一个版本仓库
      # svnadmin create /home/svn/project_1
      执行完这一步,/home/svn 中将存在project_1文件夹,这个项目的配置都在 /home/svn/project_1/conf 中

4、为项目配置权限
   (1)svnserve.conf 是主配置文件
        # vi /home/svn/project_1/conf/svnserve.conf
        anon-access=read          #匿名可读
        auth-access=write         #验证用户可读写
        password-db=passwd        #指向验证用户名密码的数据文件 passwd ,请看下文配置
        auth-db=authz             #指向验证用户的权限配置文件 authz ,请看下文配置
        注意:每一行前方不能有空格,否则会出现 Option expected 错误!
   (2)passwd 用户名密码配置文件 
        # vi /home/svn/project_1/conf/passwd
        [users]
        manager1=123456       #每一行都要是“用户名=密码”的格式
        manager2=123123 
        manager3=888888
   (3)authz 用户权限配置文件 
        # vi /home/svn/project_1/conf/authz
        [groups]
        managers=manager1,manager2         #定义群组 managers 包含 manager1 和 manager2 两个用户
        [/]
        @managers=rw                       #定义群组 managers 有读写权限
        manager3=r                         #定义 manager3 有读权限
        *=                                 #以上没有定义的用户都没有任何权限
4,启动和停止SVN服务
启动SVN服务:
[root@svn ~]# svnserve -d -r /data/svndata/
-d表示后台运行
-r 指定根目录是 /data/svndata/
停止SVN服务:
ps -aux |grep svn
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
在MySQL中使用視圖的局限性是什麼?在MySQL中使用視圖的局限性是什麼?May 14, 2025 am 12:10 AM

mysqlviewshavelimitations:1)他們不使用Supportallsqloperations,限制DatamanipulationThroughViewSwithJoinsOrsubqueries.2)他們canimpactperformance,尤其是withcomplexcomplexclexeriesorlargedatasets.3)

確保您的MySQL數據庫:添加用戶並授予特權確保您的MySQL數據庫:添加用戶並授予特權May 14, 2025 am 12:09 AM

porthusermanagementinmysqliscialforenhancingsEcurityAndsingsmenting效率databaseoperation.1)usecReateusertoAddusers,指定connectionsourcewith@'localhost'or@'%'。

哪些因素會影響我可以在MySQL中使用的觸發器數量?哪些因素會影響我可以在MySQL中使用的觸發器數量?May 14, 2025 am 12:08 AM

mysqldoes notimposeahardlimitontriggers,butacticalfactorsdeterminetheireffactective:1)serverConfiguration impactactStriggerGermanagement; 2)複雜的TriggerSincreaseSySystemsystem load; 3)largertablesslowtriggerperfermance; 4)highConconcConcrencerCancancancancanceTigrignecentign; 5); 5)

mysql:存儲斑點安全嗎?mysql:存儲斑點安全嗎?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

mySQL:通過PHP Web界面添加用戶mySQL:通過PHP Web界面添加用戶May 14, 2025 am 12:04 AM

通過PHP網頁界面添加MySQL用戶可以使用MySQLi擴展。步驟如下:1.連接MySQL數據庫,使用MySQLi擴展。 2.創建用戶,使用CREATEUSER語句,並使用PASSWORD()函數加密密碼。 3.防止SQL注入,使用mysqli_real_escape_string()函數處理用戶輸入。 4.為新用戶分配權限,使用GRANT語句。

mysql:blob和其他無-SQL存儲,有什麼區別?mysql:blob和其他無-SQL存儲,有什麼區別?May 13, 2025 am 12:14 AM

mysql'sblobissuitableForStoringBinaryDataWithInareLationalDatabase,而ilenosqloptionslikemongodb,redis和calablesolutionsolutionsolutionsoluntionsoluntionsolundortionsolunsonstructureddata.blobobobissimplobisslowdeperformberbutslowderformandperformancewithlararengedata;

mySQL添加用戶:語法,選項和安全性最佳實踐mySQL添加用戶:語法,選項和安全性最佳實踐May 13, 2025 am 12:12 AM

toaddauserinmysql,使用:createUser'username'@'host'Indessify'password'; there'showtodoitsecurely:1)choosethehostcarecarefullytocon trolaccess.2)setResourcelimitswithoptionslikemax_queries_per_hour.3)usestrong,iniquepasswords.4)Enforcessl/tlsconnectionswith

MySQL:如何避免字符串數據類型常見錯誤?MySQL:如何避免字符串數據類型常見錯誤?May 13, 2025 am 12:09 AM

toAvoidCommonMistakeswithStringDatatatPesInMysQl,CloseStringTypenuances,chosethirtightType,andManageEngencodingAndCollat​​ionsEttingSefectery.1)usecharforfixed lengengtrings,varchar forvariable-varchar forbariaible length,andtext/blobforlargerdataa.2 seterters seterters seterters

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具