version: Ubuntu 14.04 nginx-1.12.2 mysql-5.6 php-5.6
1, installation nginx-1.12.2
1) Dependent installation
sudo apt-get install OpenSSL libssl-devsudo apt-get install libpcre3 libpcre3-devsudo apt-get install Z Lib1g-dev
2) Add user
sudo useradd www
3) Download http://nginx.org/download/nginx-1.12.2.tar.gz and unzip
Enter the directory where the nginx-1.12.2 is located, such as/home/cky
Cd/home/cky
Extract
Tar xzf nginx-1.12.2.tar.gz
4) Enter the appropriate directory and compile
CD nginx-1.12.2. /--prefix=/usr/local/--user=--group=--with---with-http_ssl_module
5) Installation
sudo make install
6) Copy Nginx to bin directory for ease of use
sudo cp/usr/local/nginx/sbin/nginx /usr/bin/
7) Start
sudo nginx
8) Other common operations
Close Nginx
sudo ginx-s stop
Reread Nginx configuration file
sudo nginx-s reload
9) test, browser input http://127.0.0.1 popup Welcome to nginx! That means the installation was successful.
2. Install PHP
# The following two lines can not be installed "as if you can not install"
sudo apt-get install php5
sudo apt-get install php5-cli
sudo apt-get install php5-fpm
3. Modify nginx configuration file to support PHP
#打开配置文件
sudo vi /usr/local/nginx/conf/nginx.conf
Press keyboard A to enter edit mode
Change content 1, line 43rd or so
Location/ { root html; Index index.html index.htm; }
Change to:
Location/ { root /www/wwwroot; Index index.html index.htm index.php; }
Change content 2, line 65th or so
# Location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param script_filename /scripts$fastcgi_script_name; # include fastcgi_params; # }
Change to:
Location ~ \.php$ { root /www/wwwroot/; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include fastcgi_params; }
Press ESC to return to insert mode and save exit
: Wq
4. Modify the PHP configuration file
1) Modify the PHP5-FPM group and the listening port, after PHP 5.4, PHP5-FPM is not listening 9000 port
sudo vi/etc/php5/fpm/pool.d/www.conf
PHP5-FPM Group:
; user = www-= Www-data
Switch
user == www
To change the listening port:
; listen =/var/run/php5-fpm.sock
Switch
Listen = 127.0.0.1:9000
2) configuration php-fpm
sudo vi /etc/php5/fpm/php.ini
768 rows, which will
; cgi.fix_pathinfo=1
Instead (also remove the semicolon)
Cgi.fix_pathinfo=0
Save exit
5. Install MySQL Database
1) Install mysql-client-core-5.6
sudo apt-get install mysql-client-core-5.6
2) Install mysql-client-5.6
sudo apt-get install mysql-client-5.6
3) Install mysql-server-5.6
sudo apt-get install mysql-server-5.6
To set the root user's password during installation
4) MySQL related operations
See if the MySQL process is running
Ps-ef | grep MySQL
View MSYQL Listening ports
Netstat-tap | grep MySQL
MSYQL Service stopped
sudo service MySQL stop
Mysql service startup
sudo service MySQL start
Mysql Service Restart
sudo service MySQL restart
5) Setting up the MySQL service remote access
sudo vi/etc/mysql/my.cnf
47 lines instead
# bind-address = 127.0.0.1
Restart MSYQL
sudo service MySQL restart
Modify access Permissions
Go to MySQL, enter the following command, enter the password and enter the MySQL command line
Mysql-u root-p
Grant root access and refresh permissions, where root can be replaced by other MySQL users, and the PWD section should be replaced with the password for that user
Grant all privileges on * * to [email protected]"%""pwd " With Grant Option;flush privileges;
Exit
Restart MySQL Service
sudo service MySQL restart
6. Garbled when storing Chinese in database
1) Go to MySQL command line and view MySQL server code
Status
The discovery is Latin1 encoding method non-UTF8, need to modify to UTF8 encoding
2) exit the MySQL command line and modify the configuration file
sudo vi/etc/mysql/my.cnf
Append under [client]
default-character-set = UTF8
Append under [mysqld]
Character-set-server = UTF8
modified as follows
[mysqld] # # * Basic Settings # mysqlpid -file =/var/run/mysqld/mysqld.pidsocket =/var/run/mysqld/mysqld.sockport = 3306basedir =/usrdatadir =/var/lib/mysqltmpdir =/TMPLC -messages-dir =/usr/share/mysqlcharacter -set-server = Utf8skip -external-locking
Append under [MySQL]
default-character-set = UTF8
Save exit, restart MySQL server
sudo service MySQL restart
Check the MySQL server encoding again
Enter MySQL command line again:
Status
Verify that the encoding for Latin1 has been changed to UTF8
Ubuntu 14.04 + nginx + php + mysql Build