apache24, php71 , mariadb102 설치
apache24 설치
root@bsd11:~ # whereis apache24 apache24: /usr/ports/www/apache24 root@bsd11:~ # cd /usr/ports/www/apache24/ && make install clean
OK 선택하여 다음을 설정 합니다.
추가적으로 나오는 부분은 OK 선택하여 설치를 진행 합니다.
apache24 설치후 메세지
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! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ===> SECURITY REPORT: This port has installed the following files which may act as network servers and may therefore pose a remote security risk to the system. /usr/local/libexec/apache24/mod_cgid.so This port has installed the following startup scripts which may cause these network services to be started at boot time. /usr/local/etc/rc.d/apache24 /usr/local/etc/rc.d/htcacheclean If there are vulnerabilities in these programs there may be a security risk to the system. FreeBSD makes no guarantee about the security of ports included in the Ports Collection. Please type 'make deinstall' to deinstall the port if this is a concern. For more information, and contact details about the security status of this software, see the following webpage: http://httpd.apache.org/ ===> Cleaning for autoconf-2.69_1 ===> Cleaning for m4-1.4.18,1 ===> Cleaning for texinfo-6.5,1 ===> Cleaning for help2man-1.47.5 ===> Cleaning for p5-Locale-gettext-1.07 ===> Cleaning for gettext-tools-0.19.8.1 ===> Cleaning for gettext-runtime-0.19.8.1_1 ===> Cleaning for indexinfo-0.3.1 ===> Cleaning for gmake-4.2.1_1 ===> Cleaning for autoconf-wrapper-20131203 ===> Cleaning for automake-1.15.1 ===> Cleaning for automake-wrapper-20131203 ===> Cleaning for libtool-2.4.6 ===> Cleaning for expat-2.2.1 ===> Cleaning for apr-1.6.3.1.6.1 ===> Cleaning for gdbm-1.13_1 ===> Cleaning for readline-7.0.3_1 ===> Cleaning for db5-5.3.28_6 ===> Cleaning for pcre-8.40_1 ===> Cleaning for libnghttp2-1.27.0 ===> Cleaning for libxml2-2.9.4 ===> Cleaning for apache24-2.4.29 root@bsd11:/usr/ports/www/apache24 #
php71 설치
root@bsd11:~ # whereis php71 php71: /usr/ports/lang/php71 root@bsd11:/usr/ports/lang/php71 # make config
추가 패키지 설치를 위해 php71-extensions 디렉토리로 이동합니다.
root@bsd11:/usr/ports/lang/php71 # cd /usr/ports/lang/php71-extensions/ root@bsd11:/usr/ports/lang/php71-extensions # make config install
설치 옵션에서 CURL FTP GD MYSQLi OPENSSL SOCKETS PDF SNMP ZIP 선택후 설치를 진행 합니다.
설치 완료 메세지
Libraries have been installed in: /usr/ports/archivers/php71-zip/work/php-7.1.11/ext/zip/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Build complete. Don't forget to run 'make test'. ===> Staging for php71-zip-7.1.11 ===> php71-zip-7.1.11 depends on file: /usr/local/include/php/main/php.h - found ===> Generating temporary packing list ====> Compressing man pages (compress-man) ===> Installing for php71-zip-7.1.11 ===> Checking if php71-zip already installed ===> Registering installation for php71-zip-7.1.11 as automatic Installing php71-zip-7.1.11... ===> php71-extensions-1.0 depends on file: /usr/local/lib/php/20160303/zip.so - found ===> Returning to build of php71-extensions-1.0 ===> Generating temporary packing list ====> Compressing man pages (compress-man) ===> Installing for php71-extensions-1.0 ===> Checking if php71-extensions already installed ===> Registering installation for php71-extensions-1.0 Installing php71-extensions-1.0... root@bsd11:/usr/ports/lang/php71-extensions #
mariadb102 설치
root@bsd11:~ # whereis mariadb102-server mariadb102-server: /usr/ports/databases/mariadb102-server root@bsd11:~ # cd /usr/ports/databases/mariadb102-server && make install clean
OK 선택하여 설치를 진행 합니다.
설치 완료 메세지
************************************************************************ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! The default InnoDB storage engine is no longer XtraDB, check your !! !! configuration and switch it to InnoDB !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 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 ************************************************************************ ===> SECURITY REPORT: This port has installed the following files which may act as network servers and may therefore pose a remote security risk to the system. /usr/local/lib/mysql/plugin/ha_spider.so /usr/local/lib/mysql/plugin/handlersocket.so This port has installed the following startup scripts which may cause these network services to be started at boot time. /usr/local/etc/rc.d/mysql-server If there are vulnerabilities in these programs there may be a security risk to the system. FreeBSD makes no guarantee about the security of ports included in the Ports Collection. Please type 'make deinstall' to deinstall the port if this is a concern. For more information, and contact details about the security status of this software, see the following webpage: http://mariadb.org/ ===> Cleaning for bison-3.0.4,1 ===> Cleaning for cmake-3.9.4 ===> Cleaning for py27-sphinx-1.4.8_2,1 ===> Cleaning for py27-Jinja2-2.9.5 ===> Cleaning for py27-setuptools-36.5.0 ===> Cleaning for python27-2.7.14_1 ===> Cleaning for libffi-3.2.1_1 ===> Cleaning for py27-MarkupSafe-1.0 ===> Cleaning for py27-Babel-2.3.4 ===> Cleaning for py27-pytz-2017.2,1 ===> Cleaning for py27-docutils-0.14 ===> Cleaning for py27-six-1.11.0 ===> Cleaning for py27-pygments-2.2.0 ===> Cleaning for py27-sphinx_rtd_theme-0.2.4 ===> Cleaning for py27-alabaster-0.7.6 ===> Cleaning for py27-snowballstemmer-1.2.0_1 ===> Cleaning for py27-pystemmer-1.3.0_1 ===> Cleaning for py27-imagesize-0.7.1 ===> Cleaning for ca_root_nss-3.32.1 ===> Cleaning for curl-7.56.1 ===> Cleaning for jsoncpp-1.8.1_2 ===> Cleaning for scons-2.5.1_1 ===> Cleaning for python2-2_3 ===> Cleaning for libuv-1.16.1 ===> Cleaning for rhash-1.3.5 ===> Cleaning for libarchive-3.3.2,1 ===> Cleaning for libiconv-1.14_11 ===> Cleaning for liblz4-1.8.0,1 ===> Cleaning for lzo2-2.10_1 ===> Cleaning for unixODBC-2.3.4 ===> Cleaning for libedit-3.1.20170329_2,1 ===> Cleaning for mariadb102-client-10.2.10 ===> Cleaning for mariadb102-server-10.2.10 root@bsd11:/usr/ports/databases/mariadb102-server #
mod_php71 설치
root@bsd11:~ # whereis mod_php71 mod_php71: /usr/ports/www/mod_php71 root@bsd11:~ # cd /usr/ports/www/mod_php71/ && make install clean
AP2FILTER 를 선택 합니다.
설치시 오류 메시지
Build complete. Don't forget to run 'make test'. ===> Staging for mod_php71-7.1.11 ===> mod_php71-7.1.11 depends on file: /usr/local/sbin/apxs - found ===> Generating temporary packing list /bin/mkdir -p /usr/ports/www/mod_php71/work/stage/usr/local/libexec/apache24 install -s -m 0644 /usr/ports/www/mod_php71/work/php-7.1.11/libs/libphp7.so /u sr/ports/www/mod_php71/work/stage/usr/local/libexec/apache24 install: /usr/ports/www/mod_php71/work/php-7.1.11/libs/libphp7.so: No such file or directory *** Error code 71 Stop. make[1]: stopped in /usr/ports/www/mod_php71 *** Error code 1 Stop. make: stopped in /usr/ports/www/mod_php71 root@bsd11:/usr/ports/www/mod_php71 #
/etc/make.conf 생성
root@bsd11:/usr/ports/www/mod_php71 # vi /etc/make.conf DEFAULT_VERSIONS+=php=7.1
ports 설치시 문제가 있어 pkg 로 설치를 진행 합니다. (Freebsd 10 Version 에서도 동일한 문제가 있어 pkg 로 설치를 진행 하였습니다.)
root@bsd11:/ # pkg install mod_php71 Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 1 package(s) will be affected (of 0 checked): New packages to be INSTALLED: mod_php71: 7.1.10 Number of packages to be installed: 1 The process will require 5 MiB more space. 1 MiB to be downloaded. Proceed with this action? [y/N]: y [1/1] Fetching mod_php71-7.1.10.txz: 100% 1 MiB 597.2kB/s 00:02 Checking integrity... done (0 conflicting) [1/1] Installing mod_php71-7.1.10... Extracting mod_php71-7.1.10: 100% [activating module `php7' in /usr/local/etc/apache24/httpd.conf] Message from mod_php71-7.1.10: *************************************************************** Make sure index.php is part of your DirectoryIndex. You should add the following to your Apache configuration file: <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> ********************************************************************* If you are building PHP-based ports in poudriere(8) with ZTS enabled, add WITH_MPM=event to /etc/make.conf to prevent build failures. ********************************************************************* root@bsd11:/ #
apache24 Setting
/etc/rc.conf 파일 수정
root@bsd11:~ # vi /etc/rc.conf apache24_enable="YES"
apache24 Daemon 실행을 위해서는 httpd.conf 파일의 수정이 필요 합니다.
root@bsd11:~ # cd /usr/local/etc/apache24/ root@bsd11:/usr/local/etc/apache24 # cp httpd.conf httpd.conf.org root@bsd11:/usr/local/etc/apache24 # vi httpd.conf <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> ServerName www.example.com:80 AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php .inc .html AddType application/x-httpd-source .phps Include etc/apache24/extra/httpd-userdir.conf LoadModule userdir_module libexec/apache24/mod_userdir.so
(주석을 제거 합니다 차후 domain 에 맞게 수정해 주면 됩니다.)
php.ini 파일 카피 및 php71 include 설정
php.ini 파일 카피
root@bsd11:~ # cd /usr/local/etc root@bsd11:/usr/local/etc # cp php.ini-production php.ini
php.conf 파일 생성
root@bsd11:~ # cd /usr/local/etc/apache24/extra/ root@bsd11:/usr/local/etc/apache24/extra # vi php.conf <IfModule dir_module> DirectoryIndex index.php index.html <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> </IfModule>
apache24 Daemon 실행
root@bsd11:/usr/local/etc/apache24 # service apache24 restart Performing sanity check on apache24 configuration: Syntax OK Stopping apache24. Waiting for PIDS: 760. Performing sanity check on apache24 configuration: Syntax OK Starting apache24. root@bsd11:/usr/local/etc/apache24 #
mariadb102 Setting
/etc/rc.conf 파일 수정
root@bsd11:~ # vi /etc/rc.conf mysql_enable="YES"
mariadb102 Daemon 실행및 password 설정
root@bsd11:~ # service mysql-server start Installing MariaDB/MySQL system tables in '/var/db/mysql' ... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER ! To do so, start the server, then issue the following commands: '/usr/local/bin/mysqladmin' -u root password 'new-password' '/usr/local/bin/mysqladmin' -u root -h bsd11 password 'new-password' Alternatively you can run: '/usr/local/bin/mysql_secure_installation' which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the MariaDB Knowledgebase at http://mariadb.com/kb or the MySQL manual for more instructions. You can start the MariaDB daemon with: cd '/usr/local' ; /usr/local/bin/mysqld_safe --datadir='/var/db/mysql' You can test the MariaDB daemon with mysql-test-run.pl cd '/usr/local/mysql-test' ; perl mysql-test-run.pl Please report any problems at http://mariadb.org/jira The latest information about MariaDB is available at http://mariadb.org/. You can find additional information about the MySQL part at: http://dev.mysql.com Consider joining MariaDB's strong and vibrant community:Get InvolvedStarting mysql. root@bsd11:~ #
패스워드 설정 ( mysqladmin 명령어로 password 를 설정 할수 있습니다.)
root@bsd10:~ # mysqladmin -u root password mariadb_password
mariadb_password 부분에 원하는 패스워드를 넣어 설정 하시면 됩니다.
or
mysql_secure_installation 으로 설정 하셔도 됩니다.
root@bsd11:~ # /usr/local/bin/mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. 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! root@bsd11:~ #
mysql 로그인을 하여 characterset 을 확인 합니다.
root@bsd11:~ # mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 23 Server version: 10.2.10-MariaDB FreeBSD Ports Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> status; -------------- mysql Ver 15.1 Distrib 10.2.10-MariaDB, for FreeBSD11.1 (amd64) using readline 5.1 Connection id: 23 Current database: Current user: root@localhost SSL: Not in use Current pager: more Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 10.2.10-MariaDB FreeBSD Ports Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: ascii Conn. characterset: ascii UNIX socket: /tmp/mysql.sock Uptime: 9 min 39 sec Threads: 7 Questions: 33 Slow queries: 0 Opens: 18 Flush tables: 1 Open tables: 12 Queries per second avg: 0.056 -------------- MariaDB [(none)]>
characterset 이 latin1 으로 되어 있습니다.
my.cnf 를 수정 하여 latin1 -> utf8 로 변경 합니다.
root@bsd11:~ # cp /usr/local/share/mysql/my-large.cnf /usr/local/etc/my.cnf root@bsd11:~ # vi /usr/local/etc/my.cnf [client] #password = your_password port = 3306 socket = /tmp/mysql.sock default-character-set = utf8 # The MariaDB server [mysqld] character-set-server=utf8 skip-character-set-client-handshake
mariadb 재시작 및 status 확인
root@bsd11:~ # service mysql-server restart Stopping mysql. Waiting for PIDS: 939. Starting mysql. root@bsd11:~ # root@bsd11:~ # mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.2.10-MariaDB-log FreeBSD Ports Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> status; -------------- mysql Ver 15.1 Distrib 10.2.10-MariaDB, for FreeBSD11.1 (amd64) using readline 5.1 Connection id: 9 Current database: Current user: root@localhost SSL: Not in use Current pager: more Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 10.2.10-MariaDB-log FreeBSD Ports Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /tmp/mysql.sock Uptime: 27 sec Threads: 8 Questions: 4 Slow queries: 0 Opens: 17 Flush tables: 1 Open tables: 11 Queries per second avg: 0.148 -------------- MariaDB [(none)]>
characterset 이 latin1 에서 utf8 로 변경 된걸 확인할수 있습니다.
phpinfo 페이지 출력
oot@bsd11:/home/test # mkdir public_html root@bsd11:/home/test # cd public_html/ root@bsd11:/home/test/public_html # vi test.php <?php phpinfo(); ?>
web브라우저에서 확인 (localhost 의 경우 freebsd box 의 ip 를 입력 하시면 됩니다.)