JavaScript must be enabled in order for you to see "WP Copy Data Protect" effect. However, it seems JavaScript is either disabled or not supported by your browser. To see full result of "WP Copy Data Protector", enable JavaScript by changing your browser options, then try again.

Setup a wordpress website w/ Nginx/PHP5/MySQL on FreeBSD 10.2 x64


Hello everyone, it’s time to post a rubbish. The topic of today is how to setup a wordpress website w/ Nginx/PHP5/MySQL on the FreeBSD 10.2 x64, and I have built a wordpress website w/ Apache2/PHP5/MySQL on the CentOS, so there are some differences between these methods. How do we do to setup it? Let’s keep reading:

1) OS Installation w/ the image of FreeBSD 10.2 amd64

2) Edit the conf of /etc/ssh/sshd_config for login of root
#cat /etc/ssh/sshd_config | grep -i 'PermitRootLogin yes'
PermitRootLogin yes
#service sshd reload -> No use for restart

3) Install the package of bash
#pkg install bash
#pkg_add -r bash
#portsnap update extract && cd /usr/ports/shells/bash && make install clean

4) Setup the default shell w/ bash for the account of root
#chsh -s /usr/local/bin/bash root
#chsh -s bash root
#grep root /etc/passwd
#egrep --color 'root|bash' /etc/passwd
#finger root

5) Customize the default shell through ~/.bashrc and ~/.bash_profile
#cat ~/.bashrc
alias vi='vim'
alias grep='grep --color=auto'
alias cd..="cd .."
alias cd...="cd ../.."
alias cd....="cd ../../.."
alias cd.....="cd ../../../.."
alias cd......="cd ../../../../.."
function mkdircd () { mkdir -p "$@" && eval cd "\"\$$#\""; }
shopt -s cdspell
PS1="\[\e[1;34m\][\[\e[0;31m\]\u\[\e[1;37m\]@\[\e[1;36m\]\h \[\e[1;33m\]\W \[\e[1;35m\]\t\[\e[1;34m\]]\[\e[1;32m\]\\$ "
export HISTTIMEFORMAT='%F %T '
export HISTCONTROL=ignoredups
export HISTCONTROL=ignorespace
export HISTCONTROL=ignoreboth
bind "set completion-ignore-case on"
HISTTIMEFORMAT='%F %T '
function psgrep () {
ps aux | grep "$1" | grep -v 'grep'
}
function psterm () {
[ ${#} -eq 0 ] && echo "usage: $FUNCNAME STRING" && return 0
local pid
pid=$(ps ax | grep "$1" | grep -v 'grep' | awk '{ print $1 }' )
echo -e "terminating '$1' / process(es):\n$pid"
kill -SIGTERM $pid
}
#cat ~/.bash_profile -> For login
source ~/.bashrc
#bash

6) Install and configure the conf w/ sl, htop and vim
#pkg install sl
#pkg install htop
#echo "linproc /compat/linux/proc linprocfs rw,late 0 0" >> /etc/fstab
#mkdir -p /usr/compat/linux/proc; ln -s /usr/compat /compat; mount linproc
#pkg install vim
#wget https://github.com/kaochenlong/eddie-vim/archive/master.zip
#tar zxvf eddie-vim-master.zip
#mv eddie-vim-master.zip .vim

7) Install the packages w/ Nginx, MySQL-Server, PHP5 and configure php5
#pkg install nginx mysql56-server php56 php56-mysql
#rehash -> If using tcsh, can skip this w/ bash
#cat /usr/local/etc/rc.d/* | grep rcvar
#echo 'mysql_enable="YES"' >> /etc/rc.conf
#echo 'nginx_enable="YES"' >> /etc/rc.conf
#echo 'php_fpm_enable="YES"' >> /etc/rc.conf
#cd /usr/local/etc
#cat php-fpm.conf | grep -i listen
listen = /var/run/php-fpm.sock
listen.owner = www -> Delete ; for uncomment
listen.group = www
listen.mode = 0660
#cp php-ini-production php.ini
#cat php.ini
cgi.fix_pathinfo=0 -> Delete ; for uncomment
#service php-fpm start
#service mysql-server start

8) Setup the basic setting for MySQL Server
#mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, 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):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
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 MySQL
root user without the proper authorisation.
Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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]
... 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] N
... skipping.
By default, MySQL 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]
- 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]
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
#service mysql-server restart
#service nginx start


9) Setup the configuration for Nginx
#cd /usr/local/etc/nginx
#cat nginx.conf
user www;
worker_processes 2; -> Can query w/ #sysctl hw.ncpu
error_log /var/log/nginx/error.log info;
access_log /var/log/nginx/access.log;
server {
listen 80;
server_name iori.tw ioribk.iori.tw;
...
root /usr/local/www/nginx;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
...
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
#cat nginx.conf | grep -v '#' -> Can double check the content of nginx.conf
#mkdir -p /var/log/nginx
#touch /var/log/nginx/access.log
#touch /var/log/nginx/error.log
#rm /usr/local/www/nginx
#mkdir /usr/local/www/nginx
#cp /usr/local/www/nginx-dist/index.html /usr/local/www/nginx
#cat /usr/local/www/nginx/info.php
<?php phpinfo(); ?>
#nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
#service nginx restart
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Stopping nginx.
Waiting for PIDS: 1379.
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.


10) Install the packages that are be needed for wordpress
#pkg install php56-xml php56-hash php56-gd php56-curl php56-tokenizer php56-zlib php56-zip
#service php-fpm restart

11) Create DataBase and grant the permission w/ DB’s account
#mysql -u root -p
mysql>CREATE DATABASE db;
mysql>CREATE USER wpiori@localhost IDENTIFIED BY 'password';
mysql>GRANT ALL PRIVILEGES ON iori.* TO account@localhost;
mysql>FLUSH PRIVILEGES;
mysql>exit

12) Download and deploy the tarball about wordpress w/ the latest version
#cd ~
#fetch http://wordpress.org/latest.tar.gz
#tar zxvf latest.tar.gz
#rm latest.tar.gz
#cd wordpress
#cp wp-config-sample.php wp-config.php
#cat wp-config.php
/** The name of the database for WordPress */
define('DB_NAME', 'db');
/** MySQL database username */
define('DB_USER', 'account');
/** MySQL database password */
define('DB_PASSWORD', 'password');
#pkg install rsync
#rsync -avP ~/wordpress /usr/local/www
#chown -R www:www /usr/local/www/wordpress
#chmod -R 770 /usr/local/www/wordpress
#cat /usr/local/etc/nginx/nginx.conf
server {
...
root /usr/local/www/wordpress;
...
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
#nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
#service nginx restart
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Stopping nginx.
Waiting for PIDS: 1476.
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.



13) Install the package of tmux
#pkg install tmux

◎、Above information is about setup a wordpress website w/ Nginx/PHP5/MySQL on FreeBSD 10.2 x64, and I have referred these article from here and this, you can search more detail information on the Google. That’s all for today, see you next time!

  1. Hi Iori,
    I really like this post. It tells many skills that I’ve never used. Such as "Finger" and your customize shell. They’re really good things. :razz:

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
This site is protected by WP-CopyRightPro