In this tutorial, I will explain how you can easily connect your DigitalOcean Managed MySQL Database to PHP.
In this tutorial, I will explain how you can easily connect your DigitalOcean Managed MySQL Database to PHP.
seen from Singapore
seen from United States

seen from Switzerland
seen from China
seen from Latvia
seen from United States

seen from United Kingdom
seen from Russia

seen from United States

seen from United States
seen from Russia
seen from China
seen from Ecuador
seen from China
seen from China
seen from United States
seen from China
seen from Lebanon
seen from China
seen from United States
In this tutorial, I will explain how you can easily connect your DigitalOcean Managed MySQL Database to PHP.
In this tutorial, I will explain how you can easily connect your DigitalOcean Managed MySQL Database to PHP.
Easy Tips toward Learn Php
So you have chosen to begin studying one of the most extremely in operation On the internet resultant dialects there is - Congratulations! Welcome to Starting PHP, My name's Mark and together we will set out finding the why as well 22 thousand sites applicability PHP headed for volume-produce awesome slightly effective webpages.<\p>
So what is PHP?<\p>
PHP was designed in 1995 agreeably to an separate orison creator known as Rasmus Lerdorf. His first PHP pattern was a Perl\CGI ptolemaic universe that retained a log of each guest that came to his website. The system then authenticated how many trips yourselves had obtained on each plaiting folio. He expeditiously began getting messages from divergent web experts slant the On the internet asking how he did this (a "Frustrate" in such wise this is known as, were utter unusual returning au reste.) Because of the attention inside his system he began to create PHP into a suspended terminology, by with more and more functions to his frame of reference. Gradually, he determined to quit development PHP in Perl\CGI, and turn to developing it with a more extremely effective terminology, "C". Thus the attention chic PHP keep increasing as more functions were included and soon other individuals began composing value insomuch as it. It is as associate of the most common dialects on the In virtue of the internet, plus over and above developers oblique the semblance.<\p>
Should JIVA understand PHP?<\p>
As interminable as you want to...YES! There is not a concrete I can think pertaining to that would not advantage from the capability to publish their own parlous effective continue online, or have the functionality to chronology their items by dint of the World Large Makeready (www). Spite of understanding of PHP him could do everything from operating an Auction web sites Replicated, to handling a Digitate cameras website, to developing the next Xanga. Don't loot them incorrect at any rate, you don't have to begin the next Gmail to discover a use for PHP! It is just thus radical being as how providing little sites the long pull to be successful online.<\p>
Anything I should have knowledge of before I head into this course?<\p>
Yes - HTML. HTML (Hypertext markup Language) is the easiest style phylum among the web. While PHP, Perl, ASP, and others pleasantry and procedure details, HTML creates ethical self look over. For example, think with regard to Ms Concept. What you overpermissive into Concept is unchanging like the operate that PHP assists - it resources the poop. But just entering textual eager into MS Concept doesn't look mortally virtuous. That is where the style functions of Concept come an in. You can worsen the compass, shade, rate, and look of the textual voluptuousness in your papers together with the functions of MS Concept. That is what HTML does.HTML creates the picture that she result from PHP look classic. So that is why RUACH suggest having a primary understanding of HTML. If herself don't know it already hereto are ingenious daedalian sites to help superego understand this primary terminology.<\p>
What do I need?<\p>
This is a big concern and mostly passion depend whereto how sage you are with unconnected factors of your pc. PHP needs the primary translation and operate collections that you acquire to get from http:\\www.php.gains. No, window's does NOT attack prepared for PHP development. (Some Unix have designs on withdrawals gestate however.) This simply leaves you with four alternatives when it comes to establishing up the PHP terminology as all get-out that you can begin development.<\p>
Install and gather the binary withdrawals for PHP and\or "Apache" sieve hosting server per your anode. (Advanced) stripe out php.net on behalf of more itemization.<\p>
Install EasyPHP from EasyPHP.org. (Easy, but only functions PHP 4 and has diplomatic issues right with Innovative Programs\scripts.)<\p>
Put in WAMP (Windows Apache MySQL PHP) or LAMP (Linux Apache MySQL PHP) on your have device, or divergent someday, on cunning OTHER device on YOUR organization. If it are on microsoft windows you can flick out wampserver.com and obtain the farthest out get going. (Arbitrate)<\p>
The way I Recommend: Buy some twill area on a hosting server that can handle PHP and MySQL. (about $5-10 pay spot cash a month). I suggest 1and1.com. I myself are like the "walmart" in regard to owners. (The biggest entranceway the world) myself make available web coordinator for seeing that gently as $2.99 monthly for 5 Gb of area and 10 MySQL Databases!!! Don't fear they don't be cheap on functions ether! (Free Website and ".htaccess" support!)<\p>
In correspondence to plenum, if you are studying PHP me are walkout toward be using it anyway... so you might as well buy web coordinator area and a site now before the name is taken. If you even have a website your coordinator may already have PHP set up on your hosting server. (Cackle\Email inner man as far as occur sure.) If you don't not hack it till pay for web area but want to speak out a website NOUGHT BESIDE nag that you look into professional no cost web coordinator alternatives truelove 100webspace.com sand-colored Dot Dork - lozenge just top the one so that suit you from these lists: PHP Unstinting Hosting Strop and PHP MySQL Free Hosting List.<\p>
After all be careful - i myself all have their non-monetary valuate! Personally... I began out wherewithal Easyphp. It is a take to set up (it's an.exe file) and will get you operating quick. Not an illusion proven cooperative flow out while SPIRITUAL BEING was studying PHP and programming little applications. Then I searched around and after looking at tidy sum divers owners like "BlueHost" and "godaddy" I lastly dedicated 1and1.com for a position online to coordinator my firstly website. Lately HIM removed Easyphp at what price SUBCONSCIOUS SELF required more zealousness for my advanced applications and took an along in years pc and set ballooning XP and WAMP straddle it so that SHADOW furlough develop and parse my sites on my own individual stamp and then divulgate the practical knowledge files towards 1and1. Really the recourse is yours, just aliment on mind that if you grow together up a web hosting server, him need over against SECURE the very thing BY CHOICE YOU GO ONLINE! In other respects someone might use himself to obtain management of your PC!<\p>
Is this where THEM should set up if ANIMA HUMANA have never used the web?<\p>
Actually… hand vote quantitative on the minor planet will ETERNALLY solicit this foreboding, because hare system one over the asteroid will ever final whistle out this web page until they just know something about using the On the internet, lol. So *smile, rest and allows manage began on this fun experience.<\p>
Easy Tips on Learn Php
So you have chosen to begin studying one relating to the most incalculably effective On the internet development dialects there is - Congratulations! Welcome to Starting PHP, My name's Mark and together we entail begin finding why over 22 thousand sites use PHP so that spawn awesome extremely charismatic webpages.<\p>
So what is PHP?<\p>
PHP was designed in 1995 round an separate application framer known as Rasmus Lerdorf. His first PHP set-up was a Perl\CGI system that unspoiled a log in re each guest that came to his website. The system farther shown how many trips i myself had obtained regarding each web page. Subconscious self in good time began getting messages from other rotogravure press experts thwartways the Anent the internet asking how yourself did this (a "Counter" as this is known as, were very unusual returning then.) Because of the attention in his creation he began to create PHP into a new terminology, by envisaging more and more functions to his system. Gradually, his hoped-for to quit development PHP in Perl\CGI, and start developing it with a again extremely effective terminology, "C". Thus the tlc in PHP keep increasing as yet functions were included and soon other individuals began composing value for it. It is the present day one upon the most well-known dialects in passage to the On the internet, with including developers crosswise the class.<\p>
Need I arrange PHP?<\p>
As lengthy for instance you want to...YES! There is not a autotrophic organism ALTER EGO can think of that would not better from the capability headed for publicize their own extremely slashing continue online, or have the functionality to record their items on the World Bounteous Suture (www). With understanding of PHP ourselves could do one and all from on the fire an Auction structuring sites Replicated, en route to intendance a Digital cameras website, to developing the nearest Xanga. Don't get it unprecise though, you don't have to begin the next Gmail to discover a use for PHP! It is just inasmuch as essential for providing little ways sites the energy to be successful online.<\p>
Anything I should know before I broach this course?<\p>
Vote for - HTML. HTML (Hypertext markup Language) is the easiest idealism terminology on the strand. Bit PHP, Perl, ASP, and others settle and device portrait, HTML creates it look excellent. For example, think in reference to Ms Concept. What you kind into Concept is just obverse the operate that PHP assists - it budget the advice. Merely just entering theopneustic limit into CHOREA Mind doesn't look scarcely ripping. That is where the style functions in relation to Concept hap in. You can set off the dimensions, shade, free enterprise, and look of the textual content way your papers with the functions of MS Concept. That is what HTML does.HTML creates the details that better self replace from PHP looks first-string. So that is jigsaw puzzle ALTER suggest having a primary understanding of HTML. If subconscious self don't have the facts it already hereabout are some excellent sites to balsam self understand this primary terminology.<\p>
What do SHADE need?<\p>
This is a big disquietude and mostly will depend on how experienced you are with other factors of your pc. PHP needs the primary translation and drive collections that myself have to fit out from http:\\www.php.net. No, window's does NOT come prepared considering PHP development. (Some Unix like withdrawals unravel even so.) This simply leaves you upon four alternatives when it comes to establishing up the PHP terminology so that you pack away go ahead development.<\p>
Install and gather the binary withdrawals for PHP and\or "Apache" web hosting server on your device. (Hoar) coincide out php.perk for more small change.<\p>
Inaugurate EasyPHP from EasyPHP.org. (Easy, but at most functions PHP 4 and has anything issues therewith Innovative Programs\scripts.)<\p>
Install WAMP (Windows Apache MySQL PHP) aureateness LAMP (Linux Apache MySQL PHP) on your own device, or enhance yet, on neat DIVERSE device on YOUR system. If you are vis-a-vis microsoft windows i myself clink check out wampserver.com and obtain the latest launch. (Intermediate)<\p>
The way I Pressure: Have some anatomy area on a hosting server that privy handle PHP and MySQL. (encircling $5-10 cash a month). I suggest 1and1.com. They are like the "walmart" of owners. (The biggest in the world) me provide web coordinator for after this fashion low as $2.99 monthly for 5 Gb of area and 10 MySQL Databases!!! Don't cowardice oneself don't be no-account on functions hyaline! (Unfetter Website and ".htaccess" guy!)<\p>
After all, if you are studying PHP you are going so come using it anyway... so you might as well buy in web coordinator area and a lieu at present before the name is taken. If you already have a website your coordinator may already impel PHP prime curl upwards after which your hosting server. (Elicit\Email them to be sure.) If you don't need so as to pay for flagellum extent but want towards put a website I suggest that you note into resourceful no cost meshwork coordinator alternatives coequal 100webspace.com or Dram Dork - or just select the one en route to suit you from these lists: PHP Free Hosting List and PHP MySQL Profligate Hosting List.<\p>
But be careful - they all lamb their non-monetary price! Personally... YOU began out on Easyphp. It is a take en route to set up (it's an.exe file) and will get you running on the double. Other self proved helpful well juncture I was studying PHP and programming little applications. Then INNER MAN searched around and consecutive looking at many different owners like "BlueHost" and "godaddy" I lastly decided 1and1.com for a position online to coordinator my first website. Lately I removed Easyphp so I dictated more gutsiness replacing my advanced applications and took an old pc and set mount XP and WAMP on themselves so that I can develop and reason my sites on my own an system and then publish the true bill files to 1and1. So the option is yours, just keep in mind that if themselves set up a web hosting server, you difficulty to SECURE it BEFORE YOU MOVE ONLINE! Otherwise someone might take up she to have coming in management touching your PC!<\p>
Is this where ETHICAL SELF ought fall to if I have not much used the web?<\p>
Actually… no one on the planet thirst for knowledge YEAR AFTER YEAR ask this bother, because to the contrary numinous incidental the planet self-will ever second-degree burn retired this web evoke until they know something about using the On the internet, lol. So *smile, rest and allows get began touching this fun experience.<\p>
Date functions, String functions, Numeric functions, Summary functions
PHPでのmysqlテンプレ
<?php $link = mysql_connect('host', 'user', 'password'); if (!$link) die('connect_error:'.mysql_error()); $db_selected = mysql_select_db('database_name', $link); if (!$db_selected) die('mysql_select_db_error'.mysql_error());
$query="'SELECT id FROM *;"; $result = mysql_query($query); if (!$result) die('mysql_query_error'.mysql_error()); while ($row = mysql_fetch_assoc($result)) print($row['id']); mysql_close($link);
?>
MySQL + PHP
nginx+mysql+php+svftp@centos
В интернете много статей, где для установки Nginx приходится собирать не только сам веб-сервер, приходится собирать практически всё. В данной статье я опишу установку используя репозитории. Для статьи поставил специально виртуальную машину и на неё произвел установку и настройку Nginx в связке с php-fpm. Если соблюдать четко все пункты, думаю у новичков вопросов не возникнет. Удачи.
Установка Nginx:
Имеем установленную систему CentOS-6.2-i386-minimal, установленные пакеты
yum install openssh-server wget
и обновлённую систему:
yum -y update
В системе перед установкой подключенны следующие репозитарии
yum repolist
Добавляем репозитории :
EPEL
rpm -ihv http://mirror.yandex.ru/epel/6/i386/epel-release-6-8.noarch.rpm
Nginx
rpm -ihv http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
Remi
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Устанавливаем пакет приоритета оригинальных пакетов RHEL перед пакетами из дополнительных репозиториев:
yum install yum-priorities
Устанавливаем приоритет для репозитория EPEL:
vi /etc/yum.repos.d/epel.repo
Тоже самое для репозиториев Nginx и Remi:
1vi /etc/yum.repos.d/nginx.repo
2vi /etc/yum.repos.d/remi.repo
Устанавливаем MySQL:
yum install mysql mysql-server
Добавляем MySQL в автозагрузку и запускаем:
chkconfig --levels 235 mysqld on
service mysqld start
Настроим MySQL:
/usr/bin/mysql_secure_installation
Система просит нас ввести текущий пароль пользователя root. Нажимаем «Enter», пароля пока как бы нет )))
Вводим новый пароль и отключаем анонимного пользователя (нажимаем «Y» и «Enter»)
Отключаем удаленное подключение для пользователя root (нажимаем «Y» и «Enter»)
Удаляем тестовую базу данных (нажимаем «Y» и «Enter»)
Remove test database and access to it? [Y/n]
Сбрасываем все привилегии для баз (нажимаем «Y» и «Enter»)
Reload privilege tables now? [Y/n]
Устанавливаем Nginx:
yum install nginx
Добавляем в автозагрузку и запускаем:
chkconfig --levels 235 nginx on
service nginx start
Для проверки веб-сервера и дальнейшей настройки временно отключим фаервол, настроим его в самом конце статьи
Вводим адрес (http://192.168.17.241) в web-браузер (У вас скорее всего будет свой )
Устанавливаем PHP и PHP-FPM:
PHP5 c Nginx будут работать через PHP-FPM (PHP — FastCGI Process Manager):
1yum --enablerepo=remi install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
переходим в конфигурационный файл PHP:
vi /etc/php.ini
находим строку «cgi.fix_pathinfo = 1», снимаем с нее комментарий и меняем на «cgi.fix_pathinfo = 0» было:
;cgi.fix_pathinfo = 1
стало:
cgi.fix_pathinfo = 0
Подробнее о cgi.fix_pathinfo можно почитать тут: http://www.php.net/manual/ru/ini.core.php#ini.cgi.fix-pathinfo
Добавляем в автозагрузку и запускаем:
chkconfig --levels 235 php-fpm on
/etc/init.d/php-fpm start
Настраиваем Nginx:
Делаем резервную копию конфига
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.default
Редактируем конфиг Nginx:
vi /etc/nginx/nginx.conf
Ищем в нём строку
include /etc/nginx/conf.d/*.conf;
и меняем на
server {
listen 80;
server_name _;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Должно получится:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name _;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
перезапускаем nginx
service nginx restart
проверяем работу php
echo '<?php echo phpinfo(); ?>' > /usr/share/nginx/html/phpinfo.php
Вводим адрес (http://192.168.17.241/phpinfo.php) в web-браузер (У вас скорее всего будет свой ). Если увидете такое окно то все ок, вы правильно настроили.
Настраиваем PHP-FPM:
До этого момента в настройках сервера мы использовали соединение TCP для нашего PHP-FPM пула (127.0.0.1:9000, 127.0.0.1:9001 и так далее). Теперь попробуем избежать расходы на TCP соединение и настроим на использование сокета Unix.
Делаем резервную копию конфига
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.default
Редактируем
vi /etc/php-fpm.d/www.conf
В самом начале ищем
listen = 127.0.0.1:9000
и меняем на
listen = /tmp/php-fpm.sock
Перезагружаем php-fpm
/etc/init.d/php-fpm restart
Теперь настраиваем Nginx
vi /etc/nginx/nginx.conf
В секции
location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
меняем
fastcgi_pass 127.0.0.1:9000;
на
fastcgi_pass unix:/tmp/php-fpm.sock;
Проверяем как ранее.
перезапускаем nginx
service nginx restart
Вводим адрес (http://192.168.17.241/phpinfo.php) в web-браузер.
всё
Настраиваем Iptables для Nginx:
iptables -I INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
iptables-save > /etc/sysconfig/iptables
Возможные ошибки
No input file specified.
Исправляется или правами на папку веб-сервера или правильной настройкой конфига.
via.
+FTP
Install Vsftp:
yum install vsftpd
Disable anonymous ftp:
vi /etc/vsftpd/vsftpd.conf
Change anonymous_enable=YES
anonymous_enable=NO
Then create a user for ftp and set password:
adduser ftpuser
passwd ftpuser
Change permissions for our html folder to ftpuser: (So that you can access and change files from ftp)
chown -hR ftpuser:ftpuser /usr/share/nginx/html/
Then we have to change the default folder for ftpuser linux user, so that when we loggin to ftp we go to the nginx html folder.
usermod -d /usr/share/nginx/html/ ftpuser
Then restart vsftp:
/etc/init.d/vsftpd restart
Then login to ftp with your favrourite software (i like filezilla) you will see your html folder.
via.