Linux下php+mysql+nginx编译搭建(一)
之前一直都是一键搭建的web服务器,但是一键搭建的环境相对来说都是比较老的。如果要用比较新的环境,特别是正式服务器,就必须自己手动编译搭建了(以下搭建基于linux centos6.5 32位服务器)。 1、 nginx 版本:1.5 下载地址: http://nginx.org/download/
之前一直都是一键搭建的web服务器,但是一键搭建的环境相对来说都是比较老的。如果要用比较新的环境,特别是正式服务器,就必须自己手动编译搭建了(以下搭建基于linux centos6.5 32位服务器)。
1、 nginx
版本:1.5
下载地址: http://nginx.org/download/nginx-1.5.2.tar.gz
2、 mysql
版本5.5
下载地址:http://downloads.mysql.com/archives/mysql-5.0/mysql-5.5.30.tar.gz
3、 php
版本5.4
下载地址:http://am1.php.net/get/php-5.4.34.tar.gz/from/this/mirror
一:安装nginx
安装一些依赖包:
<ol><li> <span>yum </span><span>-</span><span>y install gcc gcc</span><span>-</span><span>c</span><span>++</span><span> gcc</span><span>-</span><span>devel gcc</span><span>-</span><span>c</span><span>++-</span><span>devel ssl ssl</span><span>-</span><span>devel autoconf make aclocal libtool expat</span><span>-</span><span>devel libxml2</span><span>-</span><span>devel openssl openssl</span><span>-</span><span>devel zlib zlib</span><span>-</span><span>devel bzip2 bzip2</span><span>-</span><span>devel gd gd</span><span>-</span><span>devel libmcrypt libmcrypt</span><span>-</span><span>devel libXpm</span><span>-</span><span>devel curl</span><span>-</span><span>devel libgd</span><span>-</span><span>devel gd</span><span>-</span><span>devel openldap</span><span>-</span><span>devel</span> </li></ol>
进入一个目录:
<ol><li> <span>cd </span><span>/</span><span>opt</span><span>/</span> </li></ol>
下载并解压:
<ol> <li> <span>wget http</span><span>:</span><span>//nginx.org/download/nginx-1.5.2.tar.gz</span> </li> <li> <span>tar </span><span>-</span><span>zxf nginx</span><span>-</span><span>1.5</span><span>.</span><span>2.tar</span><span>.</span><span>gz</span> </li> <li> <span>wget http</span><span>:</span><span>//labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz</span> </li> <li> <span>tar </span><span>-</span><span>zxf ngx_cache_purge</span><span>-</span><span>2.1</span><span>.</span><span>tar</span><span>.</span><span>gz</span> </li> </ol>
进入目录并编译:
<ol> <li> <span>cd nginx</span><span>-</span><span>1.5</span><span>.</span><span>2</span> </li> <li> <span>./</span><span>configure </span><span>--</span><span>prefix</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx </span><span>--</span><span>sbin</span><span>-</span><span>path</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>sbin</span><span>/</span><span>nginx </span><span>--</span><span>conf</span><span>-</span><span>path</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>conf</span><span>/</span><span>nginx</span><span>.</span><span>conf </span><span>--</span><span>error</span><span>-</span><span>log</span><span>-</span><span>path</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>log</span><span>/</span><span>error</span><span>.</span><span>log </span><span>--</span><span>http</span><span>-</span><span>log</span><span>-</span><span>path</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>log</span><span>/</span><span>access</span><span>.</span><span>log </span><span>--</span><span>pid</span><span>-</span><span>path</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>run</span><span>/</span><span>nginx</span><span>.</span><span>pid </span><span>--</span><span>user</span><span>=</span><span>www </span><span>--</span><span>group</span><span>=</span><span>www </span><span>--</span><span>with</span><span>-</span><span>http_ssl_module </span><span>--</span><span>with</span><span>-</span><span>http_flv_module </span><span>--</span><span>with</span><span>-</span><span>http_stub_status_module </span><span>--</span><span>with</span><span>-</span><span>http_gzip_static_module </span><span>--</span><span>http</span><span>-</span><span>client</span><span>-</span><span>body</span><span>-</span><span>temp</span><span>-</span><span>path</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>tmp</span><span>/</span><span>client </span><span>--</span><span>http</span><span>-</span><span>proxy</span><span>-</span><span>temp</span><span>-</span><span>path</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>tmp</span><span>/</span><span>proxy</span><span>/</span><span>--</span><span>http</span><span>-</span><span>fastcgi</span><span>-</span><span>temp</span><span>-</span><span>path</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>tmp</span><span>/</span><span>fcgi</span><span>/</span><span>--</span><span>add</span><span>-</span><span>module</span><span>=../</span><span>ngx_cache_purge</span><span>-</span><span>2.1</span><span>--</span><span>with</span><span>-</span><span>pcre</span><span>=../</span><span>pcre</span><span>-</span><span>8.34</span> </li> <li> <span>make </span><span>&&</span><span> make install</span> </li> </ol>
这样就完成了nginx的搭建。
运行:/usr/local/nginx/sbin/nginx
报错:nginx: [emerg] getpwnam("www") failed
在nginx.conf中 把user nobody的注释去掉既可,改成www
再次运行:/usr/local/nginx/sbin/nginx
报错:nginx: [emerg] getpwnam("www") failed in /usr/local/nginx/conf/nginx.conf:1
错误的原因是没有创建www这个用户,应该在服务器系统中添加www用户组和用户www,如下命令:
<ol> <li> <span>groupadd </span><span>-</span><span>f www</span> </li> <li> <span>useradd </span><span>-</span><span>g www www</span> </li> </ol>
第三次运行:/usr/local/nginx/sbin/nginx
报错:nginx: [emerg] mkdir() "/usr/local/nginx/tmp/client" failed (2: No such file or directory)
执行:mkdir -p /usr/local/nginx/tmp/client
然后localhost访问就可以看到:
习惯了了/etc/init.d/nginx start?觉得/usr/local/nginx/sbin/nginx 太长?
Vim /etc/init.d/nginx
<ol> <li><span>#!/bin/bash</span></li> <li><span>#</span></li> <li><span># Init file for nginx server daemon</span></li> <li><span>#</span></li> <li><span># chkconfig: 234 99 99</span></li> <li><span># description: nginx server daemon</span></li> <li><span>#</span></li> <li><span># source function library</span></li> <li> <span>.</span><span>/</span><span>etc</span><span>/</span><span>rc</span><span>.</span><span>d</span><span>/</span><span>init</span><span>.</span><span>d</span><span>/</span><span>functions</span> </li> <li><span># pull in sysconfig settings</span></li> <li> <span>[</span><span>-</span><span>f </span><span>/</span><span>etc</span><span>/</span><span>sysconfig</span><span>/</span><span>nginx </span><span>]</span><span>&&</span><span>.</span><span>/</span><span>etc</span><span>/</span><span>sysconfig</span><span>/</span><span>nginx</span> </li> <li> <span>RETVAL</span><span>=</span><span>0</span> </li> <li> <span>prog</span><span>=</span><span>"nginx"</span> </li> <li> <span>PAT</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span> </li> <li> <span>NGINXD</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>sbin</span><span>/</span><span>nginx</span> </li> <li> <span>PID_FILE</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>nginx</span><span>/</span><span>nginx</span><span>.</span><span>pid</span> </li> <li> <span>start</span><span>()</span> </li> <li><span>{</span></li> <li> <span>echo </span><span>-</span><span>n $</span><span>"Starting $prog: "</span> </li> <li> <span>$NGINXD </span><span>2</span><span>></span><span>/dev/</span><span>null</span><span> $OPTIONS </span><span>&&</span><span> success </span><span>||</span><span> failure</span> </li> <li> <span>RETVAL</span><span>=</span><span>$</span><span>?</span> </li> <li> <span>[</span><span>"$RETVAL"</span><span>=</span><span>0</span><span>]</span><span>&&</span><span> touch </span><span>/</span><span>var</span><span>/</span><span>lock</span><span>/</span><span>subsys</span><span>/</span><span>nginx</span> </li> <li><span>echo</span></li> <li><span>}</span></li> <li> <span>stop</span><span>()</span> </li> <li><span>{</span></li> <li> <span>echo </span><span>-</span><span>n $</span><span>"Shutting down $prog: "</span> </li> <li><span>killproc nginx</span></li> <li> <span>RETVAL</span><span>=</span><span>$</span><span>?</span> </li> <li><span>echo</span></li> <li> <span>[</span><span> $RETVAL </span><span>-</span><span>eq </span><span>0</span><span>]</span><span>&&</span><span> rm </span><span>-</span><span>f </span><span>/</span><span>var</span><span>/</span><span>lock</span><span>/</span><span>subsys</span><span>/</span><span>nginx</span> </li> <li> <span>return</span><span> $RETVAL</span> </li> <li><span>}</span></li> <li> <span>reload</span><span>()</span> </li> <li><span>{</span></li> <li> <span>echo </span><span>-</span><span>n $</span><span>"Reloading nginx: "</span> </li> <li> <span>killproc nginx </span><span>-</span><span>HUP</span> </li> <li> <span>RETVAL</span><span>=</span><span>$</span><span>?</span> </li> <li><span>echo</span></li> <li> <span>return</span><span> $RETVAL</span> </li> <li><span>}</span></li> <li> <span>case</span><span>"$1"</span><span>in</span> </li> <li> <span>"start"</span><span>)</span> </li> <li><span>start</span></li> <li><span>;;</span></li> <li> <span>"stop"</span><span>)</span> </li> <li><span>stop</span></li> <li><span>;;</span></li> <li> <span>"restart"</span><span>)</span> </li> <li><span>stop</span></li> <li><span>start</span></li> <li><span>;;</span></li> <li> <span>"reload"</span><span>)</span> </li> <li><span>reload</span></li> <li><span>;;</span></li> <li> <span>"status"</span><span>)</span> </li> <li> <span>status </span><span>-</span><span>p $PID_FILE nginx</span> </li> <li> <span>RETVAL</span><span>=</span><span>$</span><span>?</span> </li> <li><span>;;</span></li> <li><span>*)</span></li> <li><span> </span></li> <li> <span>echo $</span><span>"Usage: $0 {start|stop|restart|reload|status}"</span> </li> <li> <span>RETVAL</span><span>=</span><span>1</span> </li> <li><span>esac</span></li> <li> <span>exit</span><span> $RETVAL</span> </li> </ol>
保存,添加x权限。
如需开机启动:
chkconfig nginx on
更多请支持:http://www.webyang.net/Html/web/article_127.html

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds

