linux下nginx+php+mysql环境搭建 ++++++++++++++++++++++++++++++++++++++++++++++ 操作系统 : [CentOS6.0] 服务器 : [nginx-1.1.8] PHP : [php-5.2.6] 数据库 : [mysql-5.1.59] ++++++++++++++++++++++++++++++++++++++++++++++ 准备安装软件(download) 1[n
linux下nginx+php+mysql环境搭建
++++++++++++++++++++++++++++++++++++++++++++++
操作系统 : [CentOS6.0]
服务器 : [nginx-1.1.8]
PHP : [php-5.2.6]
数据库 : [mysql-5.1.59]
++++++++++++++++++++++++++++++++++++++++++++++
准备安装软件(download)
1>[nginx-1.1.8] http://nginx.org/download/nginx-1.1.8.tar.gz
2>[php-5.2.6] http://museum.php.net/php5/php-5.2.6.tar.gz
3>[php-5.2.6-fpm-0.5.8.diff.gz] http://php-fpm.org/downloads/php-5.2.6-fpm-0.5.8.diff.gz
4>[mysql-5.1.59] http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.59.tar.gz
5>[libxml2-2.6.30] http://download.chinaunix.net/down.php?id=28491&ResourceID=6095&site=1
6>[libmcrypt-2.5.8] http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
7>[zlib-1.2.3] http://sourceforge.net/projects/libpng/files/zlib/1.2.3/zlib-1.2.3.tar.gz/download
8>[libpng-1.2.31] http://files.directadmin.com/services/custombuild/libpng-1.2.31.tar.gz
9>[jpegsrc.v6b] http://download.chinaunix.net/down.php?id=10021&ResourceID=5095&site=1
10>[freetype-2.3.5] http://nongnu.askapache.com/freetype/freetype-2.3.5.tar.gz
11>[autoconf-2.61] http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz
12>[gd-2.0.35] http://code.google.com/p/google-desktop-for-linux-mirror/downloads/detail?name=gd-2.0.35.tar.gz&can=2&q=
13>[ncurses-5.6] http://ftp.gnu.org/gnu/ncurses/ncurses-5.6.tar.gz
14>[pcre-8.10] http://sourceforge.net/projects/pcre/files/pcre/8.10/pcre-8.10.tar.gz/download
15>[openssl-1.0.0e] http://www.openssl.org/source/openssl-1.0.0e.tar.gz +++++++++++++++++++++++++++++++++++++++++++++
1>【安装gcc, gcc-c++】
[html] view plaincopyprint?
- yum install gcc
- yum install gcc-c++
2>【开放80、3306、22端口】
[html] view plaincopyprint?
- #关闭防火墙
- service iptables stop
- 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 3306 -j ACCEPT
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
- #重启防火墙
- service iptables restart
3>【建立lamp/src目录, 将源码包上传】 4>【安装libxml2】
[html] view plaincopyprint?
- tar -zxvf libxml2-2.6.30.tar.gz
- cd libxml2-2.6.30
- ./configure --prefix=/usr/local/libxml2/
- make
- make install
5>【安装libmcrypt】
[html] view plaincopyprint?
- tar -zxvf libmcrypt-2.5.8.tar.gz
- cd libmcrypt-2.5.8
- ./configure --prefix=/usr/local/libmcrypt/ --enable-ltdl-install
- make
- make install
6>【安装libxml2-devel】
[html] view plaincopyprint?
- yum install libxml2-devel
7>【安装zlib】
[html] view plaincopyprint?
- tar -zxvf zlib-1.2.3.tar.gz
- cd zlib-1.2.3
- ./configure
- make
- make install
8>【安装libpng】
[html] view plaincopyprint?
- tar -zxvf libpng-1.2.31.tar.gz
- cd libpng-1.2.31
- ./configure --prefix=/usr/local/libpng/
- make
- make install
9>【安装jpegsrc.v6b】
[html] view plaincopyprint?
- mkdir /usr/local/jpeg6
- mkdir /usr/local/jpeg6/bin
- mkdir /usr/local/jpeg6/lib
- mkdir /usr/local/jpeg6/include
- mkdir -p /usr/local/jpeg6/man/man1
- tar -zxvf jpegsrc.v6b.tar.gz
- cd jpeg-6b
- ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
- make
- make install
10>【安装freetype】
[html] view plaincopyprint?
- tar -zxvf freetype-2.3.5.tar.gz
- cd freetype-2.3.5
- ./configure --prefix=/usr/local/freetype/
- make
- make install
11>【安装autoconf】
[html] view plaincopyprint?
- tar -zxvf autoconf-2.61.tar.gz
- cd autoconf-2.61
- ./configure
- make
- make install
12>【安装gd】
[html] view plaincopyprint?
- tar -zxvf gd-2.0.35.tar.gz
- cd gd-2.0.35
- ./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/
- make
- make install
13>【pcre-8.10】
[html] view plaincopyprint?
- tar -zxvf pcre-8.10.tar.gz
- cd pcre-8.10
- ./configure
- make
- make install
14>【安装openssl】
[html] view plaincopyprint?
- tar -zxvf openssl-1.0.0e.tar.gz
- cd openssl-1.0.0e
- ./config --prefix=/usr/local/openssl
- make
- make install
15>【安装nginx】
[html] view plaincopyprint?
- groupadd www
- useradd -g www www
- tar -zxvf nginx-1.1.8.tar.gz
- cd nginx-1.1.8
- ./configure --user=www --group=www --prefix=/usr/local/nginx --with-openssl=/lamp/src/openssl-1.0.0e --with-http_stub_status_module --with-http_ssl_module
- make
- make install
16>【安装ncurses】
[html] view plaincopyprint?
- tar -zxvf ncurses-5.6.tar.gz
- cd ncurses-5.6
- ./configure --with-shared --without-debug --without-ada --enable-overwrite
- make
- make install
17>【安装mysql】
[html] view plaincopyprint?
- groupadd mysql
- useradd -g mysql mysql
- tar -zxvf mysql-5.1.59.tar.gz
- cd mysql-5.1.59
- ./configure --prefix=/usr/local/mysql/ --with-extra-charsets=all
- make
- make install
- cp support-files/my-medium.cnf /etc/my.cnf
- /usr/local/mysql/bin/mysql_install_db --user=mysql
- chown -R root /usr/local/mysql
- chown -R mysql /usr/local/mysql/var
- chgrp -R mysql /usr/local/mysql
- /usr/local/mysql/bin/mysqld_safe --user=mysql &
- cp /lamp/src/mysql-5.1.59/support-files/mysql.server /etc/rc.d/init.d/mysqld
- chown root.root /etc/rc.d/init.d/mysqld
- chmod 755 /etc/rc.d/init.d/mysqld
- chkconfig --add mysqld
- chkconfig --list mysqld
- chkconfig --levels 245 mysqld off
- #配置mysql
- cd /usr/local/mysql
- #简单的测试
- bin/mysqladmin version
- #查看所有mysql参数
- bin/mysqladmin Variables
- #没有密码可以直接登录本机服务器
- bin/mysql -uroot
- DELETE FROM mysql.user WHERE Host='localhost' AND User='';
- FLUSH PRIVILEGES;
- #设置root密码为123456
- SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
- #配置可远程连接mysql
- use mysql
- SELECT user,password,host FROM user;
- DELETE FROM user WHERE host='localhsot.localdomain'
- DELETE FROM user WHERE host='127.0.0.1';
- UPDATE user SET host='%' WHERE user='root';
- #重启mysql
- service mysqld restart
18>【安装php】
[html] view plaincopyprint?
- tar -zxvf php-5.2.6.tar.gz
- gzip -cd php-5.2.6-fpm-0.5.8.diff.gz | patch -d php-5.2.6 -p1
- cd php-5.2.6
- ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets --enable-fastcgi --enable-fpm
- make
- make install
- cp php.ini-dist /usr/local/php/etc/php.ini
- #修改php-fpm.conf
- vi /usr/local/php/etc/php-fpm.conf
- #查找63,66行将注释去掉
- value name="user">nobodyvalue>
- value name="group">nobodyvalue>
- #启动php
- /usr/local/php/sbin/php-fpm start
19>【nginx配置】
[html] view plaincopyprint?
- vi /usr/local/nginx/conf/nginx.conf
- #在server下找到location / 修改解析PHP文件存放的路径, 修改为:
- location / {
- root /var/www/html;
- index index.html index.htm index.php;
- }
- #root表示虚拟目录设置为/var/www/html,增加默认解析index.php
- #在server下找到location ~ /.php$ 修改php解释器FastCGI配置,修改为:
- location ~ \.php$ {
- root /var/www/html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
- include fastcgi_params;
- }
- #将nginx添加到自启动中
- echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.d/rc.local
- #将php添加到自启动中
- echo "/usr/local/php/sbin/php-fpm start" >> /etc/rc.d/rc.local
20>【nginx虚拟主机配置】
vi /usr/local/nginx/conf/nginx.conf #在http最后一行加入 include /usr/local/nginx/conf/vhost/dev_localhost.config; #不带url重写
[html] view plaincopyprint?
- server {
- listen 80 default;
- server_name dev.localhost;
- access_log logs/dev.access.log;
- root /var/www/html/dev;
- server_name_in_redirect off;
- location / {
- index index.html index.php;
- }
- location ~ \.php$ {
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
- }
#带url重写(zend framework)
[html] view plaincopyprint?
- server {
- listen 80;
- server_name dev.localhost;
- access_log logs/dev.access.log;
- root /var/www/html/dev/code/html;
- location / {
- index index.html index.php;
- if (-e $request_filename ) {
- break;
- }
- if ( $request_filename ~* \.(js|ico|gif|jpg|jpeg|xml|swf|txt|png|css|html|htm)$ ) {
- return 404;
- }
- rewrite .* index.php;
- }
- location ~ .*\.php$ {
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME $document_root/index.php;
- #fastcgi_param REQUEST_URI $document_uri?$query_string;
- fastcgi_read_timeout 120;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- }
- }
[html] view plaincopyprint?
- #重启nginx
- /usr/local/nginx/sbin/nginx -s reload
- #重启php
- /usr/local/php/sbin/php-fpm restart

linux设备节点是应用程序和设备驱动程序沟通的一个桥梁;设备节点被创建在“/dev”,是连接内核与用户层的枢纽,相当于硬盘的inode一样的东西,记录了硬件设备的位置和信息。设备节点使用户可以与内核进行硬件的沟通,读写设备以及其他的操作。

区别:1、open是UNIX系统调用函数,而fopen是ANSIC标准中的C语言库函数;2、open的移植性没fopen好;3、fopen只能操纵普通正规文件,而open可以操作普通文件、网络套接字等;4、open无缓冲,fopen有缓冲。

端口映射又称端口转发,是指将外部主机的IP地址的端口映射到Intranet中的一台计算机,当用户访问外网IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上;可以通过使用动态或固定的公共网络IP路由ADSL宽带路由器来实现。

在linux中,可以利用“rpm -qa pcre”命令判断pcre是否安装;rpm命令专门用于管理各项套件,使用该命令后,若结果中出现pcre的版本信息,则表示pcre已经安装,若没有出现版本信息,则表示没有安装pcre。

在linux中,eof是自定义终止符,是“END Of File”的缩写;因为是自定义的终止符,所以eof就不是固定的,可以随意的设置别名,linux中按“ctrl+d”就代表eof,eof一般会配合cat命令用于多行文本输出,指文件末尾。

linux查询mac地址的方法:1、打开系统,在桌面中点击鼠标右键,选择“打开终端”;2、在终端中,执行“ifconfig”命令,查看输出结果,在输出信息第四行中紧跟“ether”单词后的字符串就是mac地址。

手机远程linux工具有:1、JuiceSSH,是一款功能强大的安卓SSH客户端应用,可直接对linux服务进行管理;2、Termius,可以利用手机来连接Linux服务器;3、Termux,一个强大的远程终端工具;4、向日葵远程控制等等。

linux中,lsb是linux标准基础的意思,是“Linux Standards Base”的缩写,是linux标准化领域中的标准;lsb制定了应用程序与运行环境之间的二进制接口,保证了linux发行版与linux应用程序之间的良好结合。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft