五常信息网(五常论坛)

 找回密码
 立即注册
搜索
查看: 993|回复: 0
打印 上一主题 下一主题

Freebsd11安装apache24+php7+MariaDB100

[复制链接]

71

主题

1461

帖子

8万

积分

系统管理员

Rank: 10Rank: 10Rank: 10

积分
86522
金钱
49328
威望
19741
经验值
12744
魅力
1787
精华
0
跳转到指定楼层
楼主
发表于 2017-11-18 11:56:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
可能是网络问题,使用porst安装经常出错,最后选择用Binary 套件来安装程序。
首先需要学习几个Binary 套件安装软体的几个命令
1、搜寻Binary 套件中编译好的软件包
pkg search 软件名(不需要版本号)
2、pkg指令手册
# man pkg-install 或
# pkg help install
3、安装命令
# pkg install packagename
4、卸载命令
# pkg delete packagename
一、安装Apache24

  1.   # pkg install apache24
  2. Updating FreeBSD repository catalogue...
  3. FreeBSD repository is up-to-date.
  4. All repositories are up-to-date.
  5. The following 10 package(s) will be affected (of 0 checked):
  6. New packages to be INSTALLED:
  7.         apache24: 2.4.23_1
  8.         libxml2: 2.9.4
  9.         expat: 2.2.0
  10.         apr: 1.5.2.1.5.4_1
  11.         gdbm: 1.12
  12.         indexinfo: 0.2.5
  13.         gettext-runtime: 0.19.8.1
  14.         db5: 5.3.28_4
  15.         perl5: 5.20.3_15
  16.         pcre: 8.39
  17. Number of packages to be installed: 10
  18. The process will require 136 MiB more space.
  19. 33 MiB to be downloaded.
  20. Proceed with this action? [y/N]: y
  21. ...
  22. ...
  23. ===> Creating groups.
  24. Using existing group 'www'.
  25. ===> Creating users
  26. Using existing user 'www'.
  27. [10/10] Extracting apache24-2.4.23_1: 100%
  28. Message from perl5-5.20.3_15:
  29. The /usr/bin/perl symlink has been removed starting with Perl 5.20.
  30. For shebangs, you should either use:
  31. #!/usr/local/bin/perl
  32. or
  33. #!/usr/bin/env perl
  34. The first one will only work if you have a /usr/local/bin/perl,
  35. the second will work as long as perl is in PATH.
  36. Message from apache24-2.4.23_1:
  37. To run apache www server from startup, add apache24_enable="yes"
  38. in your /etc/rc.conf. Extra options can be found in startup script.
  39. Your hostname must be resolvable using at least 1 mechanism in
  40. /etc/nsswitch.conf typically DNS or /etc/hosts or apache might
  41. have issues starting depending on the modules you are using.
  42. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  43. - apache24 default build changed from static MPM to modular MPM
  44. - more modules are now enabled per default in the port
  45. - icons and error pages moved from WWWDIR to DATADIR
  46.    If build with modular MPM and no MPM is activated in
  47.    httpd.conf, then mpm_prefork will be activated as default
  48.    MPM in etc/apache24/modules.d to keep compatibility with
  49.    existing php/perl/python modules!
  50. Please compare the existing httpd.conf with httpd.conf.sample
  51. and merge missing modules/instructions into httpd.conf!
  52. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
复制代码

安装完成之后,用find命令查看一下apache24都按到了哪里
  1. # find  / -name apache24
  2. /usr/local/share/doc/apache24          //apache24文档
  3. /usr/local/share/apache24   
  4. /usr/local/etc/apache24
  5. /usr/local/etc/rc.d/apache24  
  6. /usr/local/include/apache24
  7. /usr/local/libexec/apache24            //扩展库
  8. /usr/local/www/apache24/data      //默认主目录
复制代码
设置apache24开机自启动
  1. # echo ‘apache24_enable="YES"’>>/etc/rc.conf
复制代码
二、安装MariaDB
MariaDB是MySQL的替代品,性能优于MySQL。我们更担心的是因为甲骨文收购了Mysql后的闭源风险。
  1. # pkg search mariadb
  2. mariadb100-client-10.0.27      Multithreaded SQL database (client)
  3. mariadb100-server-10.0.27      Multithreaded SQL database (server)
  4. mariadb101-client-10.1.17      Multithreaded SQL database (client)
  5. mariadb101-server-10.1.17      Multithreaded SQL database (server)
  6. mariadb55-client-5.5.52        Multithreaded SQL database (client)
  7. mariadb55-server-5.5.52        Multithreaded SQL database (server)
