准备软件:nginx1.10.3+php-5.5.12+mariadb10.0.8(数据库在此使用的yum安装)

mariadb10.0.8数据库的编译安装地址:http://www.cnblogs.com/JeremyWYL/p/7251435.html

依赖包均已yum在线安装

  1. yum -y install mariadb*
  2. 启动数据库
  3. systemctl start mariadb
  4. 修改root密码
  5. grant all privileges on *.* to \'root\'@\'localhost\' identified by "root" with grant option;
  6. grant all privileges on *.* to \'root\'@\'%\' identified by "root" with grant option;
  7. flush privileges;
  1. 1、安装依赖包
  2. yum install -y pcre pcre-devel openssl openssl-devel gcc-c++
  3. 2、创建运行进程的用户
  4. groupadd nginx
  5. useradd -g nginx -s /bin/nologin nginx
  6. 3、编译安装nginx
  7. 我在这儿的软件都放在myapp目录下的
  8. tar -zxvf nginx-1.10.3.tar.gz #解压到当前目录
  9. cd nginx-1.10.3
  10. ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-pcre --with-http_gzip_static_module --without-http_gzip_module --with-http_stub_status_module
  11. make
  12. make install
  13. 4、启动nginx
  14. cd /usr/local/nginx/sbin
  15. ./nginx
  16. 5、验证:浏览器访问http://ip
  1. 1、安装依赖包
  2. yum -y install libxml2* curl curl-devel libpng-devel libpng openldap openldap-devel freetype freetype-devel libjpeg-devel libpng-devel bzip2 bzip2-devel
  3. 2、编译安装php
  4. tar -xjf php-5.5.12.tar.bz2
  5. cd php-5.5.12
  6. ./configure -prefix=/usr/local/php --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local/ --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64
  7. make
  8. make test
  9. make install
  10. 3、修改php文件
  11. cp /myapp/php-5.5.12/php.ini-production /usr/local/php/etc/php.ini
  12. cp /usr/local/php/etc/php-fpm.conf.default php-fpm.conf
  13. 4、启动php
  14. /usr/local/php/sbin/php-fpm
  15. 检查启动是否成功
  16. netstat -lntp | grep php-fpm
  17. 显示 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 77087/php-fpm: mast
  1. 1、修改nginx配置文件
  2. vi /usr/local/nginx/conf/nginx.conf
  3. [root@localhost conf]# cat nginx.conf | grep -v "#"
  4. user nginx nginx;
  5. worker_processes 1;
  6. events {
  7. worker_connections 1024;
  8. }
  9. http {
  10. include mime.types;
  11. default_type application/octet-stream;
  12. log_format main \'$remote_addr - $remote_user [$time_local] "$request" \'
  13. \'$status $body_bytes_sent "$http_referer" \'
  14. \'"$http_user_agent" "$http_x_forwarded_for"\';
  15. access_log logs/access.log main;
  16. sendfile on;
  17. keepalive_timeout 65;
  18. server {
  19. listen 80;
  20. server_name localhost;
  21. charset utf8;
  22. location / {
  23. root html;
  24. index index.html index.htm index.php;
  25. }
  26. error_page 500 502 503 504 /50x.html;
  27. location = /50x.html {
  28. root html;
  29. }
  30. location ~ \.php$ {
  31. root html;
  32. fastcgi_pass 127.0.0.1:9000;
  33. fastcgi_index index.php;
  34. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  35. include fastcgi_params;
  36. }
  37. }
  38. 2、创建index.php文件测试
  39. cd /usr/local/nginx/html
  40. vi index.php
  41. [root@localhost html]# cat index.php
  42. <?php
  43. $link=mysql_connect("172.16.20.112","root","root");
  44. if(!$link)
  45. echo "MySQL数据库连接失败!!";
  46. else
  47. echo "MySQL数据库连接成功!!";
  48. phpinfo();
  49. ?>
  50. 保存退出
  51. chmod 775 index.php
  52. 3、验证
  53. 浏览器http://IP/index.php

 

版权声明:本文为JeremyWYL原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/JeremyWYL/p/7251165.html