Configure nginx+php+mysql+phpmyadmin in Ubuntu
- 2017-10-30 15:46:00
- Memory, Renee Original
- 4839
Follow the steps below.
Start terminal and update Ubuntu
sudo atp-get update
2、Install and start Nginx
Enter
sudo apt-get install nginx
3、Check whether it is installed. Visit http://localhost. If you see “Welcome to Nginx!”, it means it has been installed.
4、Install mysql (You will be asked to set a password for the default account which is root)
sudo apt-get install mysql-server mysql-clinet
5、Install phpmyadmin and create a soft link in the root directory of a virtual machine
Enter
sudo apt-get install phpmyadmin sudo In -s /usr/share/phpmyadmin/ /var/www/****.com/ Stars can be the domain name of your website for convenience. /var/www/****.com/ is the address of the virtual machine.
6、Install PHP and extensions
Enter
sudo apt-get install php5 php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-sqlite php5-xsl
7、Install spawn-fcgi (for php5 cgi)
Enter
sudo apt-get install spawn-fcgi
8、In Nginx, congifure spawn-fcgi (use nano to locate the file and change it )
(1)Add "fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;" to /etc/nginx/fastcgi_params (2)sudo sed -i '$ i fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' /etc/nginx/fastcgi_params
9、Modify php.ini and set cgi.fix_pathinfo as 1.
Enter
sudo sed -i '/cgi.fix_pathinfo=/ c cgi.fix_pathinfo=1;' /etc/php5/cgi/php.ini
10、Start fastcgi and set boot startup
(1)sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid (2)Set boot startup, which is to add "/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid" to /etc/rc.local (3)sudo sed -i '/^exit/ i /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid' /etc/rc.local
11、Configure virtual machine in Nginx (VERY IMPORTANT)
(1)sudo vim /etc/nginx/sites-available/****.com Stars can be any name you wnat (2)Modify site ****.com .conf and add
server { listen 80; #WordPress access port(Default 80) server_name ***.com www.***.com; #hostname,bind domain root /var/www/***.com; #root directory of site location / { index index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /etc/nginx/fastcgi_params; } }
12、Start Nginx / php
Enter sudo /etc/init.d/nginx restart
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 /usr/bin/php-cgi
After it is done, access http://localhost/phpmyadmin via http://localhost.
Support
- Book a Demo
- Tech Forum
- GitHub
- SourceForge
About Us
- Company
- Privacy Policy
- Term of Use
- Blogs
- Partners
Contact Us
- Leave a Message
- Email Us: [email protected]