复制代码
选择MariaDB100
  1. # pkg install mariadb100-server mariadb100-client
  2. Updating FreeBSD repository catalogue...
  3. FreeBSD repository is up-to-date.
  4. All repositories are up-to-date.
  5. The following 3 package(s) will be affected (of 0 checked):
  6. New packages to be INSTALLED:
  7.         mariadb100-server: 10.0.27
  8.         mariadb100-client: 10.0.27
  9.         openssl: 1.0.2j,1
  10. Number of packages to be installed: 3
  11. The process will require 238 MiB more space.
  12. 33 MiB to be downloaded.
  13. Proceed with this action? [y/N]: y
  14. Fetching mariadb100-server-10.0.27.txz: 100%   27 MiB 801.3kB/s    00:35   
  15. ......
  16. ===> Creating groups.
  17. Creating group 'mysql' with gid '88'.
  18. ===> Creating users
  19. Creating user 'mysql' with uid '88'.
  20. [3/3] Extracting mariadb100-server-10.0.27: 100%
  21. Message from openssl-1.0.2j,1:
  22. Copy /usr/local/openssl/openssl.cnf.sample to /usr/local/openssl/openssl.cnf
  23. and edit it to fit your needs.
  24. Message from mariadb100-client-10.0.27:
  25. ************************************************************************
  26. MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
  27. my.cnf. Please move existing my.cnf files from those paths to
  28. /usr/local/etc and /usr/local/etc/mysql.
  29. ************************************************************************
  30. Message from mariadb100-server-10.0.27:
  31. ************************************************************************
  32. Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag)
  33. the first time you start the MySQL server after an upgrade from an
  34. earlier version.
  35. MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
  36. my.cnf. Please move existing my.cnf files from those paths to
  37. /usr/local/etc and /usr/local/etc/mysql.
  38. This port does NOT include the mytop perl script, this is included in
  39. the MariaDB tarball but the most recent version can be found in the
  40. databases/mytop port
  41. ************************************************************************
复制代码
复制my.cnf
  1. # cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf
复制代码
设置开启自启动
  1. # echo 'mysql_enable="YES"'>>/etc/rc.conf
复制代码
启动MariaDB
  1. # service mysql-server start
复制代码
管理员密码设置
  1. # mysql_secure_installation
  2. NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
  3.       SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
  4. ...
  5. Setting the root password ensures that nobody can log into the MariaDB
  6. root user without the proper authorisation.
  7. Set root password? [Y/n] y
  8. New password:                  //键入密码,看不见哦!
  9. Re-enter new password:     //再键入一次
  10. Password updated successfully!
  11. Reloading privilege tables..
  12. ... Success!
  13. ...
  14. production environment.
  15. Remove anonymous users? [Y/n] Y
  16. ... Success!
  17. ...
  18. Disallow root login remotely? [Y/n] Y
  19. ... Success!
  20. ...
  21. Remove test database and access to it? [Y/n] Y
  22. - Dropping test database...
  23. ... Success!
  24. - Removing privileges on test database...
  25. ... Success!
  26. ...
  27. Reload privilege tables now? [Y/n] Y
  28. ... Success!
  29. Cleaning up...
  30. All done!  If you've completed all of the above steps, your MariaDB
  31. installation should now be secure.
  32. Thanks for using MariaDB!
复制代码
测试
  1. # mysql -u root -p
  2. Enter password:
  3. Welcome to the MariaDB monitor.  Commands end with ; or \g.
  4. Your MariaDB connection id is 12
  5. Server version: 10.0.27-MariaDB FreeBSD Ports
  6. Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
  7. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  8. MariaDB [(none)]> exit
  9. Bye
复制代码
出现MariaDB [(none)]> ,表示成功。
三、安装php和扩展
  1. # pkg install php70-bcmath php70-ctype php70-curl php70-exif php70-extensions php70-ftp php70-gd php70-gettext php70-mbstring php70-mcrypt php70-mysqli php70-opcache php70-openssl php70-pdo_mysql php70-xml php70-zip php70-zlib php70 mod_php70
复制代码
现在php7、性能超优秀,如果你的PHP程序不兼容PHP7,可以把70换成52、……、56等。
不需要很长时间。
  1. # cp /usr/local/etc/php/php.ini-production php/usr/local/etc/php.ini
复制代码
pkg安装时已经将libphp7.so写入了httpd.conf里,只须在httpd.conf中加入php文件解析指令
  1. <FilesMatch "\.php>
  2.         SetHandler application/x-httpd-php
  3. </FilesMatch>
  4. <FilesMatch "\.phps>
  5.         SetHandler application/x-httpd-php-source
  6. </FilesMatch>
复制代码
四、启动httpd&phpinfo测试
  1. # service apache24_server start
复制代码
在web的主目录下建立个php探针
  1. # ee /usr/local/www/apache24/data/info.php
复制代码
加入如下代码:
  1. <?php
  2.       phpinfo();
复制代码
在浏览器中输入info.php网址,出现phpinfo的信息,大功告成。
至此,FAMP服务安装完毕。总体来说,FreeBSD上用Binary 套件来安装软件是超省时省事的。另外需要说的是,FreeBSD系统较各种Linux系统更稳健更简洁明快。

为众人抱火者, 不可使他冻毙于风雪! 为自由开路者, 不可使他困顿于荆棘!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|Archiver|五常信息网(五常论坛) ( 黑ICP备06006344号

GMT+8, 2024-5-5 12:23 , Processed in 0.060510 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表