环境: CentOS6.5(L) Nginx1.10.1 (N) MySQL(M) PHP(P) 在MacOS下进行搭建
使用Docker搭建CentOS环境,Docker使用自行学习
$ docker pull index.docker.io/library/centos //(拉取CentOS镜像)
$ docker run -v /Users/arnoma2015/Downloads:/data/ --name mysql-study -i -t centos /bin/bash //( 启动容器,并挂载本机/Users/arnoma2015/Downloads目录,该目录存放共享的数据)
http://nginx.org/en/download.html
nginx需要依赖zlib、pcre、openssl等库 参考:
http://www.cnblogs.com/skynet/p/4146083.html
另外如果没有安装开发工具包,请通过yum安装,如下
yum groupinstall -y “Development Tools”
$ cp /data/nginx-1.10.1.tar.gz // 移动至/opt目录
$ cd /opt
$ tar -xzvf nginx-1.10.1.tar.gz //解压文件
$ cd nginx-1.10.1
$ ./configure
$ make & make install
$ cd /usr/local/nginx/sbin
$ ./nginx (启动nginx)
我启动时出现了错误,如下图屏幕快照 2016-08-15 上午11.16.44
解决方案:cp /usr/local/lib64/libcrypto.so.1.1 /lib64 重新启动
$ curl localhost
=========如果有以下数据输出则安装成功==========
<html>
<head>
<title>Welcome to nginx!title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
style>
head>
<body>
<h1>Welcome to nginx!h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.p>
<p>For online documentation and support please refer to
<a href=”http://nginx.org/”>nginx.orga>.<br/>
Commercial support is available at
<a href=”http://nginx.com/”>nginx.coma>.p>
<p><em>Thank you for using nginx.em>p>
body>
html>
方法 :/etc/rc.local
这是一个最简单的方法,编辑“/etc/rc.local”,把启动程序的shell命令输入进去即可(要输入命令的全路径),类似于windows下的“启动”。
使用命令 vi /etc/rc.local
然后在文件最后一行添加要执行程序的全路径。
例如,每次开机时要执行一个haha.sh,这个脚本放在/opt下面,那就可以在“/etc/rc.local”中加一行“/opt/./haha.sh”,或者两行“cd /opt”和“./haha.sh”。
本例中: /usr/local/nginx/sbin/nginx
请移步我的CSDN博客:
http://blog.csdn.net/u012535312/article/details/52127798
http://php.net/get/php-5.6.24.tar.gz/from/a/mirror
$ yum install libxml2-devel openssl-devel bzip2-devel libmcrypt-devel -y
$ cp /data/php-5.6.24.tar.gz /opt
$ cd /opt
$ tar -xzvf php-5.6.24.tar.gz
$ cd php-5.6.24
$ ./configure –prefix=/usr/local/php –with-mysql=mysqlnd –with-pdo-mysql=mysqlnd –with-mysqli=mysqlnd –enable-mbstring –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –enable-sockets –enable-fpm –with-mcrypt –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d –with-bz2 –enable-opcache=no
如果遇到如下问题: configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方法: 手动编译安装libmcrypt
下载地址https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
$ make & make install
$ cp php.ini-production /etc/php.ini //设置配置文件 配置php-fpm
$ cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
$ chmod +x /etc/rc.d/init.d/php-fpm
$ chkconfig –add php-fpm
$ chkconfig php-fpm on
$ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
$ service php-fpm start
/usr/local/nginx/conf/fastcgi_params
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
PHP only, required if PHP was built with –enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
/usr/local/nginx/config/nginx.conf
//取消注释
server{
location / {
root html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
$ curl localhost
打印phpinfo()的信息