|
可能是网络问题,使用porst安装经常出错,最后选择用Binary 套件来安装程序。
首先需要学习几个Binary 套件安装软体的几个命令
1、搜寻Binary 套件中编译好的软件包
pkg search 软件名(不需要版本号)
2、pkg指令手册
# man pkg-install 或
# pkg help install
3、安装命令
# pkg install packagename
4、卸载命令
# pkg delete packagename
一、安装Apache24
- # pkg install apache24
- Updating FreeBSD repository catalogue...
- FreeBSD repository is up-to-date.
- All repositories are up-to-date.
- The following 10 package(s) will be affected (of 0 checked):
- New packages to be INSTALLED:
- apache24: 2.4.23_1
- libxml2: 2.9.4
- expat: 2.2.0
- apr: 1.5.2.1.5.4_1
- gdbm: 1.12
- indexinfo: 0.2.5
- gettext-runtime: 0.19.8.1
- db5: 5.3.28_4
- perl5: 5.20.3_15
- pcre: 8.39
- Number of packages to be installed: 10
- The process will require 136 MiB more space.
- 33 MiB to be downloaded.
- Proceed with this action? [y/N]: y
- ...
- ...
- ===> Creating groups.
- Using existing group 'www'.
- ===> Creating users
- Using existing user 'www'.
- [10/10] Extracting apache24-2.4.23_1: 100%
- Message from perl5-5.20.3_15:
- The /usr/bin/perl symlink has been removed starting with Perl 5.20.
- For shebangs, you should either use:
- #!/usr/local/bin/perl
- or
- #!/usr/bin/env perl
- The first one will only work if you have a /usr/local/bin/perl,
- the second will work as long as perl is in PATH.
- Message from apache24-2.4.23_1:
- To run apache www server from startup, add apache24_enable="yes"
- in your /etc/rc.conf. Extra options can be found in startup script.
- Your hostname must be resolvable using at least 1 mechanism in
- /etc/nsswitch.conf typically DNS or /etc/hosts or apache might
- have issues starting depending on the modules you are using.
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- - apache24 default build changed from static MPM to modular MPM
- - more modules are now enabled per default in the port
- - icons and error pages moved from WWWDIR to DATADIR
- If build with modular MPM and no MPM is activated in
- httpd.conf, then mpm_prefork will be activated as default
- MPM in etc/apache24/modules.d to keep compatibility with
- existing php/perl/python modules!
- Please compare the existing httpd.conf with httpd.conf.sample
- and merge missing modules/instructions into httpd.conf!
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
复制代码
安装完成之后,用find命令查看一下apache24都按到了哪里
- # find / -name apache24
- /usr/local/share/doc/apache24 //apache24文档
- /usr/local/share/apache24
- /usr/local/etc/apache24
- /usr/local/etc/rc.d/apache24
- /usr/local/include/apache24
- /usr/local/libexec/apache24 //扩展库
- /usr/local/www/apache24/data //默认主目录
复制代码 设置apache24开机自启动
- # echo ‘apache24_enable="YES"’>>/etc/rc.conf
复制代码 二、安装MariaDB
MariaDB是MySQL的替代品,性能优于MySQL。我们更担心的是因为甲骨文收购了Mysql后的闭源风险。
- # pkg search mariadb
- mariadb100-client-10.0.27 Multithreaded SQL database (client)
- mariadb100-server-10.0.27 Multithreaded SQL database (server)
- mariadb101-client-10.1.17 Multithreaded SQL database (client)
- mariadb101-server-10.1.17 Multithreaded SQL database (server)
- mariadb55-client-5.5.52 Multithreaded SQL database (client)
- mariadb55-server-5.5.52 Multithreaded SQL database (server)
复制代码 选择MariaDB100
- # pkg install mariadb100-server mariadb100-client
- Updating FreeBSD repository catalogue...
- FreeBSD repository is up-to-date.
- All repositories are up-to-date.
- The following 3 package(s) will be affected (of 0 checked):
- New packages to be INSTALLED:
- mariadb100-server: 10.0.27
- mariadb100-client: 10.0.27
- openssl: 1.0.2j,1
- Number of packages to be installed: 3
- The process will require 238 MiB more space.
- 33 MiB to be downloaded.
- Proceed with this action? [y/N]: y
- Fetching mariadb100-server-10.0.27.txz: 100% 27 MiB 801.3kB/s 00:35
- ......
- ===> Creating groups.
- Creating group 'mysql' with gid '88'.
- ===> Creating users
- Creating user 'mysql' with uid '88'.
- [3/3] Extracting mariadb100-server-10.0.27: 100%
- Message from openssl-1.0.2j,1:
- Copy /usr/local/openssl/openssl.cnf.sample to /usr/local/openssl/openssl.cnf
- and edit it to fit your needs.
- Message from mariadb100-client-10.0.27:
- ************************************************************************
- MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
- my.cnf. Please move existing my.cnf files from those paths to
- /usr/local/etc and /usr/local/etc/mysql.
- ************************************************************************
- Message from mariadb100-server-10.0.27:
- ************************************************************************
- Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag)
- the first time you start the MySQL server after an upgrade from an
- earlier version.
- MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
- my.cnf. Please move existing my.cnf files from those paths to
- /usr/local/etc and /usr/local/etc/mysql.
- This port does NOT include the mytop perl script, this is included in
- the MariaDB tarball but the most recent version can be found in the
- databases/mytop port
- ************************************************************************
复制代码 复制my.cnf
- # cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf
复制代码 设置开启自启动
- # echo 'mysql_enable="YES"'>>/etc/rc.conf
复制代码 启动MariaDB
- # service mysql-server start
复制代码 管理员密码设置
- # mysql_secure_installation
- NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
- SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
- ...
- Setting the root password ensures that nobody can log into the MariaDB
- root user without the proper authorisation.
- Set root password? [Y/n] y
- New password: //键入密码,看不见哦!
- Re-enter new password: //再键入一次
- Password updated successfully!
- Reloading privilege tables..
- ... Success!
- ...
- production environment.
- Remove anonymous users? [Y/n] Y
- ... Success!
- ...
- Disallow root login remotely? [Y/n] Y
- ... Success!
- ...
- Remove test database and access to it? [Y/n] Y
- - Dropping test database...
- ... Success!
- - Removing privileges on test database...
- ... Success!
- ...
- Reload privilege tables now? [Y/n] Y
- ... Success!
- Cleaning up...
- All done! If you've completed all of the above steps, your MariaDB
- installation should now be secure.
- Thanks for using MariaDB!
复制代码 测试
- # mysql -u root -p
- Enter password:
- Welcome to the MariaDB monitor. Commands end with ; or \g.
- Your MariaDB connection id is 12
- Server version: 10.0.27-MariaDB FreeBSD Ports
- Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- MariaDB [(none)]> exit
- Bye
复制代码 出现MariaDB [(none)]> ,表示成功。
三、安装php和扩展
- # 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等。
不需要很长时间。
- # cp /usr/local/etc/php/php.ini-production php/usr/local/etc/php.ini
复制代码 pkg安装时已经将libphp7.so写入了httpd.conf里,只须在httpd.conf中加入php文件解析指令
- <FilesMatch "\.php>
- SetHandler application/x-httpd-php
- </FilesMatch>
- <FilesMatch "\.phps>
- SetHandler application/x-httpd-php-source
- </FilesMatch>
复制代码 四、启动httpd&phpinfo测试
- # service apache24_server start
复制代码 在web的主目录下建立个php探针
- # ee /usr/local/www/apache24/data/info.php
复制代码 加入如下代码:
在浏览器中输入info.php网址,出现phpinfo的信息,大功告成。
至此,FAMP服务安装完毕。总体来说,FreeBSD上用Binary 套件来安装软件是超省时省事的。另外需要说的是,FreeBSD系统较各种Linux系统更稳健更简洁明快。
|
|