您好,欢迎访问一九零五行业门户网

ubuntu14.04 LEMP(linux+nginx+mysql+php5)构建环境,_PHP教程

ubuntu14.04 lemp(linux+nginx+mysql+php5)构建环境,install lemp (linux, nginx, mysql and php) stack on ubuntu linux 14.04 ltsby vivek gite on december 2, 2014
i'm a new ubuntu linux user. how do i install the lemp stack on an ubuntu linux 14.04 lts server using command line options to serve dynamic web apps?
tutorial detailsdifficulty easy (rss)
root privileges yes
requirements ubuntu
estimated completion time 15m
what is new in ubuntu 14.04 (trusty tahr) version?you may see it on cyberciti.biz or visit the ubuntu home page at ubuntu.com.
nginx installationnginx is one of the robust web server in linux world. nginx is a free, open source, high performance http server and reverse proxy, as weell as an imap/pop3 proxy server. now, we are going to install nginx web server.
first, make sure system is upto date:
$ sudo apt-get update
#1 - download and install nginx
the easiest way to download and install nginx is using apt-get command. here is the command:
$ sudo apt-get install nginx
fig.01: download and install nginx on ubuntu linux
#2 - test nginxonce it get done, you can open your browser and type url http://localhost or http://your_ip_address to test it. if everything goes normal, you will see nginx welcome page:
fig.02: welcome nginx page on ubuntu linux
mysql installation on ubuntumysql is one of the most powerful database management system in linux world. next, we are going to install it with php support.
#1 - install mysql and php supporttype the following command:
$ sudo apt-get install mysql-server php5-mysql
fig.03: ubuntu linux install mysql to manage site data with php
#2 - test mysqlonce mysql installation finished, we can test it. open your console and type the following command:
$ mysql -u root -p
fig.04: ubuntu test mysql installation
#3 - securing access to mysqlif we are going to use mysql as a production database, we may want to secure it. mysql provides a shell script to help us securing it. just type the following command on your console:
$ sudo mysql_secure_installation
1. enter your root password
enter your current root password to continue to the next step.
fig.05: mysql enter your root db password
2.change the root passwordif you want to change it, press y. otherwise, press n.
fig.06: mysql security
3.remove anonymous userit is recommended to remove anonymous user to mitigate risk who can log in into your database.
fig.07: mysql security
4.disallow root login remotelyto make sure that no one remote your database as root from another machines, we need to disallow root login remotely.
fig.08: mysql security
5.remove test databasesometimes some mysql installation will create a database named ëtestí for testing purpose. we can remove it if we donít use it.
fig.09: mysql security
6.reload privilege tablesthen we need to reloading the privilege tables to ensure all changes made so far will take effect immediately.
fig.10: mysql security
7.donefig.11: mysql securityphp installation for server side scriptingsince php is popular, a lot of websites is built using php language. as of january 2013, php was installed on more than 240 millions websites. now we are going to install php on ubuntu 14.04
#1 - download and install phpas usual, we can download and install php using apt-get command. just type the following command on your ubuntu console or over the ssh based session:
$ sudo apt-get install php5-fpm
fig.12: install php for server side processing on ubuntu
configure nginx to work with php and mysql server on ubuntunow we have all components installed. the next step is we need to configure nginx with php and mysql. let's start to configure them.
#1 - configure php5-fpmphp5-fpm configuration file is located at /etc/php5/fpm/php.ini. open it with your text editor
$ sudo vi /etc/php5/fpm/php.ini
cgi.fix_pathinfo=1
cgi.fix_pathinfo=0
$ sudo service php5-fpm restart
#2 - configure nginxnginx configuration file is located at /etc/nginx/nginx.conf. but basically, we don't need to touch it. the configuration of nginx website is located in /etc/nginx/sites-available/default file.
location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # # note: you should have cgi.fix_pathinfo = 0; in php.ini # # # with php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # with php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
then restart the services.
$ sudo service nginx restart
$ tail /var/log/nginx/error.log
fastcgi_pass unix:/var/run/php5-fpm.sock
location ~ \.php$ {
#3 - configure mysqlafter the configuration section is done, now we need to test them to make sure that our configuration is working as required. on ubuntu 14.04 the root document folder is located in /usr/share/nginx/html. so create a file called /usr/share/nginx/html/phpinfo.php with the following code:
[php] view plaincopyafter restarting php-fpm and nginx, open the browser and browse to the php file, we got only a blank screen. no error message on the screen. no error message on php-fpm and nginx log file.
and then open the browser again and type url http://your_ip_address/phpinfo.php
... your code ... ?>to enable short php tag, we need to change the value of short_open_tag parameter on php.ini file:
sudo service php5-fpm restartthen try again to test your phpinfo file. next, we will see if the mysql support is enabled or not. scroll down the php configuration screen on your browser, if you see mysql block there, then mysql support already enabled.you are now ready to use nginx, php5 and mysql on ubuntu server. i hope this quick article help anyone who wish to install linux, nginx, php and mysql on ubuntu 14.04.
http://www.bkjia.com/phpjc/1084380.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1084380.htmltecharticleubuntu14.04 lemp(linux+nginx+mysql+php5)构建环境, install lemp (linux, nginx, mysql and php) stack on ubuntu linux 14.04 lts by vivek gite on december 2, 2014 i 'm a new ubun...
其它类似信息

推荐信息