Deepseek est un puissant outil de recherche et d'analyse intelligent qui fournit deux méthodes d'accès: la version Web et le site officiel. La version Web est pratique et efficace et peut être utilisée sans installation; Que ce soit des individus ou des utilisateurs d'entreprise, ils peuvent facilement obtenir et analyser des données massives via Deepseek pour améliorer l'efficacité du travail, aider la prise de décision et promouvoir l'innovation.

Il existe de nombreuses façons d'installer Deepseek, notamment: Compiler à partir de Source (pour les développeurs expérimentés) en utilisant des packages précompilés (pour les utilisateurs de Windows) à l'aide de conteneurs Docker (pour le plus pratique, pas besoin de s'inquiéter de la compatibilité), quelle que soit la méthode que vous choisissez, veuillez lire Les documents officiels documentent soigneusement et les préparent pleinement à éviter des problèmes inutiles.

OUYI OKX, le premier échange mondial d'actifs numériques, a maintenant lancé un package d'installation officiel pour offrir une expérience de trading sûre et pratique. Le package d'installation OKX de OUYI n'a pas besoin d'être accessible via un navigateur. Le processus d'installation est simple et facile à comprendre.

Bitget est un échange de crypto-monnaie qui fournit une variété de services de trading, notamment le trading au comptant, le trading de contrats et les dérivés. Fondée en 2018, l'échange est basée à Singapour et s'engage à fournir aux utilisateurs une plate-forme de trading sûre et fiable. Bitget propose une variété de paires de trading, notamment BTC / USDT, ETH / USDT et XRP / USDT. De plus, l'échange a une réputation de sécurité et de liquidité et offre une variété de fonctionnalités telles que les types de commandes premium, le trading à effet de levier et le support client 24/7.

Gate.io est un échange de crypto-monnaie populaire que les utilisateurs peuvent utiliser en téléchargeant son package d'installation et en l'installant sur leurs appareils. Les étapes pour obtenir le package d'installation sont les suivantes: Visitez le site officiel de Gate.io, cliquez sur "Télécharger", sélectionnez le système d'exploitation correspondant (Windows, Mac ou Linux) et téléchargez le package d'installation sur votre ordinateur. Il est recommandé de désactiver temporairement les logiciels antivirus ou le pare-feu pendant l'installation pour assurer une installation fluide. Une fois terminé, l'utilisateur doit créer un compte Gate.io pour commencer à l'utiliser.

Ouyi, également connu sous le nom d'OKX, est une plate-forme de trading de crypto-monnaie de pointe. L'article fournit un portail de téléchargement pour le package d'installation officiel d'Ouyi, qui facilite les utilisateurs pour installer le client Ouyi sur différents appareils. Ce package d'installation prend en charge les systèmes Windows, Mac, Android et iOS. Une fois l'installation terminée, les utilisateurs peuvent s'inscrire ou se connecter au compte OUYI, commencer à négocier des crypto-monnaies et profiter d'autres services fournis par la plate-forme.

Comment définir automatiquement les autorisations d'UnixSocket après le redémarrage du système. Chaque fois que le système redémarre, nous devons exécuter la commande suivante pour modifier les autorisations d'UnixSocket: sudo ...

Causes et solutions pour les erreurs Lors de l'utilisation de PECL pour installer des extensions dans un environnement Docker Lorsque nous utilisons un environnement Docker, nous rencontrons souvent des maux de tête ...
